chengkun
2025-05-26 4462855c0033970c39ac8d0da704b7dc41eabbfe
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
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
<?php
 
class admin_member_controller extends siteadmin_controller{     
    private function set_search(){
        include(CONFIG_PATH.'db.data.php');
        $source         =  $arr_data['source'];
        $search_list[]  =  array('param'=>'source','name'=>'数据来源','value'=>$source);
        $search_list[]  =  array('param'=>'lotime','name'=>'最近登录','value'=>array('1'=>'今天','3'=>'最近三天','7'=>'最近七天','15'=>'最近半月','30'=>'最近一个月'));
        $search_list[]  =  array('param'=>'adtime','name'=>'最近注册','value'=>array('1'=>'今天','3'=>'最近三天','7'=>'最近七天','15'=>'最近半月','30'=>'最近一个月'));
        $search_list[]  =  array('param'=>'status','name'=>'审核状态','value'=>array('1'=>'已审核','2'=>'已锁定','3'=>'未通过','4'=>'未审核'));
        $this->yunset('source',$source);
        $this->yunset('search_list',$search_list);
    }
    function index_action(){
        $this->set_search();
        
        $userinfoM    =    $this->MODEL('userinfo');
        
        if($_GET['lotime']){
            if($_GET['lotime']=='1'){
                
                $where['login_date']    =    array('>',strtotime(date("Y-m-d 00:00:00")));
                
            }else{
                
                $where['login_date']    =    array('>',strtotime('-'.(int)$_GET['lotime'].'day'));
                
            }
            $urlarr['lotime']            =    $_GET['lotime'];
        }
        if($_GET['adtime']){
            if($_GET['adtime']=='1'){
                
                $where['reg_date']        =    array('>',strtotime(date("Y-m-d 00:00:00")));
                
            }else{
                
                $where['reg_date']        =    array('>',strtotime('-'.(int)$_GET['adtime'].'day'));
                
            }
            $urlarr['adtime']            =    $_GET['adtime'];
        }
        if($_GET['status']){
            
            $status                        =    intval($_GET['status']);
            
            $where['status']            =    $status == 4 ? 0 : $status;
            
            $urlarr['status']            =    $status;
        }
        if($_GET['source']){
            
            $where['source']            =    intval($_GET['source']);
            
            $urlarr['source']            =    $_GET['source'];
        }
        if(trim($_GET['keyword'])){
            if($_GET['type']==1){
                
                $where['username']        =    array('like',trim($_GET['keyword']));
                
            }elseif($_GET['type']==2){
                
                $where['moblie']        =    array('like',trim($_GET['keyword']));
                
            }elseif($_GET['type']==3){
                
                $where['uid']            =    array('like',trim($_GET['keyword']));
                
            }
            $urlarr['keyword']            =    $_GET['keyword'];
            
            $urlarr['type']                =    $_GET['type'];
        }
        if($_GET['order']){
            $where['orderby']            =    $_GET['t'].','.$_GET['order'];
            
            $urlarr['order']            =    $_GET['order'];
            
            $urlarr['t']                =    $_GET['t'];
        }else{
            
            $where['orderby']            =    array('uid,desc');
            
        }
        
        $urlarr['page']    =    '{{page}}';
        
        $pageurl        =    Url($_GET['m'],$urlarr,'admin');
        
        $pageM            =    $this  -> MODEL('page');
        
        $pages            =    $pageM -> pageList('member',$where,$pageurl,$_GET['page']);
        
        if($pages['total'] > 0){
            
            $where['limit']    =      $pages['limit'];
            
            $List            =    $userinfoM -> getList($where);
            
            $this -> yunset('rows',$List);
        }
        
        $this->siteadmin_tpl(array('admin_member'));
    }
    
    function edit_action(){
        $memberM    =    $this->MODEL('userinfo');
        
        $member        =    $memberM->getInfo(array('uid'=>$_GET['uid']),array('sf'=>'1'));    
        
        $this -> yunset('lasturl', 'index.php?m=admin_member');
        $this -> yunset('member', $member);
        $this -> siteadmin_tpl(array('admin_member_edit'));
    }
    
    function editSave_action(){
        $_POST      =  $this->post_trim($_POST);
        
        $memberM      =  $this -> MODEL('userinfo');
        
        if($_POST['submit']){
            $uData    =  array(
                'uid'          =>  intval($_POST['uid']),
                'usertype'  =>  intval($_POST['usertype']),
                'lasturl'   =>  $_POST['lasturl']
            );
            
            $mData  =  array(
                'username'  =>  $_POST['username'],
                'password'  =>  $_POST['password'],
                'moblie'    =>  $_POST['moblie'],
                'email'     =>  $_POST['email'],
                'reg_ip'    =>    $_POST['reg_ip'],
                'address'    =>    $_POST['address'],
                'status'    =>  $_POST['status']
            );
            
            $return       =      $memberM -> upMemberInfo($uData,$mData);
            
            $this->ACT_layer_msg($return['msg'], $return['errcode'], $return['url'], 2, 1);
            
        }
        
    }
    
    /**
     * 会员用户列表:获取锁定、审核未通过原因
     */
    function lockinfo_action(){
        
        $userinfoM  =  $this -> MODEL('userinfo');
        
        $member     =  $userinfoM -> getInfo(array('uid'=> $_GET['uid']),array('field'=>'lock_info'));
        
        echo trim($member['lock_info']);die;
    }
    
    /**
     * 会员用户列表:会员锁定
     */
    function lock_action(){
        
        $userinfoM  =  $this -> MODEL('userinfo');
        
        $post       =  array(
            'status'     =>  intval($_POST['status']),
            'lock_info'  =>  trim($_POST['lock_info'])
        );
        
        $return     =  $userinfoM -> lock(array('uid'=>intval($_POST['uid'])),array('post'=>$post));
        
        $this->ACT_layer_msg($return['msg'],$return['errcode'],$_SERVER['HTTP_REFERER'],2,1);
    }
    
    /**
     * 会员用户列表:会员审核
     */
    function status_action(){
        
        $userinfoM  =  $this -> MODEL('userinfo');
        
        $post       =  array(
            'status'     =>  intval($_POST['status']),
            'lock_info'  =>  trim($_POST['statusbody'])
        );
        
        $return     =  $userinfoM -> status(array('uid'=>intval($_POST['uid'])),array('post'=>$post));
        
        $this->ACT_layer_msg($return['msg'],$return['errcode'],$_SERVER['HTTP_REFERER'],2,1);
    }
    /**
     * 会员列表(页面统计数量)
     */
    function memNum_action(){
        
        $MsgNum    =    $this->MODEL('msgNum');
        
        echo $MsgNum->memNum();
    }
    
    /**
     * 会员列表(重置密码)
     */
    function reset_pw_action(){
        
        $this -> check_token();
        
        $userinfoM  =  $this->MODEL('userinfo');
        
        $userinfoM -> upInfo(array('uid'=>intval($_GET['uid'])),array('password'=>'123456'));
        
        $this -> MODEL('log') -> addAdminLog('会员(ID:'.$_GET['uid'].')重置密码成功');
        
        echo '1';
    }
    function del_action(){
        $this->check_token();
        
        $userinfoM    =    $this->MODEL('userinfo');
        
        if($_GET['del']){
            $del    =    $_GET['del'];
            
            $return    =    $userinfoM->delMember($del);
            
            $this->layer_msg( $return['msg'],$return['errcode'],$return['layertype'],$_SERVER['HTTP_REFERER']);
            
        }
    }
    function send_action(){ 
    
        $UserInfoM = $this->MODEL('userinfo');
 
        if($_POST['email_title']==''||$_POST['content']==''){
            $arr['msg']        =    "邮件标题均不能为空!";
            $arr['status']    =    2;
            echo json_encode($arr);die;
         } 
        
        $emailarr=$user=$com=$lt=$px=$userinfo=array();
         
        if($_POST['utype']!='5'){
            $userrows    =    $UserInfoM->getList(array('usertype'=>$_POST['utype']),array('field'=>'email,`uid`,`usertype`'));
        }else if($_POST['utype']=='5'){
            $email_user    =    @explode(',',$_POST['email_user']); 
            $email_user    =    array_filter($email_user);
            foreach($email_user as $v){
                if(CheckRegEmail($v)){
                    $earr[]=$v;
                }
            }
            if(!empty($earr)){
                $where['email']=array('in', "\"".@implode('","',$earr)."\"");
                $userrows    =    $UserInfoM->getList($where,array('field'=>'`email`,`uid`,`usertype`'));  
            }
        }
        if(is_array($userrows)&&$userrows){
            foreach($userrows as $v){
                
                if($v['usertype']=='1'){    $user[]    =    $v['uid'];}
                if($v['usertype']=='2'){    $com[]    =    $v['uid'];}
                if($v['usertype']=='3'){    $lt[]    =    $v['uid'];}
                if($v['usertype']=='4'){    $px[]    =    $v['uid'];}
                
                $emailarr[$v['uid']]=$v["email"];
            }
             
            if($user&&is_array($user)){
                $where['uid']    =    array('in',pylode(',',$user));
            }
            if($com&&is_array($com)){
                $where['uid']    =    array('in',pylode(',',$com));
            }
            if($lt&&is_array($lt)){
                $where['uid']    =    array('in',pylode(',',$lt));
            }
            if($px&&is_array($px)){
                $where['uid']    =    array('in',pylode(',',$px));
            }
            $List    =    $UserInfoM->getUserList($where);
            
            foreach($List as $v){
                $userinfo[$v['uid']]=$v['name'];
            }
        } 
            
        if(!count($emailarr)){ 
            $arr['msg']        =    "没有符合条件的邮箱,请先检查!";
            $arr['status']    =    2;
            echo json_encode($arr);die;
        }else{
            set_time_limit(10000);
 
            $pagesize    =    intval($_POST['pagelimit']);
            $sendok        =    intval($_POST['sendok']);
            $sendno        =    intval($_POST['sendno']?$_POST['sendno']:0);
            $value        =    intval($_POST['value']);
 
            //分批次发送
            $result        =    $this->send_email($emailarr,$_POST['email_title'],$_POST['content'],$userinfo,$pagesize,$sendok,$sendno,$value);
            
            if($result){
                $toSize = $pagesize * $result['page'];
 
                if(count($emailarr) > $toSize){
                    $npage    =    $result['page'];
                    $spage    =    $npage*$pagesize+1;
                    $topage    =    ($npage+1)*$pagesize;
                    $name    =    $spage."-".$topage;
                    
                    $this->get_return("3",$result['page'],"正在发送".$name."封邮件",$result['sendok'],$result['sendno']);
                 
                }else{
                    $this->get_return("1",$result['page'],"发送成功:".$result['sendok'].",失败:".$result['sendno']);
                 }
            }
        }
     }
 
