Advertisement
Guest User

Untitled

a guest
Dec 15th, 2013
494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.64 KB | None | 0 0
  1. <?php
  2. error_reporting(0);
  3. class ControllerModuleFeedbackpro extends Controller {
  4.     private $error = array();
  5.     protected $ukeygen;
  6.     public function index() {
  7.         $this->id = 'feedback';
  8.         $this->document->addStyle('catalog/view/javascript/jquery/colorbox/colorbox.css');
  9.         $this->document->addScript('catalog/view/javascript/jquery/colorbox/jquery.colorbox.js');
  10.        
  11.     }
  12.     protected function ukeygen() {
  13.         $str = str_split(DIR_SYSTEM.':'.$_SERVER['SERVER_NAME']);
  14.         $ukey = '';
  15.         foreach ($str as $chr){
  16.             $ukey = md5($chr.$ukey.$chr.'fe');
  17.         }
  18.         return $ukey;
  19.     }
  20.     public function getform() {
  21.         $this->language->load('module/feedbackpro');
  22.  
  23.         $tukey = $this->config->get('config_ukey_fe');
  24.         $this->ukeygen();
  25.         if($tukey !== $this->ukeygen()) die('<div id="lcer">license error</div>');
  26.  
  27.         $this->data['text_required_inputs'] = $this->language->get('text_required_inputs');
  28.         $this->data['text_feedbackpro_sendform'] = $this->language->get('text_feedbackpro_sendform');
  29.  
  30.         if (!empty($this->request->get['id'])) {
  31.             $this->data['getid'] = $this->request->get['id'];
  32.             $feedback = $this->config->get('feedback_'.$this->request->get['id']);
  33.             $this->data['feedback'] = $feedback;
  34.         }
  35.  
  36.         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/feedbackpro.tpl')) {
  37.             $this->template = $this->config->get('config_template') . '/template/module/feedbackpro.tpl';
  38.         } else {
  39.             $this->template = 'default/template/module/feedbackpro.tpl';
  40.         }
  41.         if (!empty($_GET['ajax'])) {
  42.             $this->template = $this->config->get('config_template') . '/template/module/feedbackpro.tpl';
  43.         }
  44.         $this->response->setOutput($this->render());
  45.     }
  46.  
  47.     public function send() {
  48.  
  49.     $this->load->model('catalog/feedbackpro');
  50.     $this->language->load('module/feedbackpro');
  51.  
  52.     $this->data['text_feedbackpro_success'] = $this->language->get('text_feedbackpro_success');
  53.  
  54.     if (!empty($this->request->post['getid'])) {
  55.         $feedback = $this->config->get('feedback_'.$this->request->post['getid']);
  56.         $this->data['feedback'] = $feedback;
  57.     }
  58.    
  59.     $render = array();
  60.    
  61.     foreach($this->request->post['feedback'] as $key => $data) {
  62.         if (isset($feedback['filds'][$key]['fieldname'])) {
  63.             if ( (!empty($feedback['filds'][$key]['requaried']))&&(empty($data))) {
  64.                 $this->error[$key] = $feedback['filds'][$key]['fieldname'];
  65.             } else {
  66.                 $render[$feedback['filds'][$key]['fieldname']] = $data;
  67.             }
  68.         }
  69.     }
  70.  
  71.     $this->data['feedback']['filds'] = $render;
  72.  
  73.     $json = array();
  74.     $headers = array();
  75.    
  76.     $headers['referer'] = '<a href="'.$_SERVER["HTTP_REFERER"].'" target="_blank">'.$_SERVER["HTTP_REFERER"].'</a>';
  77.     $headers['ip'] = $_SERVER['REMOTE_ADDR'];
  78.    
  79.     $this->data['feedback']['filds']['info'] = $headers;
  80.     $this->data['feedback']['description'] = (!empty($this->request->post['feedback'][$feedback['main']]))?$this->request->post['feedback'][$feedback['main']]:'---';
  81.     $this->data['feedback']['name'] = $feedback['heading'];
  82.  
  83.         if(empty($this->error)) {
  84.  
  85.             $json['success'] = $this->data['text_feedbackpro_success'];
  86.  
  87.             $sendsemail = $this->data['feedback']['adminemail'];
  88.  
  89.             if (!empty($sendsemail)) {
  90.                 $ourmail = $this->data['feedback']['adminemail'];
  91.             } else {
  92.                 $ourmail = $this->config->get('config_email');
  93.             }
  94.  
  95.             $mail = new Mail();
  96.             $mail->protocol = $this->config->get('config_mail_protocol');
  97.             $mail->parameter = $this->config->get('config_mail_parameter');
  98.             $mail->hostname = $this->config->get('config_smtp_host');
  99.             $mail->username = $this->config->get('config_smtp_username');
  100.             $mail->password = $this->config->get('config_smtp_password');
  101.             $mail->port = $this->config->get('config_smtp_port');
  102.             $mail->timeout = $this->config->get('config_smtp_timeout');
  103.             $mail->setTo($ourmail);
  104.             $mail->setFrom(substr(preg_replace("#/$#", "", $this->config->get('config_url')), 7));
  105.             $mail->setSender(substr(preg_replace("#/$#", "", $this->config->get('config_url')), 7));
  106.             $mail->setSubject($feedback['heading']);
  107.                    
  108.             $feedbackresult = $this->data['feedback']['filds'];
  109.                    
  110.             array_pop($feedbackresult);
  111.                    
  112.             $polya = array();
  113.  
  114.             foreach ($feedbackresult as $key => $mailvalues) {
  115.                 $polya[] = $key.' : '. $mailvalues;
  116.             }
  117.  
  118.             $all = implode("\r\n", $polya);
  119.             $MailCom = $all;
  120.                    
  121.             $mail->setText(strip_tags(html_entity_decode($MailCom, ENT_QUOTES, 'UTF-8')));
  122.             $mail->send();
  123.  
  124.             $this->model_catalog_feedbackpro->addFeedbackpro($this->data['feedback']);
  125.  
  126.         } else {
  127.             $json['error'] = $this->error;
  128.         }
  129.  
  130.         $this->response->setOutput(json_encode($json));
  131.     }
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement