public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->document->setTitle($this->language->get('heading_title'));
     $this->form = new AForm('ContactUsFrm');
     $this->form->loadFromDb('ContactUsFrm');
     $form = $this->form->getForm();
     if ($this->request->is_POST() && $this->_validate()) {
         // move all uploaded files to their directories
         $file_pathes = $this->form->processFileUploads($this->request->files);
         $mail = new AMail($this->config);
         $mail->setTo($this->config->get('store_main_email'));
         $mail->setFrom($this->request->post['email']);
         $mail->setSender($this->request->post['first_name']);
         $mail->setSubject(sprintf($this->language->get('email_subject'), $this->request->post['name']));
         $msg = $this->request->post['enquiry'] . "\r\n";
         $form_fields = $this->form->getFields();
         foreach ($form_fields as $field_name => $field_info) {
             if (has_value($this->request->post[$field_name]) && !in_array($field_name, array('first_name', 'email', 'enquiry', 'captcha'))) {
                 $field_details = $this->form->getField($field_name);
                 $msg .= "\r\n" . rtrim($field_details['name'], ':') . ":\t" . $this->request->post[$field_name];
             }
         }
         if ($file_pathes) {
             $msg .= "\r\n" . $this->language->get('entry_attached') . ": \r\n";
             foreach ($file_pathes as $file_info) {
                 $basename = pathinfo(str_replace(' ', '_', $file_info['path']), PATHINFO_BASENAME);
                 $msg .= "\t" . $file_info['display_name'] . ': ' . $basename . " (" . round(filesize($file_info['path']) / 1024, 2) . "Kb)\r\n";
                 $mail->addAttachment($file_info['path'], $basename);
             }
         }
         $mail->setText(strip_tags(html_entity_decode($msg, ENT_QUOTES, 'UTF-8')));
         $mail->send();
         //get success_page
         if ($form['success_page']) {
             $success_url = $this->html->getSecureURL($form['success_page']);
         } else {
             $success_url = $this->html->getSecureURL('content/contact/success');
         }
         $this->redirect($success_url);
     }
     if ($this->request->is_POST()) {
         foreach ($this->request->post as $name => $value) {
             $this->form->assign($name, $value);
         }
     }
     $this->document->resetBreadcrumbs();
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('content/contact'), 'text' => $this->language->get('heading_title'), 'separator' => $this->language->get('text_separator')));
     $this->view->assign('form_output', $this->form->getFormHtml());
     $this->view->assign('action', $this->html->getURL('content/contact'));
     $this->view->assign('store', $this->config->get('store_name'));
     $this->view->assign('address', nl2br($this->config->get('config_address')));
     $this->view->assign('telephone', $this->config->get('config_telephone'));
     $this->view->assign('fax', $this->config->get('config_fax'));
     $this->processTemplate('pages/content/contact.tpl');
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }
 protected function getBlockContent($instance_id)
 {
     $block_info = $this->layout->getBlockDetails($instance_id);
     $custom_block_id = $block_info['custom_block_id'];
     $descriptions = $this->layout->getBlockDescriptions($custom_block_id);
     if ($descriptions[$this->config->get('storefront_language_id')]) {
         $key = $this->config->get('storefront_language_id');
     } else {
         $key = $descriptions ? key($descriptions) : null;
     }
     if ($descriptions[$key]['content']) {
         $content = unserialize($descriptions[$key]['content']);
     } else {
         $content = array('form_id' => null);
     }
     $this->loadModel('tool/forms_manager');
     $form_data = $this->model_tool_forms_manager->getForm($content['form_id']);
     if (empty($form_data)) {
         return array();
     }
     $field_types = $this->model_tool_forms_manager->getFieldTypes($content['form_id']);
     $form = new AForm();
     $form->loadFromDb($form_data['form_name']);
     $form_info = $form->getForm();
     $form_info['controller'] = $form_info['controller'] . '&form_id=' . $content['form_id'];
     $form->setForm($form_info);
     if (isset($this->session->data['custom_form_' . $content['form_id']]['errors'])) {
         $form->setErrors($this->session->data['custom_form_' . $content['form_id']]['errors']);
         unset($this->session->data['custom_form_' . $content['form_id']]['errors']);
     }
     $output = array('title' => $key ? $descriptions[$key]['title'] : '', 'content' => $form->getFormHtml(), 'block_wrapper' => $key ? $descriptions[$key]['block_wrapper'] : 0, 'block_framed' => $key ? (int) $descriptions[$key]['block_framed'] : 0);
     return $output;
 }
