Advertisement
Guest User

код от zhmih

a guest
Jul 6th, 2016
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.80 KB | None | 0 0
  1. <?php
  2.  
  3. class shopZnauthPluginFrontendNregController extends waJsonController
  4. {
  5.     public function execute()
  6.     {
  7.              try {
  8.         $data = waRequest::post();
  9.         $model = new shopZncontactModel(); 
  10.         $cnt = str_split($data['passNumber']);
  11.        
  12.         $plugin_id = array('shop', 'znauth');
  13.         $app_settings_model = new waAppSettingsModel();
  14.         $settings = $app_settings_model->get($plugin_id);  
  15.        
  16.        
  17.         $mail_user = $data['email'];
  18.         $probnic_user = $data['shipping_id'];
  19.         $text = $data['vkus'][$probnic_user];
  20.                
  21.        
  22.        
  23.         if(count($cnt) < 6){
  24.            
  25.            
  26.             $this->response['result'] = 'countfalse';
  27.            
  28.            
  29.            
  30.         }else{
  31. /*----------------------------------------------------------------------------------------*/       
  32.         if($data['passNumber'] != $data['passCheck']){
  33.             $this->response['result'] = 'checkfalse';
  34.         }else{
  35.             $phone = preg_replace('#\D#u', '', $data['phoneNumber']);
  36.             $result = $model->query("select * from contact_newauth where phone='".$phone."' and code='".$data['codeNumber']."'")->fetchAll();
  37.             if($result){
  38.                 $this->response['result'] = 'codetrue';
  39.                 $model->query("delete from contact_newauth where phone='".$phone."'");
  40.                 $phone = preg_replace('#\D#u', '', $data['phoneNumber']);
  41.                 $password = md5($data['passNumber']);
  42.                 $model->query("insert into wa_contact (`name`,`firstname`,`password`,`phonen`,`create_datetime`,`create_app_id`,`create_method`) values('".$phone."','".$phone."','".$password."','".$phone."','".date('Y-m-d H:m:s')."','shop','signup')");
  43.                 $res = $model->query("select * from wa_contact where phonen='".$phone."' and password='".$password."'")->fetchALL();
  44.                 if($res){              
  45.                 $uid = $res[0]['id'];              
  46.                 $model->query("insert into wa_contact_data (`contact_id`,`field`,`value`) values('".$uid."','phone','".$phone."')");
  47.                 $model->query("insert into wa_contact_data (`contact_id`,`field`,`value`) values('".$uid."','create_ip','".$_SERVER['REMOTE_ADDR']."')");
  48.                 $model->query("insert into wa_contact_data (`contact_id`,`field`,`value`) values('".$uid."','create_user_agent','".$_SERVER['HTTP_USER_AGENT']."')");
  49.                 $model->query("insert into wa_log (`app_id`,`contact_id`,`datetime`,`action`,`params`) values('shop','".$uid."','".date('Y-m-d H:m:s')."','signup','frontend')");
  50.             $user_info = $res[0];
  51.             $auth = new waAuth;
  52.            
  53.            
  54.            
  55.  
  56.        
  57.  
  58.  
  59.        
  60.            
  61.            
  62.             if($auth->auth($user_info)){   
  63.  
  64. /*-----------------------------------------------------------------------------------------*/
  65.  
  66.        
  67.        
  68.        
  69.  
  70.  
  71.        
  72.        
  73.         if($settings[emeil] !== '' && $mail_user !== '' && $probnic_user > 0){
  74.         $sendto   = "".$settings[emeil]."";//'info@web-click.ru';
  75.         // Формирование заголовка письма
  76.         $subject  = "чайчайвыручай. Новый пользователь";
  77.         $headers  = "From: чайчайвыручай \r\n";
  78.         $headers .= "Reply-To: ". strip_tags($mail_user) . "\r\n";
  79.         $headers .= "MIME-Version: 1.0\r\n";
  80.         $headers .= "Content-Type: text/html;charset=utf-8 \r\n";
  81.        
  82.  
  83.         // Формирование тела письма
  84.         $msg  = "<html><body style='font-family:Arial,sans-serif;'>";
  85.         $msg .= "<h2 style='font-weight:bold;border-bottom:1px dotted #ccc;'>Новое сообщение</h2>\r\n";
  86.         $msg .= "<p><strong>E-mail:</strong> ".$mail_user."</p>\r\n";
  87.         $msg .= "<p><strong>Выбранный набор:</strong> №".$probnic_user." <b>".$text."</b></p>\r\n";
  88.         $msg .= "</body></html>";
  89.        
  90.         // Формирование заголовка письма для юзера
  91.         $subject_user  = "тема письма";
  92.         $headers_user  = "From: чайчайвыручай@msk3.imhoster.net\r\n";
  93.         $headers_user .= "Reply-To: чайчайвыручай@msk3.imhoster.net\r\n";
  94.         $headers_user .= "MIME-Version: 1.0\r\n";
  95.         $headers_user .= "Content-Type: text/html;charset=utf-8 \r\n";
  96.        
  97.         // Формирование инструкции
  98.         $msg_user  = "<html><body style='font-family:Arial,sans-serif;'>";
  99.         $msg_user .= "<h2 style='font-weight:bold;border-bottom:1px dotted #ccc;'>".$settings[inst1]."</h2>\r\n";
  100.         $msg_user .= "<p> ".$settings[inst2]."</p>\r\n";
  101.         $msg_user .= "</body></html>";
  102.        
  103.         // отправка сообщения
  104.        
  105.         @mail($sendto, $subject, $msg, $headers);
  106.         @mail($mail_user, $subject_user, $msg_user, $headers_user);
  107.         }
  108.        
  109.    
  110.  
  111.  
  112.                
  113. /*-----------------------------------------------------------------------------------------*/
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.            
  126.                     $this->response['result'] = 'success'; 
  127.             }
  128.                 }else{     
  129.                     $this->response['result'] = 'codefalse';
  130.                    
  131.                 }
  132.             }else{
  133.                 $this->response['result'] = 'codefalse';
  134.                
  135.             }          
  136.         }
  137.         }
  138. /*----------------------------------------------------------------------------------------*/       
  139.            } catch (Exception $e) {
  140.             $this->setError($e->getMessage());
  141.         }      
  142.     }
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement