chengkun
2025-05-22 1a8aea45ebb1582c9f65d9e8dcd520002f83ae12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
<?php
 
class set_controller extends user_controller
{
    //个人设置信息页面
    function getInfo_action()
    {
        
        $resumeM    =  $this->MODEL('resume');
        $resume        =    $resumeM->getResumeInfo(array('uid'=>$this->member['uid']),array('logo'=>1,'setname'=>1,'field'=>'`name`,`exp`,`edu`,`birthday`,`status`,`sex`,`telphone`,`moblie_status`,`email`,`email_status`,`idcard_pic`,`idcard_status`,`photo`,`def_job`'));
 
 
        if(empty($resume['name'])){
            
            $resume['name']    =    $this->member['username'];
        }
        
        $data  =  array_merge($this->member,$resume);
        
        $data['cuswitch']   =    $this->config['sy_user_change'];
        $data['iosfk']        =    $this->config['sy_iospay'] ;
        $data['sy_lietou_web']   = $this->config['sy_lietou_web'];
        $data['sy_train_web']   = $this->config['sy_train_web'];
        $data['xcx_contact']  =  $this->config['sy_xcx_contact'] ? $this->config['sy_xcx_contact'] : 2;
        $data['app_push']   =  $this->member['app_push'];
        
        if (isset($_POST['provider']) && ($_POST['provider'] == 'weixin' || $_POST['provider'] == 'baidu')) {
            // 小程序关联登录入口判断
            if ($_POST['provider'] == 'weixin'){
                @include(DATA_PATH.'api/wxpay/wxpay_data.php');
                if (isset($wxpaydata)){
                    if($wxpaydata['sy_xcxappid'] == '' || $wxpaydata['sy_xcxsecret'] ==''){
                        $data['isWxopen'] = false;
                    }else{
                        $data['isWxopen'] = true;
                    }
                }
            }
            if($_POST['provider'] == 'baidu'){
                @include(DATA_PATH . 'api/baidu/baidu_data.php');
                if (isset($baiduData)) {
                    if($baiduData['sy_bdlogin_appKey'] == '' || $baiduData['sy_bdlogin_appSecret'] == ''){
                        $data['isBdopen'] = false;
                    }else{
                        $data['isBdopen'] = true;
                    }
                }
            }
        }
        
        $this -> render_json(0, 'ok', $data);
    }
    //查询用户是否有多重身份
    function transferInfo_action(){
        $userInfo   = $this->MODEL('userinfo');
        $userStatue = $userInfo -> getUserInfo(array('uid'=>$this->member['uid']),array('usertype'=>2));
        $userStat   = $userInfo -> getUserInfo(array('uid'=>$this->member['uid']),array('usertype'=>3));
        $userSta    = $userInfo -> getUserInfo(array('uid'=>$this->member['uid']),array('usertype'=>4));
        $this->yunset('userStatue',$userStatue);
        $this->yunset('userStat',$userStat);
        $this->yunset('userSta',$userSta);
 
        $data['userStatue']   = $userStatue;
        $data['userStat']   = $userStat;
        $data['userSta']   = $userSta;
        $data['config']    =    array(
            'reg_namemaxlen'         =>  $this->config['sy_reg_namemaxlen'],
            'reg_nameminlen'        =>  $this->config['sy_reg_nameminlen'],
               'reg_name_sp'            =>  $this->config['reg_name_sp'],
            'reg_name_zm'            =>  $this->config['reg_name_zm'],
            'reg_name_num'           =>  $this->config['reg_name_num'],
            'reg_name_han'           =>  $this->config['reg_name_han'],
 
            'reg_pw_sp'                =>  $this->config['reg_pw_sp'],
            'reg_pw_zm'                =>  $this->config['reg_pw_zm'],
            'reg_pw_num'               =>  $this->config['reg_pw_num'],
        );
        $this -> render_json(0, 'ok', $data);
    }
    //身份证审核查询
    function getidcard_action(){
        
        $ResumeM    =    $this        ->    MODEL('resume');
        $resume        =    $ResumeM    ->    getResumeInfo(array('uid'=>$this->member['uid']),array('logo'=>1));
        
        $return     =    array(
            'statusbody'            =>    $resume['statusbody'],
            'url'            =>    $resume['idcard_pic'],
            'idcard'        =>    $resume['idcard'],
            'status'        =>    $resume['idcard_status'],
            'file_maxsize'    =>    $this->config['file_maxsize'],
            'pic_type'    =>    $this->config['pic_type']
        );
        $this -> render_json(1, 'ok', $return);
    }
    //上传身份证
    function saveidcard_action()
    {
        $UserinfoM    =    $this -> MODEL('userinfo');
        
        $upResumeData    =    array(
            'name'        =>    $resume['name'],
            
            'idcard'    =>    $_POST['idcard'],
            
            'uid'        =>    $this->member['uid'],
            
            'usertype'    =>    '1',
            'preview'   =>  $_POST['preview'],
            'file'        =>  $_FILES['photos']
        );
        
        $return        =    $UserinfoM -> upidcardInfo(array('uid'=>$this->member['uid']),$upResumeData);
        $error        =    $return['errcode']==9 ? 1 : 2;
        $this -> render_json($error, $return['msg']);
    }
    //手机认证,发送短信;
    function mobliecert_action(){
        $noticeM    =    $this -> MODEL('notice');    
        $logM        =    $this -> MODEL('log');
        if($_POST['type']=='wap') {
 
            $result = $noticeM->jycheck($_POST['code'], '');
            if (!empty($result)) {
                $this->render_json($result['error'], "图片验证码错误");
            }
        }
        $moblie     =    $_POST['moblie'];
     //判断手机号码是否存在
        $UserinfoM         =   $this->MODEL('userinfo');
        $where['uid']      =   array('<>',$this->member['uid']);
        $where['moblie']   =   $_POST['moblie'];
        $Info              =  $UserinfoM->getInfo($where);
        if(!checkMsgOpen($this -> config)){
            $this->render_json(10,'没有配置短信,请联系管理员');
        }elseif($this->config['sy_msg_cert']=="2"){
            $this->render_json(10,'短信通知已关闭,请联系管理员');
        }elseif($Info){
            $this->render_json(10,'手机号码已存在,请重新填写新号码');
        }else{
             $moblie =    $_POST['moblie'];
             $msgM    =    $this->MODEL('mobliemsg');
             $num    =    $msgM->getNum(array('moblie'=>$moblie,'ctime'=>array('>',strtotime('today'))));
             if($num>=$this->config['moblie_msgnum']){
                $this->render_json(12,'同一手机号一天发送次数已超');
             }
             $ip        =    fun_ip_get();
             $ipnum    =    $msgM->getNum(array('ip'=>$ip,'ctime'=>array('>',strtotime('today'))));
            if($ipnum>=$this->config['ip_msgnum']){
                $this->render_json(13,'同一ip一天发送次数已超',13);
            }
            $user         =    array(
                'uid'      => $this->member['uid'],
                'usertype' => '1'
            );
            $port    =    $this->plat == 'mini' ? '3' : '4';    // 短信发送端口$port : 3-小程序  4-APP
            $result =    $noticeM->sendCode($moblie, 'cert', $port, $user);
            $logM -> addMemberLog($user['uid'], $user['usertype'], '手机认证验证码,认证手机号:'.$moblie, 13, 1);
            $this -> render_json(0, 'ok', $result);
        }
    }
    //修改密码
    function pwd_action()
    {
        $UserinfoM  =   $this->MODEL('userinfo');
        $data       =   array(
            
            'uid'           =>  $this->member['uid'],
            'usertype'      =>  '1',
            'oldpassword'   =>  $_POST['oldpwd'],
            'password'      =>  $_POST['newpwd'],
            'repassword'    =>  $_POST['confirmpwd']
            
        );
        $err            =   $UserinfoM -> savePassword($data);
    
        $data['error']    =    $err['errcode']==9 ? 1 : 2;
        
        $this -> render_json($data['error'], $err['msg']);
        
    }
    //手机号和邮箱绑定
    function bindingbox_action()
    {
        if($_POST['id']=='tel'){
            
            $CompanyM             =       $this -> MODEL('company');
          
            $UserinfoM           =       $this->MODEL('userinfo');
          
              $moblie              =        $_POST['moblie'];
          
              $uid                  =       $this->member['uid'];
          
            $where['uid']          =       array('<>',$uid);
              
              $where['moblie']       =       $moblie;
          
              $Info                  =          $UserinfoM->getInfo($where);
              if($Info){
 
                $error            =        2;
 
                $msg            =        '手机号码已存在,请重新填写新号码';
                   
              }else{
 
                $data  =  array(
                    
                    'uid'        =>  $this->member['uid'],
                    'usertype'  =>  '1',
                    'moblie'    =>  $_POST['moblie'],
                    
                );
                $res  =  array();
                $user    =  $UserinfoM->getInfo(array('uid'=>$uid),array('field'=>'username,moblie,password,salt,usertype'));
                if (isset($_POST['provider']) && $user['username'] == $user['moblie']){
                    // 用户名和手机号重复,修改手机号会修改用户名,需要重新生成token;
                    $token  =  md5($data['moblie'].$user['password'].$user['salt'].$user['usertype']);
                    $res['user']  =  array('uid'=>$uid,'usertype'=>$user['usertype'],'token'=>$token);
                }
                $return        =      $CompanyM -> upCertInfo(array('uid'=>$this->member['uid'],'check2'=>$_POST['code']),array('status'=>'1'), $data); 
    
                if($return==4){
                    $error        =        2;
                    $msg        =        '验证码时间已过期,请重新获取验证码';
                }elseif($return ==3){
                    $error        =        2;
                    $msg        =        '验证码错误';
                }elseif($return ==2){
                    $error        =        2;
                    $msg        =        '验证码不存在,请获取验证码';
                }elseif($return==1){
                    $error        =        1;
                }else{
                    $error        =        2;
                    $msg        =        '绑定失败';
                } 
            }
          
        }elseif ($_POST['id']=='email'){
 
            $ComapnyM    =    $this->MODEL('company');
            //判断邮箱是否存在
            $UserinfoM           =       $this->MODEL('userinfo');
          
              $email              =        $_POST['email'];
          
              $uid                  =       $this->member['uid'];
          
            $where['uid']          =       array('<>',$uid);
              
              $where['email']       =       $email;
          
            $Info                  =          $UserinfoM->getInfo($where);
            $noticeM    =    $this -> MODEL('notice');
 
            if($_POST['type']=='wap') {
 
                $result = $noticeM->jycheck($_POST['code'], '');
                if (!empty($result)) {
                    $this->render_json($result['error'], "图片验证码错误");
                }
            }
              if($Info){
                $error            =        2;
                $msg            =        '邮箱已存在,请重新填写邮箱';
              }else{
 
                $data          =   array(
                        
                    'usertype'     =>  '1',
                    
                    'email'        =>     $_POST['email']
                    
                );
                $return            =   $ComapnyM -> sendCertEmail(array('uid'=>$this->member['uid'], 'type'=>'1'), $data);
                if($return  == 3){
 
                    $error            =        2;
                    $msg            =        '邮件没有配置,请联系管理员!';
                }elseif($return ==2){
 
                    $error            =        2;
                    $msg            =        '邮件通知已关闭,请联系管理员';
                }elseif($return ==1){
                    $error            =        1;
                }else{
                
                    $error            =        2;
                    $msg            =        '操作错误';
                }
            
            }
 
        }
        
        $this -> render_json($error,$msg,$res);
        
    }
    //修改用户名
    function setname_action(){
        $UserinfoM    =    $this->MODEL('userinfo');
        $data    =    array(
            'username'    =>  trim($_POST['username']),
            'password'    =>  trim($_POST['password']),
            'uid'        =>  $this->member['uid'],
            'usertype'    =>  1,
            'restname'    =>  '1'
        );
        if (!empty($data['username'])) {
            $return =    $UserinfoM->saveUserName($data);
            
            if($return['errcode'] == '1'){
                $error    =    1;
            }else{
                $error    =    2;
                $msg    =    $return['msg'];
            }
        }else{
            $error    =    2;
            $msg    =    '修改失败';
        }
        
        $this -> render_json($error, $msg);
        
    }
    //账户分离
    function transfer_action(){
    
        
        if($_POST['bdtypes']){
            $_POST['bdtype'] = explode(',',$_POST['bdtypes']);
        }
        $transferM    =    $this -> MODEL('transfer');
        
        $return        =    $transferM -> setTransfer($this->member['uid'],$_POST);
        
        
        $this -> render_json($return['errcode'], $return['msg']);
    }
    //社交账号绑定页面
    function getBind_action(){
        
        $userInfoM  =  $this->MODEL('userinfo');
        $member     =  $userInfoM->getInfo(array('uid'=>$this->member['uid']),array('field'=>'`qqid`,`bdopenid`,`qqunionid`,`wxid`,`wxopenid`,`unionid`,`app_wxid`,`sinaid`,`maguid`,`qfyuid`'));
        
        $return  =  array(
            'qqbind'    =>  0,
            'wxbind'    =>  0,
            'sinabind'  =>  0,
            'magbind'   =>  0,
            'qfybind'   =>  0,
            'bdbind'    =>  0,
        );
        if (isset($this->config['sy_qqdt']) && $this->config['sy_qqdt'] == 1 && !empty($member['qqunionid'])){
            $return['qqbind']  =  1;
        }elseif (!empty($member['qqid'])){
            $return['qqbind']  =  1;
        }
        if ($_POST['provider'] == 'app'){
            if (!empty($member['app_wxid']) || !empty($member['unionid'])){
                $return['wxbind']  =  1;
            }else{
                if (!empty($member['wxid'])){
                    $return['wxbind']  =  2;
                }
            }
        }elseif ($_POST['provider'] == 'h5'){
            if (!empty($member['wxid']) || !empty($member['unionid'])){
                $return['wxbind']  =  1;
            }else{
                if (!empty($member['wxopenid']) || !empty($member['app_wxid'])){
                    $return['wxbind']  =  2;
                }
            }
        }else{
            if (!empty($member['wxopenid']) || !empty($member['unionid'])){
                $return['wxbind']  =  1;
            }else{
                if (!empty($member['wxid']) || !empty($member['app_wxid'])){
                    $return['wxbind']  =  2;
                }
            }
        }
        if (!empty($member['sinaid'])){
            $return['sinabind']  =  1;
        }
        if (!empty($member['maguid'])){
            $return['magbind']  =  1;
        }
        if (!empty($member['qfyuid'])){
            $return['qfybind']  =  1;
        }
        if (!empty($member['bdopenid'])){
            $return['bdbind'] = 1;
        }
        $this->render_json(0, 'ok', $return);
    }
    //保存社交账号绑定
    function binding_action()
    {
        if ($_POST['isbind'] == 1){
            
            $uni = 'wxapp';
            if (isset($_POST['provider'])){
                if ($_POST['provider'] == 'weixin'){
                    $uni = '微信小程序';
                }elseif ($_POST['provider'] == 'app'){
                    $uni = 'APP/微信';
                }elseif ($_POST['provider'] == 'h5'){
                    $uni = 'H5/微信';
                }
            }
            if ($_POST['type'] == 'qq'){
                
                $uni =  'APP/QQ';
                
            }elseif ($_POST['type'] == 'sinaweibo'){
                
                $uni =  'APP/weibo';
            }elseif ($_POST['type'] == 'mag'){
                
                $uni =  '马甲APP';
            }elseif ($_POST['type'] == 'qfy'){
                
                $uni =  '千帆云APP';
            }elseif ($_POST['type'] == 'baidu'){
                $uni = '百度小程序';
            }
            $comM      =   $this -> MODEL('company');
            $comM -> delBd($this->member['uid'], array('type'=>$_POST['type'], 'usertype'=>$this->member['usertype']));
            
            $logM  =  $this->Model('log');
            $logM->addMemberLog($this->member['uid'],$this->member['usertype'], $uni.'解除绑定');
            
            $this->render_json(0, 'ok');
            
        }else{
            
            $bdData['uid']     =  $this->member['uid'];
            $bdData['type']    =  $_POST['type'];
            $bdData['openid']  =  $_POST['openid'];
            $bdData['provider']=  $_POST['provider'];
            if (!empty($_POST['unionid'])){
                
                $bdData['unionid']    = $_POST['unionid'];
            }
            
            if ($_POST['type'] == 'weixin' && !empty($_POST['code'])){
                
                $getdata  =  $this->getOpenid($_POST['code']);
                if (isset($getdata['errcode'])){
                    $this->MODEL('errlog')->addErrorLog($this->member['uid'], 10, '微信小程序绑定获取openid错误。code:'.$_POST['code'].'。'.$getdata['errcode'].','.$getdata['errmsg']);
                    $this->render_json($getdata['errcode'],$getdata['errmsg']);
                }
                $bdData['openid']  =  $getdata['openid'];
                if (!empty($getdata['unionid'])){
                    
                    $bdData['unionid']    =    $getdata['unionid'];
                }
            }elseif ($_POST['type']=='baidu' && !empty($_POST['code'])){
                $getdata  =  $this->getBdOpenid($_POST['code']);
                if (isset($getdata['errno'])){
                    $this->MODEL('errlog')->addErrorLog('', 10, '百度小程序登录获取openid错误。code:'.$_POST['code'].'。'.$getdata['error'].','.$getdata['error']);
                    $this->render_json($getdata['errno'],$getdata['error']);
                }
                $bdData['openid']  =  $getdata['openid'];
            }
            $userInfoM  =  $this->MODEL('userinfo');
            $return     =  $userInfoM->loginBind($bdData);
            $this->render_json($return['error'],$return['msg']);
        }
    }
    // 查询申请注销记录
    function getLogout_action()
    {
        $logoutM  =  $this->MODEL('logout');
        $row      =  $logoutM->getInfo(array('uid'=>$this->member['uid']));
        
        if (!empty($row)){
            
            $this->render_json(1,'您已申请了注销账号');
        }else{
 
            $this->render_json(0,'ok');
        }
    }
    //注销账号申请
    public function logoutApply_action()
    {
        $_POST  =   $this->post_trim($_POST);
 
        $p      =   array(
            'password'  =>  $_POST['password']
        );
 
        $logoutM=   $this->MODEL('logout');
        $return =   $logoutM->apply(array('uid' => $this->member['uid']), $p);
 
        if ($return['errcode'] == 9) {
 
            $this->render_json(0, 'ok');
        } else {
 
            $this->render_json($return['errcode'], $return['msg']);
        }
    }
    // 开启、关闭app推送
    function pushSet_action()
    {
 
        $UserinfoM  =   $this->MODEL('userinfo');
        $UserinfoM->upInfo(array('uid' => $this->member['uid']), array('app_push' => $_POST['app_push']));
        $this->render_json(0, 'ok');
    }
}