wangtengyu
2018-12-07 f459412e0dac4ed94106da043b4c6f8576bfe496
commit | author | age
e2b48d 1 <?php
B 2
3 /**
4  * 获取登录信息
5 */
6     define('IN_ECS', true);
7     require('includes/init.php');
8
9 if($_POST['acr'] == 'app')
10 {
11     if($_POST['act'] == 'reg')
12     {
13         $user= isset($_POST['user'])? $_POST['user'] : '';
14         $email= isset($_POST['email']) ? $_POST['email'] : '';
15         $sex= $_POST['sex'];
16         $pwd=md5($_POST['pwd']);
17         $reg_list = $_POST['reg_field'];//会员注册项
18     
19         $res_field = explode(',',$reg_list);//拆分数组
20         $reg_field = array_filter($res_field);//去除数组中的空值
21         $msn = '';
22         $qq = '';
23         $office_phone = '';
24         $home_phone = '';
25         $mobile_phone = '';
26         $extend_field_str = '';
27         if($reg_field)
28         {
29             foreach($reg_field as $value)
30             {
31                 $field = explode('@',$value);
32                 if($field['0'] == 1)
33                 {
34                     $msn = $field['1'];
35                 }
36                 if($field['0'] == 2)
37                 {
38                     $qq = $field['1'];
39                 }
40                 if($field['0'] == 3)
41                 {
42                     $office_phone = $field['1'];
43                 }
44                 if($field['0'] == 4)
45                 {
46                     $home_phone = $field['1'];
47                 }
48                 if($field['0'] == 5)
49                 {
50                     $mobile_phone = $field['1'];
51                 }
52                 if($field['0'] > 6)
53                 {
54                     //$extend_field_str .= " ('" . $_SESSION['user_id'] . "', '" . $field['0'] . "', '" . $field['1'] . "'),";
55                     $extend_field_str.= $field['0'].",".$field['1']."@";
56                 }
57             }
58         }
59         $result=array();
60         $row = $db -> getRow("SELECT * FROM ".$ecs->table('users')."  WHERE  `user_name`='$user'");
61         if(!empty($row)){
62             $result['code']=2;
63             $result['info']="该用户名已经存在";
64             print_r(json_encode($result));
65             exit();
66         }
67         $row = $db -> getRow("SELECT * FROM ".$ecs->table('users')."  WHERE  `email`='$email'");
68         if(!empty($row)){
69             $result['code']=3;
70             $result['info']="该邮箱已经存在";
71             print_r(json_encode($result));
72             exit();
73         }
74
75         $add = array(  
76             'user_name' => $user,
77             'email' => $email, 
78             'password' => $pwd, 
79             'reg_time' => gmtime(), 
80             'sex' => $sex,
81             //注册项
82             'msn' => $msn,
83             'qq' => $qq,
84             'office_phone' => $office_phone,
85             'home_phone' => $home_phone,
86             'mobile_phone' => $mobile_phone,
87             'froms' => 'app'
88         ); 
89         $set=$db->autoExecute($ecs->table('users'), $add, 'INSERT');
90         if($set){
91             /*注册赠送积分*/
92             $sql="SELECT value FROM ".$ecs->table('shop_config')." WHERE id='220'";
93             $shop_config=$db ->getRow($sql);
94             $shop_config_integral=intval($shop_config['value']);
95             if($shop_config_integral>0){
96                 $row = $db -> getRow("SELECT * FROM ".$ecs->table('users')."  WHERE  `user_name`='$user'");
97                 $uid=$row['user_id'];
98                 $user_log=array();
99                $user_log['user_id'] = $uid;
100                $user_log['user_money'] = '0.00';
101                $user_log['frozen_money'] = '0.00';
102                $user_log['rank_points'] ='0';
103                $user_log['pay_points'] = $shop_config_integral;
104                $user_log['change_desc'] = '注册赠送积分';
105                $user_log['change_type'] = '99';
106                $user_log['change_time'] = gmtime();
107                $db->autoExecute($ecs->table('account_log'), $user_log, 'INSERT');
108                $sql="UPDATE ".$ecs->table('users') . " SET `pay_points`=`pay_points`+$shop_config_integral WHERE `user_id`='$uid'";
109                 $db->query($sql);
110             }
111             if ($extend_field_str)      //插入注册扩展数据
112             {
113                 $extend_str = explode('@',$extend_field_str);//拆分数组
114                 $extend_field = array_filter($extend_str);//去除数组中的空值
115                 foreach($extend_field as $value)
116                 {
117                     $extend = explode(',',$value);
118                     $extend_list.=" (' $uid ', '" . $extend['0'] . "', '" . $extend['1'] . "'),";
119                 }
120                  $extend_list = substr($extend_list, 0, -1);
121                 $sql = 'INSERT INTO '. $ecs->table('reg_extend_info') . ' (`user_id`, `reg_field_id`, `content`) VALUES' . $extend_list;
122                 $db->query($sql);
123             }
124             
125             $row = $db -> getRow("SELECT * FROM ".$ecs->table('users')."  WHERE  `user_name`='$user'");
126             $result['code']=1;
127             $result['info']=$row;
128             print_r(json_encode($result));
129             exit();
130         }
131     }
132 }
133 else
134 {
135     $redirect_url =  "http://".$_SERVER["HTTP_HOST"].str_replace("user.php", "index.php");
136     header('Location: '.$redirect_url);
137 }
138 ?>