    function send_email($email=array(),$emailtitle="",$emailcoment="",$userinfo=array(),$pagesize,$sendok,$sendno,$value){
        
        $notice = $this->MODEL('notice');
        $sendok = intval($sendok);
        $sendno = intval($sendno);
 
        if($value=='0'){
            $i = 1;
            foreach($email as $key => $v){
                    
                if($i <=$pagesize){
                    $emailData['email']        =    $v;
                    $emailData['subject']    =    $emailtitle;
                    $emailData['content']    =    stripslashes($emailcoment);
                    $emailData['uid']        =    $key;
                    $emailData['name']        =    $userinfo[$key];
                    $emailData['cname']        =    "系统";
                    if($v){
                        $sendid = $notice->sendEmail($emailData);
                    }
                    if($sendid['status'] != -1){
                        $state=1;
                        $sendok++;
                    }else{
                        $state=0;
                        $sendno++;
                    }
                }
                $i++;
            }
            $result['sendok']    =    $sendok;
            $result['sendno']    =    $sendno;
            $result['page']        =    1;
 
        }else{
            $page    =    $value;
            $start    =    $page*$pagesize;
            $end    =    ($page+1)*$pagesize;
 
            $i=1;
 
            foreach($email as $key=>$v){
 
                if($i > $start && $i <= $end){
                    
                    $emailData['email']        =    $v;
                    $emailData['subject']    =    $emailtitle;
                    $emailData['content']    =    stripslashes($emailcoment);
                    $emailData['uid']        =    $key;
                    $emailData['name']        =    $userinfo[$key]['name'];
                    $emailData['cname']        =    "系统";
                        
                    if($v){
                        $sendid = $notice->sendEmail($emailData);
                    }
                    if($sendid['status'] != -1){
                        $state=1;
                        $sendok++;
                    }else{
                        $state=0;
                        $sendno++;
                    }
                }
                $i++;
            }
 
            $page    =    $page + 1;
            $result['sendok']    =    $sendok;
            $result['sendno']    =    $sendno;
            $result['page']        =    $page;
             
        }
        return $result;
    }
    function msgsave_action(){
        
        $userinfoM    =    $this->MODEL('userinfo');
        
        if(!checkMsgOpen($this -> config)){
            $arr['msg']        =    "还没有配置短信!";
            $arr['status']    =    2;
            echo json_encode($arr);die;
        }
        if(trim($_POST['content'])==''){
            $arr['msg']        =    "请输入短信内容!";
            $arr['status']    =    2;
            echo json_encode($arr);die;
        }
        if($_POST['userarr']=='' && $_POST['utype']=='5'){
            $arr['msg']        =    "手机号码不能为空!";
            $arr['status']    =    2;
            echo json_encode($arr);die;
        }
        $uidarr=array();
        if($_POST['utype']==5){
            $mobliesarr    =    @explode(',',$_POST['userarr']);
            $userrows    =    $userinfoM->getList(array('moblie'=>array('in',$_POST['userarr'])),array('field'=>'`moblie`,`uid`,`usertype`'));         
            $moblies    =    array();
            foreach($userrows as $v){
                $moblies[]=$v['moblie'];
            }  
        }else{
            $userrows    =    $userinfoM->getList(array('usertype'=>$_POST['utype']),array('field'=>'`moblie`,`uid`,`usertype`'));
        }
 
        if(is_array($userrows)&&$userrows){
            $user=$com=$lt=$px=$userinfo=array();
            foreach($userrows as $v){
                
                if($v['usertype']=='1'){    $user[]    =    $v['uid'];}
                if($v['usertype']=='2'){    $com[]    =    $v['uid'];}
                if($v['usertype']=='3'){    $lt[]    =    $v['uid'];}
                if($v['usertype']=='4'){    $px[]    =    $v['uid'];}
                
                $uidarr[$v['uid']]    =    $v["moblie"];
            }
            if($user&&is_array($user)){
                $where['uid']    =    array('in',pylode(',',$user));
            }
            if($com&&is_array($com)){
                $where['uid']    =    array('in',pylode(',',$com));
            }
            if($lt&&is_array($lt)){
                $where['uid']    =    array('in',pylode(',',$lt));
            }
            if($px&&is_array($px)){
                $where['uid']    =    array('in',pylode(',',$px));
            }
            $List    =    $userinfoM->getUserList($where);
            
            foreach($List as $v){
                $userinfo[$v['uid']]=$v['name'];
            }
        }
        if($_POST['utype']==5){
            foreach($mobliesarr as $v){
                if(in_array($v,$moblies)==false&&CheckMobile($v)){
                    $uidarr[]=$v;
                }
            }
        }
 
        if(!count($uidarr)){ 
            $arr['msg']        =    "没有符合条件号码,请先检查!";
            $arr['status']    =    2;
            echo json_encode($arr);die;
        }else{
            set_time_limit(10000);
 
            $pagesize    =    intval($_POST['pagelimit']);
            $sendok        =    intval($_POST['sendok']);
            $sendno        =    intval($_POST['sendno']?$_POST['sendno']:0);
            $value        =    intval($_POST['value']);
 
            //分批次发送
            $result        =    $this->sendDivMsg($uidarr,$_POST['content'],$userinfo,$pagesize,$sendok,$sendno,$value);
            
            if($result){
                $toSize = $pagesize * $result['page'];
 
                if(count($uidarr) > $toSize){
                    $npage    =    $result['page'];
                    $spage    =    $npage*$pagesize+1;
                    $topage    =    ($npage+1)*$pagesize;
                    $name    =    $spage."-".$topage;
                    
                    $this->get_return("3",$result['page'],"正在发送".$name."条短信",$result['sendok'],$result['sendno']);
                }else{
                    $this->get_return("1",$result['page'],"发送成功:".$result['sendok'].",失败:".$result['sendno']);
                }
            }
            
             
        }
    }
 
