chengkun
2025-05-26 8f3df543230cd4403368b39b9bbe5726d11a0284
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
<?php
 
class index_controller extends common{
    function index_action(){
        if($this->uid!=""&&$this->username!=""){
            if($_GET['type']=="out"){       
                
                $this->cookie->unset_cookie();
                
            }else{
                $this->ACT_msg($this->config['sy_weburl']."/member", "您已经登录了!");
            }
        }
        if($_GET['backurl']=='1'){
            $this->cookie->setCookie("backurl",$_SERVER['HTTP_REFERER'],time()+60);
        }
        if(!$_GET['usertype']){
            $_GET['usertype']        =        1;
        }
        $this->yunset("cookie", $_COOKIE['checkurl']);                
        $this->yunset("usertype",(int)$_GET['usertype']);
        $this->yunset("loginname",$_COOKIE['loginname']);
        $this->yunset("referurl",$_SERVER['HTTP_REFERER']);
        $this->seo("login");
        $this->yun_tpl(array('index'));
    }
    //登录验证
    function loginsave_action(){
        
    
        $Member                    =            $this->MODEL('userinfo');
 
        $lData['username']        =            $_POST['username'];
        $lData['uid']            =            $this->uid;
        $lData['usertype']        =            $this->usertype;
        $lData['act_login']        =            $_POST['act_login'];
        $lData['num']            =            $_POST['num'];
        $lData['loginname']        =            $_POST['loginname'];
        $lData['password']        =            $_POST['password'];
        $lData['referurl']        =            $_POST['referurl'];
        $lData['authcode']        =            $_POST['authcode'];
        $lData['port']            =            1;
 
        $return                    =            $Member->userLogin($lData);
        
        if($return['uclogin']){
            $error    =    2;
            $return['msg'] = $return['uclogin'];
        }else{
            $error    =    1;
        }
        if($return['errcode']==2){
            $this->layer_msg($return['msg'],9,0,Url('register',array('c'=>'ident')),2,$error);
        }else if($return['url']){
            $this->layer_msg($return['msg'],9,0,$return['url'],2,$error);
        }else{
            $this->layer_msg($return['msg']);    
        }
        
    }
    //登录短信验证码发送
    function sendmsg_action()
    {
        $noticeM    =    $this->MODEL('notice');
        $result        =    $noticeM->jycheck($_POST['code'],'前台登录');
        if(!empty($result)){
            $this->layer_msg($result['msg'], 9, 0, '', 2, $result['error']);
        }
        $moblie        =    $_POST['moblie'];
        $UserinfoM    =    $this->MODEL('userinfo');
        $userinfo    =    $UserinfoM->getInfo(array("moblie" => $moblie),array('field'=>"`usertype`,`uid`"));
 
        if ($this->config['sy_reg_type'] == 2 && empty($userinfo)){
 
            $result =   array(
                'error' =>  2,
                'msg'   =>  '请先注册账号'
            );
        }else{
            $user = array(
                'uid'        =>    $userinfo['uid'],
                'usertype'     =>    $userinfo['usertype']
            );
 
            $result    =    $noticeM->sendCode($moblie, 'login', 1, $user, 6, 90, 'msg');
        }
 
        echo json_encode($result);exit();
    }
    function rest_action(){
        $this->cookie->unset_cookie();
        $url = Url("login",array("usertype"=>"1"),"1");
        header("Location: ".$url);
    }
    function utype_action(){
        if($this->uid){
            header("Location:".$this->config['sy_weburl']."/member");
        }
        $this->seo("login");
        $this->yun_tpl(array('utype'));
    }
 
