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.
194 lines
5.7 KiB
PHP
194 lines
5.7 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) {
|
|
$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) {
|
|
$data['user_id'] = $userAdd;
|
|
$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) {
|
|
$this->success('添加白名单成功',U('TestWhiteList/lists'));
|
|
} 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.'失败']);
|
|
}
|
|
}
|
|
|
|
}
|