    function sendDivMsg($uidarr=array(),$content="",$userinfo=array(),$pagesize,$sendok,$sendno,$value){
 
        $notice = $this->MODEL('notice');
        $sendok = intval($sendok);
        $sendno = intval($sendno);
       
        if($value=='0'){
            $i = 1;
            foreach($uidarr as $key => $v){
                    
                if($i <= $pagesize){
                    $msgData['mobile']    =    $v;
                     $msgData['content']    =    $content;
                    $msgData['uid']        =    $key;
                    $msgData['name']    =    $userinfo[$key];
                    $msgData['cname']    =    "系统";
                    
                    if($v){
                        $msgData['port']=    '5';
                        $sendid = $notice->sendSMS($msgData);
                     }
                    if($sendid['status'] != -1){
                        $sendok++;
                    }else{
                        $sendno++;
                    }
                }
                $i++;
            }
            $result['sendok']    =    $sendok;
            $result['sendno']    =    $sendno;
            $result['page']        =    1;
 
        }else{
            $page    =    $value;
            $start    =    $page*$pagesize;
            $end    =    ($page+1)*$pagesize;
 
            $i=1;
 
            foreach($uidarr as $key=>$v){
 
                if($i > $start && $i <= $end){
                    
                    $msgData['moblie']    =    $v;
                     $msgData['content'] =    $content;
                    $msgData['uid']        =    $key;
                     $msgData['name']    =    $userinfo[$key]['name'];
                    $msgData['cname']    =    "系统";
                        
                    if($v){
                        $msgData['port']=    '5';
                        $sendid = $notice->sendSMS($msgData);
                    }
                    if($sendid['status'] != -1){
                         $sendok++;
                    }else{
                         $sendno++;
                    }
                }
                $i++;
            }
 
            $page    =    $page + 1;
            $result['sendok']    =    $sendok;
            $result['sendno']    =    $sendno;
            $result['page']        =    $page;
             
        }
        return $result;
    }
    
    //Other
    function get_return($status,$value,$msg,$sendok,$sendno){
        $data['status']    =    $status;
        $data['value']    =    $value;
        $data['msg']    =    $msg;
        $data['sendok']    =    $sendok;    
        $data['sendno']    =    $sendno;
        echo json_encode($data);die;
    }
    function userchange_action(){
        $userinfoM            =            $this->MODEL('userinfo');
        $uid                =            $_POST['uid'];
        $where['uid']        =            $uid;
        $rows                =            $userinfoM->getInfo($where,array('field'=>'`uid`,`username`,`usertype`,`pid`'));
        if($rows['uid'] && $rows['username'] && $rows['usertype']>0){
            $userwhere['uid']            =            $_POST['uid'];
            $userwhere['pres_usertype']    =            $rows['usertype'];
            $userwhere['status']        =            0;
            $suser        =        $userinfoM->getUserChangeInfo($where,array('field'=>'`id`,`uid`,`pres_usertype`'));
            if($suser['id']>0){
                $this->ACT_layer_msg('当前存在转换会员申请,请确认',8,'index.php?m=admin_userchange&id='.$suser['id'].'',2,1);
            }else{
                if($rows['pid']>0){
                    $this->ACT_layer_msg('子账号不支持转换',8,$_SERVER['HTTP_REFERER'],2,1);
                }
                if($_POST['applyusertype']==""){
                    $this->ACT_layer_msg('请选择转换会员类型',8,$_SERVER['HTTP_REFERER'],2,1);
                }elseif($rows['usertype']==$_POST['applyusertype']){
                    $this->ACT_layer_msg('选择转换会员类型与当前会员类型一致,无须切换',8,$_SERVER['HTTP_REFERER'],2,1);
                }
                $data                        =            array(
                    'uid'                    =>            $rows['uid'],
                    'name'                    =>            $rows['username'],
                    'pres_usertype'            =>            $rows['usertype'],
                    'did'                    =>            $rows['did'],
                    'apply_usertype'        =>            $_POST['applyusertype'],
                    'apply_time'            =>            time(),
                    'lastupdate'            =>            time(),
                    'status'                =>            1,
                    'statusbody'            =>            $_POST['statusbody'],
                    'type'                    =>            2,
          'state'         =>      0,
                );
                $res                        =            $userinfoM->addUserChange($data);
                if($res){
                    $userinfoM->actUserchange($uid,$_POST['applyusertype'],1,$rows['moblie'],'5');
                    $this->ACT_layer_msg('转换会员类型成功',9,$_SERVER['HTTP_REFERER'],2,1);
                }else{
                    $this->ACT_layer_msg('转换会员类型失败',8,$_SERVER['HTTP_REFERER'],2,1);
                }
            }
        }else{
      if($rows['uid']){
        $this->ACT_layer_msg('当前会员用户没有相关类型,无须转换身份',8,$_SERVER['HTTP_REFERER'],2,1);
      }else{
        $this->ACT_layer_msg('会员数据不存在',8,$_SERVER['HTTP_REFERER'],2,1);
      }
            
        }
    
    }
}
?>