You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
253 lines
7.5 KiB
PHP
253 lines
7.5 KiB
PHP
<?php
|
|
namespace Admin\Controller;
|
|
|
|
|
|
/**
|
|
* 后台首页控制器
|
|
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
|
*/
|
|
class TestWhiteListController extends ThinkController
|
|
{
|
|
public function lists($p = 1) {
|
|
|
|
$page = intval($p);
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
$row=10;
|
|
if(isset($_REQUEST['row'])) {$row = $_REQUEST['row'];}else{$row = 10;}
|
|
|
|
$map =[];
|
|
if (I('account')) {
|
|
$map['account'] = array('like',I('account').'%');
|
|
}
|
|
|
|
$data = M('test_white_list','tab_')
|
|
->page($p, $row)
|
|
->where($map)
|
|
->order('create_ime DESC')
|
|
->select();
|
|
|
|
foreach ($data as $key => $Value) {
|
|
// $data[$key]['show_status'] = $data[$key]['show_status']?'显示':'锁定';
|
|
$data[$key]['create_ime'] = date('Y-m-d H:i:s',$Value['create_ime']);
|
|
}
|
|
|
|
$count = M('test_white_list','tab_')
|
|
->where($map)
|
|
->count();
|
|
|
|
$page = set_pagination($count, $row);
|
|
if ($page) {
|
|
$this->assign('_page', $page);
|
|
}
|
|
$this->meta_title = '测试白名单';
|
|
$this->assign('data',$data);
|
|
$this->display();
|
|
|
|
}
|
|
|
|
public function add() {
|
|
$this->meta_title = '测试白名单添加';
|
|
$this->assign('title','新增');
|
|
$this->display();
|
|
}
|
|
|
|
public function edit() {
|
|
$this->meta_title = '测试白名单编辑';
|
|
$this->assign('title','编辑');
|
|
$this->display("add");
|
|
}
|
|
|
|
public function edit_user() {
|
|
$data = I('');
|
|
|
|
if (!$data['user_id']) {
|
|
$this->error('请填写测试账号');
|
|
}
|
|
|
|
$userData['account'] = $data['account'];
|
|
|
|
$user = M('user','tab_')->where(array('id'=>$data['user_id']))->find();
|
|
|
|
if (!$user) {
|
|
$this->error('账号不存在');
|
|
}
|
|
$userData['check_status'] = $data['status']?$data['status']:0;
|
|
|
|
$userAdd = M('user','tab_')->where(array('id'=>$data['user_id']))->save($userData);
|
|
if ($userAdd) {
|
|
$whitedata['show_status'] = $data['status']?$data['status']:0;
|
|
$whitedata['account'] = $data['account'];
|
|
|
|
$whiteList = M('test_white_list','tab_')->where(array('user_id'=>$data['user_id']))->save($whitedata);
|
|
// echo M('test_white_list','tab_')->_sql();die();
|
|
|
|
if($whiteList) {
|
|
$this->success('修改白名单成功',U('TestWhiteList/lists'));
|
|
} else {
|
|
$this->error('修改白名单失败');
|
|
}
|
|
|
|
} else {
|
|
$this->error('修改用户失败');
|
|
}
|
|
}
|
|
|
|
public function edit_user1() {
|
|
$data = $_GET;
|
|
|
|
if (!$data['user_id']) {
|
|
$this->ajaxReturn(['status'=>0,'msg'=>"请填写测试账号"]);
|
|
}
|
|
|
|
$userData['account'] = $data['account'];
|
|
|
|
$user = M('user','tab_')->where(array('id'=>$data['user_id']))->find();
|
|
|
|
if (!$user) {
|
|
$this->ajaxReturn(['status'=>0,'msg'=>"账号不存在"]);
|
|
}
|
|
$userData['check_status'] = $data['status']?$data['status']:0;
|
|
|
|
$userAdd = M('user','tab_')->where(array('id'=>$data['user_id']))->save($userData);
|
|
if ($userAdd) {
|
|
$whitedata['show_status'] = $data['status']?$data['status']:0;
|
|
$whitedata['account'] = $data['account'];
|
|
|
|
$whiteList = M('test_white_list','tab_')->where(array('user_id'=>$data['user_id']))->save($whitedata);
|
|
// echo M('test_white_list','tab_')->_sql();die();
|
|
|
|
if($whiteList) {
|
|
//
|
|
addOperationLog(array(
|
|
"op_type"=>1,
|
|
"key"=>$data['account'],
|
|
"menu"=>"用户-玩家组-测试白名单-锁定/开启",
|
|
"url"=>U("TestWhiteList/lists",array('account'=>$data['account']))
|
|
));
|
|
$this->ajaxReturn(['status'=>1,'msg'=>"修改白名单成功"]);
|
|
} else {
|
|
$this->ajaxReturn(['status'=>0,'msg'=>"修改白名单成功"]);
|
|
}
|
|
|
|
} else {
|
|
$this->ajaxReturn(['status'=>0,'msg'=>"修改用户失败"]);
|
|
}
|
|
}
|
|
|
|
public function add_user() {
|
|
$data = I('');
|
|
|
|
if (!$data['account']) {
|
|
$this->error('请填写测试账号');
|
|
}
|
|
|
|
$userData['account'] = $data['account'];
|
|
|
|
$user = M('user','tab_')->where($userData)->find();
|
|
|
|
if (!$user) {
|
|
$this->error('账号不存在');
|
|
}
|
|
|
|
// $userData['password'] = md5(sha1('123456') . UC_AUTH_KEY);
|
|
// $userData['promote_id'] = 0;
|
|
// $userData['promote_account'] = '官方渠道';
|
|
// $userData['register_time'] = time();
|
|
// $userData['check_status'] = $data['status']?$data['status']:0;
|
|
//
|
|
// $userAdd = M('user','tab_')->add($userData);
|
|
// if ($userAdd) {
|
|
// dump($user);die();
|
|
|
|
$userWhite = M('test_white_list','tab_')->where(['user_id'=>$user['id']])->find();
|
|
|
|
if (!$userWhite) {
|
|
$data['user_id'] = $user['id'];
|
|
$data['show_status'] = $data['status']?$data['status']:0;
|
|
$data['add_user'] = $_SESSION['onethink_admin']['user_auth']['username'];
|
|
$data['create_ime'] = time();
|
|
|
|
$whiteList = M('test_white_list','tab_')->add($data);
|
|
if($whiteList) {
|
|
//操作日志
|
|
addOperationLog(array(
|
|
"op_type"=>0,
|
|
"key"=>$data['account'],
|
|
"menu"=>"用户-玩家组-测试白名单-添加测试账号",
|
|
"url"=>U("TestWhiteList/lists",array('account'=>$data['account']))
|
|
));
|
|
$this->success('添加白名单成功',U('TestWhiteList/lists'));
|
|
|
|
} else {
|
|
$this->error('添加白名单失败');
|
|
}
|
|
} else {
|
|
$this->error('白名单以添加,请勿重复添加');
|
|
}
|
|
|
|
|
|
|
|
// } else {
|
|
// $this->error('添加用户失败');
|
|
// }
|
|
|
|
}
|
|
|
|
public function freezeSupport() {
|
|
$supportId = I('status');
|
|
|
|
$data = [
|
|
'check_status' => $supportId
|
|
];
|
|
|
|
$isFreeze = M('user','tab_')->where("id=".$supportId)->save($data);
|
|
|
|
if ($supportId == 1) {
|
|
$msg = '启用';
|
|
} else if ($supportId == 0) {
|
|
$msg = '锁定';
|
|
}
|
|
|
|
if ($isFreeze) {
|
|
$this->ajaxReturn(['status'=>1, 'msg'=> $msg.'成功']);
|
|
} else {
|
|
$this->ajaxReturn(['status'=>0, 'msg'=> $msg.'失败']);
|
|
}
|
|
}
|
|
|
|
public function deleteWhileUser() {
|
|
|
|
$userId = $_REQUEST['id'];
|
|
|
|
// dump($userId);die();
|
|
|
|
$userWhite = M('test_white_list','tab_')->where(['id'=>$userId])->find();
|
|
|
|
|
|
if ($userWhite) {
|
|
|
|
$del = M('test_white_list','tab_')->where(['id'=>$userId])->delete();
|
|
|
|
if ($del) {
|
|
addOperationLog(array(
|
|
"op_type"=>2,
|
|
"key"=>$userWhite['account'],
|
|
"menu"=>"用户-玩家组-测试白名单-删除",
|
|
"url"=>U("TestWhiteList/lists")
|
|
));
|
|
$this->ajaxReturn(['status'=>0,'msg'=>"删除成功"]);
|
|
} else {
|
|
$this->ajaxReturn(['status'=>0,'msg'=>"删除失败"]);
|
|
}
|
|
|
|
} else {
|
|
|
|
$this->ajaxReturn(['status'=>0,'msg'=>"账号不存在,删除失败"]);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|