    function setutype_action(){   
        //验证前期保存的登录数据,是否在本系统有存在并且密码对应
        if($_COOKIE['username'] && $_COOKIE['password'] && (CheckRegUser($_COOKIE['username']) OR CheckRegEmail($_COOKIE['username'])==false)){
            //无usertype情况下 才予以激活 否则直接登录会员中心
            $Member=$this->MODEL("userinfo");
            $user = $Member->getInfo(array("username"=>$_COOKIE['username']),array("field"=>"`uid`,`username`,`password`,`salt`,`usertype,did`"));
            
            $userid = $user['uid'];
            if(!$user['usertype']){
                if(passCheck($_COOKIE['password'],$user['salt'],$user['password']) && $user['password']!=''){
                    $usertype = (int)$_GET['usertype'];
                    if($usertype=='1'){
                        $table = "member_statis";
                        $table2 = "resume";
                        $data1=array("uid"=>$userid);
                        $data2['uid']=$userid;
                    }elseif($usertype=='2'){
                        
                        $table         =  "company_statis";
                        $table2        =  "company";
                        $ratingM       =  $this->MODEL('rating');
                        $data1         =  $ratingM->FetchRatingInfo();
                        $data2['uid']  =  $userid;
                        $data1['did']  =  $user['did'];
                        
                    }elseif($usertype=='3'){
                        $table = 'lt_statis';
                        $table2 = 'lt_info';
                        $id =$this->config['lt_rating'];
                        $row = $Member->GetRatinginfoOne(array('id'=>$id));
                        $data1=array('rating'=>$id,'integral'=>$this->config['integral_reg'],'rating_name'=>$row['name'],'rating_type'=>$row['type'],'lt_job_num'=>$row['lt_job_num'],'lt_down_resume'=>$row['lt_resume'],'lt_editjob_num'=>$row['lt_editjob_num'],'lt_breakjob_num'=>$row['lt_breakjob_num']);
                        if($row['service_time']>0){
                            $time=time()+86400*$row['service_time'];
                        }else{
                            $time=0;
                        }
                        $data1['vip_etime']=$time;
                        $data2['uid']=$userid;
                        $data2['did']=$user['did'];
 
                    }elseif($usertype=='4'){
                        $table = 'train_statis';
                        $table2 = 'px_train';
                        $data1=array('uid'=>$userid,'integral'=>$this->config['integral_reg']);
                        $data2['uid']=$userid;
                        $data2['did']=$user['did'];
                    }
                    $Member->upInfo(array(array("uid"=>$userid),"usertype"=>$usertype));
                    $Member->InsertReg($table,$data1);
                    $Member->InsertReg($table2,$data2);
                    $this->cookie->unset_cookie();
                    $this->cookie->add_cookie($userid,$user['username'],$user['salt'],$user['email'],$user['password'],$usertype,$this->config['sy_logintime'],$user['did']);
                    header("Location:".$this->config['sy_weburl'].'/member');
                }else{
                    $this->cookie->unset_cookie();
                    echo "激活失败";
                }
            }else{
                $this->cookie->unset_cookie();
                echo "激活失败";
            }
        }else{
            header("Location:".Url('index'));
        }
    }
 
    //微信登录
    function wxlogin_action()
    {
 
        $wxloginid  =   isset($_COOKIE['wxloginid']) ? $_COOKIE['wxloginid'] : '';
        $WxM        =   $this->MODEL('weixin');
        $qrcode     =   $WxM->applyWxQrcode($wxloginid, '', $this->uid);
        if (!$qrcode) {
            echo 0;
        } else {
            echo $qrcode;
        }
    }
 
    function getwxloginstatus_action()
    {
        if ($_COOKIE['wxloginid']) {
 
            $WxM    =   $this->MODEL('weixin');
            $result =   $WxM->getWxLoginStatus($_COOKIE['wxloginid'], $this->uid);
 
            if ($result['status'] == 1) {
                if (!empty($result['member'])) {
 
                    $user   =   $result['member'];
 
                    if ($user['usertype'] == 0) {
 
                        $this->cookie->unset_cookie();
                        $this->cookie->add_cookie($user['uid'], $user['username'], $user['salt'], $user['email'], $user['password'], '', $this->config['sy_logintime'], $user['did']);
                        $this->layer_msg('扫码成功', 9, 0, Url('register', array('c' => 'ident')));
                    } else {
 
                        if ($user['status'] == "2") {
                            $this->layer_msg('您的账号已被锁定', 9, 0, Url("register", array("c" => "ok", "type" => 2), "1"), 2);
                        }
                        $this->cookie->unset_cookie();
                        $this->cookie->add_cookie($user['uid'], $user['username'], $user['salt'], $user['email'], $user['password'], $user['usertype'], $this->config['sy_logintime'], $user['did']);
                        $this->layer_msg('', 9, 0, Url("member"));
                    }
                } else {
 
                    $this->layer_msg('扫码成功,请绑定已有账号或直接创建新账号', 9, 0, Url('wxconnect', array('bind' => 1, 'type' => 'ba')));
                }
            } else {
 
                $this->layer_msg('');
            }
        } else {
            $this->layer_msg('');
        }
    }
 
    /**
     * 第三方登录后,绑定已有账号,登录验证并绑定
     */
    function baloginsave_action(){
 
        $userinfoM    =  $this->MODEL('userinfo');
 
        if ($_POST['provider'] == 'weixin'){
            
            if(!empty($_COOKIE['wxloginid'])){
                
                $weixinM  =  $this->MODEL('weixin');
                $wxqrcode  =  $weixinM->getWxQrcode(array('wxloginid' => $_COOKIE['wxloginid'], 'status' => 1));
                
                if($wxqrcode['wxid'] || $wxqrcode['unionid']){
 
                    $lData['openid']    =    $wxqrcode['wxid'];
                    $lData['unionid']    =    $wxqrcode['unionid'];
                    $lData['username']    =    $_POST['username'];
                    $lData['uid']        =    $this->uid;
                    $lData['usertype']    =    $this->usertype;
                    $lData['source']    =    1;
                    $lData['password']    =    $_POST['password'];
                    $lData['authcode']    =    $_POST['authcode'];
                    
                    $return        =  $userinfoM->bindacount($lData,'weixin');
                }
            }else{
                $return['msg']        =    '微信登录信息已失效,请重新登录!';
            }
        }else if($_POST['provider'] == 'qq'){
 
            session_start();
            
            if($_SESSION['qq']['openid']){
                
                $lData  =  array(
                    'openid'       =>  $_SESSION['qq']['openid'],
                    'unionid'      =>  $_SESSION['qq']['unionid'],
                    'authcode'     =>  $_POST['authcode'],
                    'username'     =>  $_POST['username'],
                    'password'     =>  $_POST['password'],
                    'source'    =>  1,
                    'uid'        =>    $this->uid,
                    'usertype'    =>    $this->usertype
                );
                
                $return        =  $userinfoM->bindacount($lData,'qq');
            }else{
                $return['msg']        =    'qq登录信息已失效,请重新登录!';
            }
        }else if ($_POST['provider'] == 'sinaweibo'){
            
            session_start();
            
            if($_SESSION['sina']['openid']){
                
                $lData  =  array(
                    'openid'       =>  $_SESSION['sina']['openid'],
                    'authcode'     =>  $_POST['authcode'],
                    'username'     =>  $_POST['username'],
                    'password'     =>  $_POST['password'],
                    'source'    =>  1,
                    'uid'        =>    $this->uid,
                    'usertype'    =>    $this->usertype
                );
 
                $return        =  $userinfoM->bindacount($lData,'sinaweibo');
 
            }else{
                $return['msg']        =    '新浪微博登录信息已失效,请重新登录!';
            }
        }
 
        if($return['errcode']==2){
            $this->layer_msg($return['msg'],9,0,Url('register',array('c'=>'ident')),2,1);
        }else if($return['url']){
            $this->layer_msg($return['msg'],9,0,$return['url'],2,1);
        }else{
            $this->layer_msg($return['msg']);    
        }
    }
    function balogin_action(){
        
        if ($_POST['provider'] == 'weixin'){
            if($_COOKIE['wxloginid']){
                
                $weixinM  =  $this->MODEL('weixin');
                $qrcode   =  $weixinM->getWxQrcode(array('wxloginid' => $_COOKIE['wxloginid'], 'status' => 1));
                
                $wdata  =  array(
                    'openid'   =>  $qrcode['wxid'],
                    'unionid'  =>  $qrcode['unionid'],
                    'source'   =>  9
                );
                
                $userinfoM  =  $this->MODEL('userinfo');
                $result     =  $userinfoM->fastReg($wdata, '', 'weixin');
                
                if ($result['errcode'] == 9){
                    
                    $this->layer_msg('创建成功',9,0, Url('register',array('c'=>'ident')));
                    
                }else{
                    $this->layer_msg('账号注册失败',8,0);
                }
 
            }else{
                $this->layer_msg('请扫描微信二维码',9,0, Url('wxconnect'));
            }
        }else if($_POST['provider'] == 'qq'){
            session_start();
            
            if($_SESSION['qq']['openid']){
                
                // 未设置实名注册,QQ未绑定账号的,直接注册账号
                $wdata  =  array(
                    'openid'   =>  $_SESSION['qq']['openid'],
                    'unionid'  =>  $_SESSION['qq']['unionid'],
                    'source'   =>  8
                );
                
                $userinfoM  =  $this->MODEL('userinfo');
                $result     =  $userinfoM->fastReg($wdata, '', 'qq');
                
                if ($result['errcode'] == 9){
                    
                    $this->layer_msg('创建成功',9,0, Url('register',array('c'=>'ident')));
                    
                }else{
                    $this->layer_msg('账号注册失败',8,0);
                }
            }else{
                $this->layer_msg('qq登录信息已失效,请重新登录!',8,0);
            }
        }else if($_POST['provider'] == 'sinaweibo'){
            session_start();
            
            if($_SESSION['sina']['openid']){
                
                // 未设置实名注册,微博未绑定账号的,直接注册账号
                $wdata  =  array(
                    'openid'   =>  $_SESSION['sina']['openid'],
                    'source'   =>  10
                );
                
                $userinfoM  =  $this->MODEL('userinfo');
                $result     =  $userinfoM->fastReg($wdata, '', 'sinaweibo');
                
                if ($result['errcode'] == 9){
                    
                    $this->layer_msg('创建成功',9,0, Url('register',array('c'=>'ident')));
                    
                }else{
                    
                    $this->layer_msg('账号注册失败',8,0);
                }
            }else{
                $this->layer_msg('新浪微博登录信息已失效,请重新登录!',8,0);
            }
        }
    }
    /**
     * 微信扫码后,后台设置实名验证,需绑定手机号后再自动注册账号
     */
    function fastregsave_action(){
        
        if ($_POST['provider'] == 'weixin'){
            
            if(!empty($_COOKIE['wxloginid'])){
                
                $weixinM  =  $this->MODEL('weixin');
                $wxqrcode  =  $weixinM->getWxQrcode(array('wxloginid' => $_COOKIE['wxloginid'], 'status' => 1));
                
                if($wxqrcode['wxid'] || $wxqrcode['unionid']){
                    
                    $data  =  array(
                        'openid'       =>  $wxqrcode['wxid'],
                        'unionid'      =>  $wxqrcode['unionid'],
                        'source'       =>  9,
                        'moblie'       =>  $_POST['moblie'],
                        'moblie_code'  =>  $_POST['moblie_code'],
                        'code'         =>  $_POST['authcode'],
                        'port'         =>  1
                    );
                    $userinfoM    =  $this->MODEL('userinfo');
                    $return        =  $userinfoM->fastReg($data, '', 'weixin');
                }
            }else{
                $return['msg']        =    '微信登录信息已失效,请重新登录!';
            }
        }
        if ($_POST['provider'] == 'qq'){
            
            session_start();
            
            if($_SESSION['qq']['openid']){
                
                $data  =  array(
                    'openid'       =>  $_SESSION['qq']['openid'],
                    'unionid'      =>  $_SESSION['qq']['unionid'],
                    'source'       =>  8,
                    'moblie'       =>  $_POST['moblie'],
                    'moblie_code'  =>  $_POST['moblie_code'],
                    'code'         =>  $_POST['authcode'],
                    'port'         =>  1
                );
                $userinfoM    =  $this->MODEL('userinfo');
                $return        =  $userinfoM->fastReg($data, '', 'qq');
            }else{
                $return['msg']        =    'QQ登录信息已失效,请重新登录!';      
            }
        }
        if ($_POST['provider'] == 'sinaweibo'){
            
            session_start();
            
            if($_SESSION['sina']['openid']){
                
                $data  =  array(
                    'openid'       =>  $_SESSION['sina']['openid'],
                    'source'       =>  10,
                    'moblie'       =>  $_POST['moblie'],
                    'moblie_code'  =>  $_POST['moblie_code'],
                    'code'         =>  $_POST['authcode'],
                    'port'         =>  1
                );
                $userinfoM    =  $this->MODEL('userinfo');
                $return        =  $userinfoM->fastReg($data, '', 'sinaweibo');
            }else{
                $return['msg']        =    '新浪微博登录信息已失效,请重新登录!';
            }
        }
        if($return['errcode']==9){
            $arr['status']    =    9;
            $arr['msg']        =    $return['msg'];
            $arr['url']        =    Url('register',array('c' => 'ident'));
        }else{
            $arr['msg']        =    $return['msg'];
            $arr['status']    =    8;
        }
        echo json_encode($arr);die;
    }
}