assign('keyword',$keyword); } if($is_admin==0){ $condition['admin_id']=0; }elseif($is_admin==1){ $condition['admin_id']=array('GT',0); } if($is_auth!=2){ $Model = M(); $sql = "select a.user_id from ((select user_id from `t_choice` where choice_status=3 and choice_type=2) union all (select user_id from `t_course` where course_status=3)) as a group by a.user_id"; $list = $Model->query($sql); $ids=array(); foreach($list as $k=>$v){ $ids[]=$v['user_id']; } if($is_auth==0){ $condition['user_id']=array('not in',$ids); }elseif($is_auth==1){ $condition['user_id']=array('in',$ids); } } $this->assign('is_admin',$is_admin); $this->assign('is_auth',$is_auth); $count = M('User')->where($condition)->count(); //分页 $Page = new \Think\Page($count); $show = $Page->show(); $userList = M('User')->where($condition)->field()->order('user_id desc')->limit($Page->firstRow.','.$Page->listRows)->select(); //获取用户等级 $levelRes = M('UserLevel')->field('level_id,level_name')->select(); $levelList = array(); foreach ($levelRes as $level){ $levelList[$level['level_id']] = $level['level_name']; } foreach($userList as $k=>$v){ if($v['forbidden']-time()>0){ $userList[$k]['is_forbidden']=1; $time=$v['forbidden']-time(); $d = floor($time / (3600*24)); $h = floor(($time % (3600*24)) / 3600); $m = floor((($time % (3600*24)) % 3600) / 60); $tmp=''; if($d>'0'){ $tmp=$d.'天'.$h.'小时'.$m.'分'; }else{ if($h!='0'){ $tmp=$h.'小时'.$m.'分'; }else{ $tmp=$m.'分'; } } $userList[$k]['str_forbidden']=$tmp; $userList[$k]['is_forbidden']=1; }else{ $userList[$k]['str_forbidden']=''; $userList[$k]['is_forbidden']=0; } } $this->assign('page',$show); $this->assign('list',$userList); $this->assign('levelList',$levelList); $this->display(); } //用户详细信息 public function detail(){ $userId = I('user_id',''); if (empty($userId) || $userId<1000000){ //$this->error("用户ID错误",'/admin/user/index'); } $userInfo = M('User')->where(array('user_id'=>$userId))->find(); //用户好友 $Model = M(); $count = $Model->field('user_id2')->table('t_user_connect')->where(array('user_id1'=>$userId)) ->union(array('field'=>'user_id1','table'=>'t_user_connect','where'=>array('user_id2'=>$userId)))->count(); //分页 $Page = new \Think\Page($count); $show = $Page->show(); $userIdList = D('UserConnect')->getConnectUserList($userId, $Page->firstRow, $Page->listRows); $userList = array(); $userIdArr = array(); if (function_exists('array_column')){ $userIdArr = array_column($userIdList, 'user_id'); }else{ foreach ($userIdList as $row){ $userIdArr[] = $row['user_id']; } } if (count($userIdArr)){ $userList = M('User')->where(array('user_id'=>array('IN',implode(',', $userIdArr))))->field()->order('user_id desc')->select(); } //获取用户等级 $levelRes = M('UserLevel')->field('level_id,level_name')->select(); $levelList = array(); foreach ($levelRes as $level){ $levelList[$level['level_id']] = $level['level_name']; } $areaRes = M('China')->select(); $areaList = array(); foreach ($areaRes as $row){ $areaList[$row['id']] = $row['name']; } $this->assign('areaList',$areaList); $this->assign('levelList',$levelList); $this->assign('userList',$userList); $this->assign('userInfo',$userInfo); $this->display(); } //用户课程 public function course(){ $courseStatus = I('course_status',''); $userId = I('user_id',''); if (empty($userId) || $userId<1000000){ $this->error("用户ID错误",'/admin/user/index'); } $condition = array('course_source'=>2,'user_id'=>$userId, 'is_delete'=>1,'course_flag'=>1); if (!empty($courseStatus)){ $condition['course_status'] = array('IN',$courseStatus); } $count = M('Course')->where($condition)->count(); //分页 $Page = new \Think\Page($count); $show = $Page->show(); $courseList = M('Course')->where($condition)->field()->order('course_id desc')->limit($Page->firstRow.','.$Page->listRows)->select(); $this->assign('page',$show); $this->assign('list',$courseList); $this->display(); } //用户自由记 public function notepad(){ $courseStatus = I('course_status',''); $userId = I('user_id',''); if (empty($userId) || $userId<1000000){ $this->error("用户ID错误",'/admin/user/index'); } $condition = array('user_id'=>$userId,'course_flag'=>2, 'is_delete'=>1,'course_source'=>2,); if (!empty($courseStatus)){ $condition['course_status'] = array('IN',$courseStatus); } $count = M('Course')->where($condition)->count(); //分页 $Page = new \Think\Page($count); $show = $Page->show(); $notepadList = M('Course')->where($condition)->field()->order('course_id desc')->limit($Page->firstRow.','.$Page->listRows)->select(); $this->assign('page',$show); $this->assign('list',$notepadList); $this->display(); } //用户禁言 public function forbidden(){ $userId = I('user_id',''); $days = I('days','0'); if (empty($userId) || $userId<1000000){ $this->error("用户ID错误",'/admin/user/index'); } M('user')->where(array('user_id'=>$userId))->save(array('forbidden'=>time()+$days*24*60*60)); } //设置用户管理员 public function set_admin(){ $userId = I('user_id',''); if (empty($userId) || $userId<1000000){ $this->error("用户ID错误",'/admin/user/index'); } $userInfo = M('User')->where(array('user_id'=>$userId))->find(); if (!$userInfo){ $this->error("用户ID错误",'/admin/user/index'); } $adminInfo = M('admin')->where(array('admin_account'=>$userInfo['user_phone']))->find(); if (!$adminInfo){ $data=array(); $data['admin_account']=$userInfo['user_phone']; $data['admin_pwd']=$userInfo['user_pwd']; $data['group_id']=1; $data['operate_dt'] = time(); M('admin')->add($data); $adminInfo = M('admin')->where($data)->find(); } $admin_id=$adminInfo['admin_id']; $uid=$userId; $noticeContent = '您已被设置为管理员,遇到恶意评论长摁评论可以删除,情节严重可长摁用户ID进行一段时间的禁言。'; $temp=array(); M('Notice')->add(array('ref_user_id'=>$uid,'user_id'=>0,'notice_flag'=>0,'notice_status'=>1,'notice_type'=>0,'notice_title'=>$noticeContent,'notice_content'=>$noticeContent,'operate_dt'=>time(),'extra'=>json_encode($temp))); M('User')->where(array('user_id'=>$uid))->setInc('sys_notice'); $data = array('type'=>0,'msg'=>$noticeContent,'data'=>array()); $url="http://www.hanlinyuanonline.com/api/choice/push?uid=".$uid."&data=".urlencode(base64_encode(json_encode($data))); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); M('user')->where(array('user_id'=>$userId))->save(array('admin_id'=>$admin_id,'is_delete'=>1)); } //取消用户管理员 public function cancle_admin(){ $userId = I('user_id',''); if (empty($userId) || $userId<1000000){ $this->error("用户ID错误",'/admin/user/index'); } if($userId==0){ $this->error("超管无法取消",'/admin/user/index'); } $userInfo = M('User')->where(array('user_id'=>$userId))->find(); if (!$userInfo){ $this->error("用户ID错误",'/admin/user/index'); } M('admin')->where(array('admin_id'=>$userInfo['admin_id']))->delete(); M('user')->where(array('user_id'=>$userId))->save(array('admin_id'=>0)); } }