Esempio n. 3
0
 public function download()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     if ($this->user->canAccess('tool/files')) {
         $filename = str_replace(array('../', '..\\', '\\', '/'), '', $this->request->get['filename']);
         if ($this->request->get['attribute_type'] == 'field') {
             $this->loadModel('tool/file_uploads');
             $attribute_data = $this->model_tool_file_uploads->getField($this->request->get['attribute_id']);
         } elseif (strpos($this->request->get['attribute_type'], 'AForm:') === 0) {
             // for aform fields
             $form_info = explode(':', $this->request->get['attribute_type']);
             $aform = new AForm('ST');
             $aform->loadFromDb($form_info[1]);
             $attribute_data = $aform->getField($form_info[2]);
         } elseif ($this->request->get['order_option_id']) {
             $this->loadModel('sale/order');
             $attribute_data = $this->model_sale_order->getOrderOption($this->request->get['order_option_id']);
             $attribute_data['settings'] = unserialize($attribute_data['settings']);
         } else {
             $am = new AAttribute($this->request->get['attribute_type']);
             $attribute_data = $am->getAttribute($this->request->get['attribute_id']);
         }
         if (has_value($attribute_data['settings']['directory'])) {
             $file = DIR_APP_SECTION . 'system/uploads/' . $attribute_data['settings']['directory'] . '/' . $filename;
         } else {
             $file = DIR_APP_SECTION . 'system/uploads/' . $filename;
         }
         if (file_exists($file)) {
             header('Content-Description: File Transfer');
             header('Content-Type: application/x-gzip');
             header('Content-Disposition: attachment; filename=' . $filename);
             header('Content-Transfer-Encoding: binary');
             header('Expires: 0');
             header('Cache-Control: must-revalidate');
             header('Pragma: public');
             header('Content-Length: ' . filesize($file));
             ob_end_clean();
             flush();
             readfile($file);
             exit;
         } else {
             echo 'Error: File ' . $file . ' does not exists!';
             exit;
         }
     } else {
         return $this->dispatch('error/permission');
     }
 }
 public function main()
 {
     $this->loadModel('tool/forms_manager');
     $this->loadLanguage('forms_manager/forms_manager');
     $this->loadLanguage('forms_manager/default_email');
     if ($this->request->is_POST()) {
         $path = $_SERVER['HTTP_REFERER'];
         if (!isset($this->request->get['form_id'])) {
             $this->redirect($path);
             exit;
         }
         $form_id = $this->request->get['form_id'];
         $form_data = $this->model_tool_forms_manager->getForm($form_id);
         $form = new AForm($form_data['form_name']);
         $form->loadFromDb($form_data['form_name']);
         $errors = $form->validateFormData($this->request->post);
         if ($errors) {
             //save error and data to session
             $this->session->data['custom_form_' . $form_id] = $this->request->post;
             $this->session->data['custom_form_' . $form_id]['errors'] = $errors;
             $this->redirect($path);
             exit;
         } else {
             $mail = new AMail($this->config);
             $mail->setTo($this->config->get('store_main_email'));
             if (isset($this->request->post['email'])) {
                 $mail->setFrom($this->request->post['email']);
                 unset($this->request->post['email']);
             } else {
                 $sender_email = $this->config->get('forms_manager_default_sender_email');
                 $sender_email = !$sender_email ? $this->config->get('store_main_email') : $sender_email;
                 $mail->setFrom($sender_email);
             }
             if (isset($this->request->post['first_name'])) {
                 $mail->setSender($this->request->post['first_name']);
                 unset($this->request->post['first_name']);
             } else {
                 $sender_name = $this->config->get('forms_manager_default_sender_name');
                 $sender_name = !$sender_name ? $this->config->get('store_name') : $sender_name;
                 $mail->setSender($sender_name);
             }
             if (isset($this->request->post['email_subject'])) {
                 $mail->setSubject($this->request->post['email_subject']);
                 unset($this->request->post['email_subject']);
             } else {
                 $mail->setSubject($form_data['form_name']);
             }
             $msg = $this->config->get('store_name') . "\r\n" . $this->config->get('config_url') . "\r\n";
             $fields = $this->model_tool_forms_manager->getFields($form_id);
             foreach ($fields as $field) {
                 // skip files and captchas
                 if (in_array($field['element_type'], array('K', 'J', 'U'))) {
                     continue;
                 }
                 if (isset($this->request->post[$field['field_name']])) {
                     $val = $this->request->post[$field['field_name']];
                     $val = $this->_prepareValue($val);
                     //for zones
                     if ($field['element_type'] == 'Z') {
                         $msg .= $field['name'] . ': ' . $val . "";
                         $val = $this->request->post[$field['field_name'] . '_zones'];
                         $val = $this->_prepareValue($val);
                         $msg .= "\t" . $val . "\r\n";
                     } else {
                         $msg .= $field['name'] . ': ' . $val . "\r\n";
                     }
                 }
             }
             // add attachments
             $file_pathes = $form->processFileUploads($this->request->files);
             if ($file_pathes) {
                 $msg .= "\r\n" . $this->language->get('entry_attached') . ": \r\n";
                 foreach ($file_pathes as $file_info) {
                     $basename = pathinfo(str_replace(' ', '_', $file_info['path']), PATHINFO_BASENAME);
                     $msg .= "\t" . $file_info['display_name'] . ': ' . $basename . " (" . round(filesize($file_info['path']) / 1024, 2) . "Kb)\r\n";
                     $mail->addAttachment($file_info['path'], $basename);
                 }
             }
             $mail->setText(strip_tags(html_entity_decode($msg, ENT_QUOTES, 'UTF-8')));
             $mail->send();
             if (empty($mail->error)) {
                 if ($form_data['success_page']) {
                     $success_url = $this->html->getSecureURL($form_data['success_page']);
                 } else {
                     $success_url = $this->html->getSecureURL('forms_manager/default_email/success');
                 }
                 //clear form session
                 unset($this->session->data['custom_form_' . $form_id]);
                 $this->redirect($success_url);
                 exit;
             } else {
                 $this->session->data['warning'] = $mail->error;
                 $this->redirect($this->html->getSecureURL('forms_manager/default_email', '&form_id=' . $form_id));
                 exit;
             }
         }
     }
     $this->data['warning'] = $this->session->data['warning'];
     if (isset($this->session->data['warning'])) {
         unset($this->session->data['warning']);
     }
     $this->document->setTitle($this->language->get('text_default_email_title'));
     $this->document->resetBreadcrumbs();
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('forms_manager/default_email'), 'text' => $this->language->get('text_default_email_title'), 'separator' => $this->language->get('text_separator')));
     $this->data['continue'] = $_SERVER['HTTP_REFERER'];
     $continue = HtmlElementFactory::create(array('type' => 'button', 'name' => 'continue_button', 'text' => $this->language->get('button_continue'), 'style' => 'button', 'icon' => 'icon-arrow-right'));
     $this->data['continue_button'] = $continue;
     $this->view->batchAssign($this->data);
     $this->processTemplate('pages/default_email.tpl');
 }
