Advertisement
Guest User

Создание юзера

a guest
Jul 26th, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.12 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.                                  * @event signup
  66.                                  * @param waContact $contact
  67.                                  */
  68.                                 $contact = new waContact($uid);
  69.                                 wa()->event('signup', $contact);
  70.  
  71.                                 /*-----------------------------------------------------------------------------------------*/
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.                                 if($settings[emeil] !== '' && $mail_user !== '' && $probnic_user > 0){
  81.                                     $sendto   = "".$settings[emeil]."";//'info@web-click.ru';
  82.                                     // Формирование заголовка письма
  83.                                     $subject  = "чайчайвыручай. Новый пользователь";
  84.                                     $headers  = "From: чайчайвыручай \r\n";
  85.                                     $headers .= "Reply-To: ". strip_tags($mail_user) . "\r\n";
  86.                                     $headers .= "MIME-Version: 1.0\r\n";
  87.                                     $headers .= "Content-Type: text/html;charset=utf-8 \r\n";
  88.  
  89.  
  90.                                     // Формирование тела письма
  91.                                     $msg  = "<html><body style='font-family:Arial,sans-serif;'>";
  92.                                     $msg .= "<h2 style='font-weight:bold;border-bottom:1px dotted #ccc;'>Новое сообщение</h2>\r\n";
  93.                                     $msg .= "<p><strong>E-mail:</strong> ".$mail_user."</p>\r\n";
  94.                                     $msg .= "<p><strong>Выбранный набор:</strong> №".$probnic_user." <b>".$text."</b></p>\r\n";
  95.                                     $msg .= "</body></html>";
  96.  
  97.                                     // Формирование заголовка письма для юзера
  98.                                     $subject_user  = "тема письма";
  99.                                     $headers_user  = "From: чайчайвыручай@msk3.imhoster.net\r\n";
  100.                                     $headers_user .= "Reply-To: чайчайвыручай@msk3.imhoster.net\r\n";
  101.                                     $headers_user .= "MIME-Version: 1.0\r\n";
  102.                                     $headers_user .= "Content-Type: text/html;charset=utf-8 \r\n";
  103.  
  104.                                     // Формирование инструкции
  105.                                     $msg_user  = "<html><body style='font-family:Arial,sans-serif;'>";
  106.                                     $msg_user .= "<h2 style='font-weight:bold;border-bottom:1px dotted #ccc;'>".$settings[inst1]."</h2>\r\n";
  107.                                     $msg_user .= "<p> ".$settings[inst2]."</p>\r\n";
  108.                                     $msg_user .= "</body></html>";
  109.  
  110.                                     // отправка сообщения
  111.  
  112.                                     @mail($sendto, $subject, $msg, $headers);
  113.                                     @mail($mail_user, $subject_user, $msg_user, $headers_user);
  114.                                 }
  115.  
  116.  
  117.  
  118.  
  119.  
  120.                                 /*-----------------------------------------------------------------------------------------*/
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.                                 $this->response['result'] = 'success';
  134.                             }
  135.                         }else{
  136.                             $this->response['result'] = 'codefalse';
  137.  
  138.                         }
  139.                     }else{
  140.                         $this->response['result'] = 'codefalse';
  141.  
  142.                     }
  143.                 }
  144.             }
  145.             /*----------------------------------------------------------------------------------------*/
  146.         } catch (Exception $e) {
  147.             $this->setError($e->getMessage());
  148.         }
  149.     }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement