Advertisement
Guest User

Untitled

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