Esempio n. 5
0
 public function main()
 {
     //init controller data
     $this->extensions->hk_InitData($this, __FUNCTION__);
     $this->document->setTitle($this->language->get('heading_title'));
     $this->form = new AForm('ContactUsFrm');
     $this->form->loadFromDb('ContactUsFrm');
     $form = $this->form->getForm();
     if ($this->request->is_POST() && $this->_validate()) {
         // move all uploaded files to their directories
         $file_pathes = $this->form->processFileUploads($this->request->files);
         $template = new ATemplate();
         $subject = sprintf($this->language->get('email_subject'), $this->request->post['name']);
         $template->data['subject'] = $subject;
         $mail = new AMail($this->config);
         $mail->setTo($this->config->get('store_main_email'));
         $mail->setFrom($this->config->get('store_main_email'));
         $mail->setReplyTo($this->request->post['email']);
         $mail->setSender($this->request->post['first_name']);
         $mail->setSubject($subject);
         $store_logo = md5(pathinfo($this->config->get('config_logo'), PATHINFO_FILENAME)) . '.' . pathinfo($this->config->get('config_logo'), PATHINFO_EXTENSION);
         $template->data['logo'] = 'cid:' . $store_logo;
         $template->data['store_name'] = $this->config->get('store_name');
         $template->data['store_url'] = $this->config->get('config_url');
         $template->data['text_project_label'] = project_base();
         $template->data['entry_enquiry'] = $msg = $this->language->get('entry_enquiry');
         $msg .= "\r\n" . $this->request->post['enquiry'] . "\r\n";
         $template->data['enquiry'] = nl2br($this->request->post['enquiry'] . "\r\n");
         $form_fields = $this->form->getFields();
         $template->data['form_fields'] = array();
         foreach ($form_fields as $field_name => $field_info) {
             if (has_value($this->request->post[$field_name]) && !in_array($field_name, array('first_name', 'email', 'enquiry', 'captcha'))) {
                 $field_details = $this->form->getField($field_name);
                 $msg .= "\r\n" . rtrim($field_details['name'], ':') . ":\t" . $this->request->post[$field_name];
                 $template->data['form_fields'][rtrim($field_details['name'], ':')] = $this->request->post[$field_name];
             }
         }
         if ($file_pathes) {
             $msg .= "\r\n" . $this->language->get('entry_attached') . ": \r\n";
             foreach ($file_pathes as $file_info) {
                 $basename = pathinfo(str_replace(' ', '_', $file_info['path']), PATHINFO_BASENAME);
                 $msg .= "\t" . $file_info['display_name'] . ': ' . $basename . " (" . round(filesize($file_info['path']) / 1024, 2) . "Kb)\r\n";
                 $mail->addAttachment($file_info['path'], $basename);
                 $template->data['form_fields'][$file_info['display_name']] = $basename . " (" . round(filesize($file_info['path']) / 1024, 2) . "Kb)";
             }
         }
         $mail_html = $template->fetch('mail/contact.tpl');
         $mail->setHtml($mail_html);
         $mail->addAttachment(DIR_RESOURCE . $this->config->get('config_logo'), $store_logo);
         $mail->setText(strip_tags(html_entity_decode($msg, ENT_QUOTES, 'UTF-8')));
         $mail->send();
         //get success_page
         if ($form['success_page']) {
             $success_url = $this->html->getSecureURL($form['success_page']);
         } else {
             $success_url = $this->html->getSecureURL('content/contact/success');
         }
         //notify admin
         $this->loadLanguage('common/im');
         $message_arr = array(1 => array('message' => sprintf($this->language->get('im_customer_contact_admin_text'), $this->request->post['email'], $this->request->post['first_name'])));
         $this->im->send('customer_contact', $message_arr);
         $this->extensions->hk_ProcessData($this);
         $this->redirect($success_url);
     }
     if ($this->request->is_POST()) {
         foreach ($this->request->post as $name => $value) {
             $this->form->assign($name, $value);
         }
     }
     $this->document->resetBreadcrumbs();
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => false));
     $this->document->addBreadcrumb(array('href' => $this->html->getURL('content/contact'), 'text' => $this->language->get('heading_title'), 'separator' => $this->language->get('text_separator')));
     $this->view->assign('form_output', $this->form->getFormHtml());
     $this->view->assign('action', $this->html->getURL('content/contact'));
     $this->view->assign('store', $this->config->get('store_name'));
     $this->view->assign('address', nl2br($this->config->get('config_address')));
     $this->view->assign('telephone', $this->config->get('config_telephone'));
     $this->view->assign('fax', $this->config->get('config_fax'));
     $this->processTemplate('pages/content/contact.tpl');
     //init controller data
     $this->extensions->hk_UpdateData($this, __FUNCTION__);
 }