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.

791 lines
28 KiB
PHTML

5 years ago
<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------
namespace Admin\Controller;
5 years ago
use User\Api\UserApi;
use Com\Wechat;
use Com\WechatAuth;
/**
* 后台用户控制器
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
class UserController extends AdminController
{
5 years ago
/**
* 用户管理首页
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
*/
public function index()
{
$nickname = I('nickname');
if (isset($_REQUEST['status'])) {
$map['status'] = $_REQUEST['status'];
}
if (is_numeric($nickname)) {
$map['uid|nickname'] = array(intval($nickname), array('like', '%' . $nickname . '%'), '_multi' => true);
} else {
$map['nickname'] = array('like', '%' . (string)$nickname . '%');
}
$list = $this->lists('Member', $map);
5 years ago
int_to_string($list);
$this->assign('_list', $list);
$this->meta_title = '管理员列表';
$this->m_title = '管理员列表';
$this->assign('commonset', M('Kuaijieicon')->where(['url' => 'User/index', 'status' => 1])->find());
5 years ago
$this->display();
}
/**
* 修改昵称初始化
* @author huajie <banhuajie@163.com>
*/
public function updateNickname()
{
5 years ago
$nickname = M('Member')->getFieldByUid(UID, 'nickname');
$this->assign('nickname', $nickname);
$this->meta_title = '修改昵称';
$this->display('updatenickname');
}
/**
* 修改昵称提交
* @author huajie <banhuajie@163.com>
*/
public function submitNickname()
{
5 years ago
//获取参数
$nickname = I('post.nickname');
$password = I('post.password');
empty($nickname) && $this->error('请输入昵称');
empty($password) && $this->error('请输入密码');
//密码验证
$User = new UserApi();
$uid = $User->login(UID, $password, 4);
5 years ago
($uid == -2) && $this->error('密码不正确');
$Member = D('Member');
$data = $Member->create(array('nickname' => $nickname));
if (!$data) {
5 years ago
$this->error($Member->getError());
}
$res = $Member->where(array('uid' => $uid))->save($data);
5 years ago
if ($res) {
$user = session('user_auth');
$user['username'] = $data['nickname'];
5 years ago
session('user_auth', $user);
session('user_auth_sign', data_auth_sign($user));
$this->success('修改昵称成功!');
} else {
5 years ago
$this->error('修改昵称失败!');
}
}
/**
* 修改密码初始化
* @author huajie <banhuajie@163.com>
*/
public function updatePassword()
{
5 years ago
$this->meta_title = '修改密码';
$this->display('updatepassword');
}
/**
* 修改密码提交
* @author huajie <banhuajie@163.com>
*/
public function submitPassword()
{
5 years ago
//获取参数
$password = I('post.old');
5 years ago
empty($password) && $this->error('请输入原密码');
$data['password'] = I('post.password');
empty($data['password']) && $this->error('请输入新密码');
$repassword = I('post.repassword');
empty($repassword) && $this->error('请输入确认密码');
if ($data['password'] !== $repassword) {
5 years ago
$this->error('您输入的新密码与确认密码不一致');
}
$Api = new UserApi();
$res = $Api->updateInfo(UID, $password, $data);
if ($res['status']) {
5 years ago
$this->success('修改密码成功!');
} else {
5 years ago
$this->error($res['info']);
}
}
/**
* 用户行为列表
* @author huajie <banhuajie@163.com>
*/
public function action()
{
5 years ago
//获取列表数据
$Action = M('Action')->where(array('status' => array('gt', -1)));
$list = $this->lists($Action);
5 years ago
int_to_string($list);
// 记录当前列表页的cookie
Cookie('__forward__', $_SERVER['REQUEST_URI']);
5 years ago
$this->assign('_list', $list);
$this->meta_title = '用户行为';
$this->display();
}
/**
* 新增行为
* @author huajie <banhuajie@163.com>
*/
public function addAction()
{
5 years ago
$this->meta_title = '新增行为';
$this->assign('data', null);
5 years ago
$this->display('editaction');
}
/**
* 编辑行为
* @author huajie <banhuajie@163.com>
*/
public function editAction()
{
5 years ago
$id = I('get.id');
empty($id) && $this->error('参数不能为空!');
$data = M('Action')->field(true)->find($id);
$this->assign('data', $data);
5 years ago
$this->meta_title = '编辑行为';
$this->display('editaction');
}
/**
* 更新行为
* @author huajie <banhuajie@163.com>
*/
public function saveAction()
{
5 years ago
$res = D('Action')->update();
if (!$res) {
5 years ago
$this->error(D('Action')->getError());
} else {
$this->success($res['id'] ? '更新成功!' : '新增成功!', Cookie('__forward__'));
5 years ago
}
}
/**
* 会员状态修改
* @author 朱亚杰 <zhuyajie@topthink.net>
*/
public function changeUserStatus($method = null)
{
$id = array_unique((array)I('id', 0));
if (in_array(C('USER_ADMINISTRATOR'), $id)) {
5 years ago
$this->error("不允许对超级管理员执行该操作!");
}
$id = is_array($id) ? implode(',', $id) : $id;
if (empty($id)) {
5 years ago
$this->error('请选择要操作的数据!');
}
$map['uid'] = array('in', $id);
$map1['id'] = array('in', $id);
$status = I('method') == 'forbidUser' ? 0 : 1;
$res = M('UcenterMember')->where($map1)->setField('status', $status);
$res1 = M('Member')->where($map)->setField('status', $status);
if ($res && $res1) {
$nickname = M('Member')->where($map)->field("nickname")->find()['nickname'];//默认一个,多个时需要遍历
addOperationLog(array(
"op_type"=>1,
"key"=> $nickname,
"menu"=>"用户-管理组-管理员列表-锁定/解锁",
"url"=>U("User/index",array("nickname"=>$nickname))
));
5 years ago
$this->success('更新成功!');
} else {
5 years ago
$this->error('更新失败!');
}
}
/**
* 会员状态修改
* @author 朱亚杰 <zhuyajie@topthink.net>
*/
public function changeStatus($method = null)
{
$id = array_unique((array)I('id', 0));
if (in_array(C('USER_ADMINISTRATOR'), $id)) {
5 years ago
$this->error("不允许对超级管理员执行该操作!");
}
$id = is_array($id) ? implode(',', $id) : $id;
if (empty($id)) {
5 years ago
$this->error('请选择要操作的数据!');
}
$map['uid'] = array('in', $id);
switch (strtolower($method)) {
5 years ago
case 'forbiduser':
\Think\Log::actionLog('User/changeStatus?method=forbidUser', 'user', 1);
$this->forbid('Member', $map);
5 years ago
break;
case 'resumeuser':
\Think\Log::actionLog('User/changeStatus?method=resumeuser', 'user', 1);
$this->resume('Member', $map);
5 years ago
break;
case 'deleteuser':
\Think\Log::actionLog('User/changeStatus?method=deleteuser', 'user', 1);
$this->delete('Member', $map);
5 years ago
break;
default:
$this->error('参数非法');
}
}
public function add($username = '', $password = '', $repassword = '', $email = '', $second_pwd = '')
{
5 years ago
if (IS_POST) {
5 years ago
/*检测用户名是否为空*/
if (empty($username)) {
5 years ago
$this->error('管理员账号不能为空!');
}
/* 检测密码 */
if ($password != $repassword) {
5 years ago
$this->error('管理员密码和确认密码不一致!');
}
5 years ago
$usernameUser = M('UcenterMember', 'sys_')->field('username')->where(['username' => $username])->find();
if (!empty($usernameUser)) {
$this->error('用户名已存在!');
}
$emailUser = M('UcenterMember', 'sys_')->field('id')->where(['email' => $email])->find();
5 years ago
if (!empty($emailUser)) {
$this->error('邮箱已存在!');
}
5 years ago
/* 调用注册接口注册用户 */
$User = new UserApi;
$uid = $User->register($username, $password, $email, $second_pwd);
if (0 < $uid) { //注册成功
$user = array('uid' => $uid, 'nickname' => $username, 'status' => 1,"birthday"=>date('Y-m-d',time()));
5 years ago
$data['uid'] = $uid;
$data['group_id'] = I('auth');
M('auth_group_access')->data($data)->add();
if (!M('Member')->add($user)) {
5 years ago
$this->error('用户添加失败!');
} else {
//操作日志
addOperationLog(array(
"op_type"=>0,
"key"=>$username,
"url"=>U("User/index",array("nickname"=>$username))
));
\Think\Log::actionLog('User/add', 'Member', $uid);
$this->success('用户添加成功!', U('index'));
5 years ago
}
} else { //注册失败,显示错误信息
$this->error($this->showRegError($uid));
}
} else {
$list = D('AuthGroup')->where(array('status' => 1))->select();
$this->assign('lists', $list);
5 years ago
$this->meta_title = '新增管理员';
$this->m_title = '管理员列表';
$this->assign('commonset', M('Kuaijieicon')->where(['url' => 'User/index', 'status' => 1])->find());
5 years ago
$this->display();
}
}
/**
* 系统非常规MD5加密方法
* @param string $str 要加密的字符串
* @return string
*/
function think_ucenter_md5($str, $key = 'ThinkUCenter')
{
return '' === $str ? '' : md5(sha1($str) . $key);
}
public function edit($id)
{
5 years ago
// var_dump(session());exit;
if (IS_POST) {
if (isset($_POST['bind_wx'])) {
if ($_POST['bind_wx'] == 'unbind_wx') {
$info['admin_openid'] = '';
} else {
$info['admin_openid'] = session('admin_openid');
if ($info['admin_openid'] == '') {
5 years ago
$this->error('请在30分钟内扫描并关注微信公众号');
}
}
}
if ($_POST['auth'] == '' && $id != 1) {
5 years ago
$this->error('请选择用户权限!');
}
if ($_POST['password'] == '') {
5 years ago
//$this->error('请填写管理员密码!');
}
if (!empty($_POST['password']) && (strlen($_POST['password']) < 6 || strlen($_POST['password']) > 30)) {
5 years ago
$this->error('管理员密码长度必须在6-30个字符之间');
}
if ($_POST['second_pwd'] == '') {
5 years ago
//$this->error('请填写二级密码!');
}
if (!empty($_POST['second_pwd']) && (strlen($_POST['second_pwd']) < 6 || strlen($_POST['second_pwd']) > 30)) {
5 years ago
$this->error('二级密码长度必须在6-30个字符之间');
}
if ($_POST['email'] == '') {
5 years ago
$this->error('请填写邮箱!');
}
$pattern = "/([a-z0-9]*[-_.]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[.][a-z]{2,3}([.][a-z]{2})?/i";
if (!preg_match($pattern, $_POST['email'])) {
$this->error('邮箱格式不正确!');
}
if (isset($_POST['mobile']) && $_POST['mobile'] != '') {
5 years ago
$dx = A('Phone');
$res = $dx->check_tel_code($_POST['mobile'], $_POST['code']);
5 years ago
switch ($res) {
case '-1':
$this->error('短信验证码无效,请重新获取');
break;
case '-2':
$this->error('时间超时,请重新获取短信验证码');
break;
case '-3':
$this->error('短信验证码不正确,请重新输入');
break;
}
}
$Member = D('UcenterMember');
$mem = D('Member');
$au = D('AuthGroupAccess');
$map['id'] = $id;
$maps['uid'] = $id;
$info['username'] = $_POST['username'];
$in['nickname'] = $_POST['username'];
$pwd = $this->think_ucenter_md5($_POST['password'], UC_AUTH_KEY);
$spwd = $this->think_ucenter_md5($_POST['second_pwd'], UC_AUTH_KEY);
$rpwd = $Member->where(array('id' => $id))->find();
$oldpwd = $rpwd['password'];
$oldspwd = $rpwd['second_pwd'];
5 years ago
$User = new UserApi;
$info['password'] = (empty($pwd) || $pwd == $oldpwd) ? $oldpwd : $pwd;
$info['second_pwd'] = (empty($spwd) || $spwd == $oldspwd) ? $oldspwd : $spwd;
$info['email'] = $_POST['email'];
$info['mobile'] = isset($_POST['mobile']) ? $_POST['mobile'] : '';
$ss['group_id'] = $_POST['auth'];
$ss['houtai'] = $_POST['houtai'];
$smember = $Member->where($map)->save($info);
$meb = $mem->where($maps)->save($in);
5 years ago
if ($au->where(array('uid' => $id))->find()) {
if ($ss['group_id'] == '') {
unset($ss['group_id']);
}
$ag = $au->where(array('uid' => $id))->save($ss);
} else {
$ss['uid'] = $id;
$ag = $au->add($ss);
}
if ($smember !== false || $meb || $ag) {
M('user_pwd')->where($maps)->setField('password', think_encrypt($info['password']));
addOperationLog(array(
"op_type"=>1,
"key"=>$_POST['username'],
"url"=>U("User/index",array("nickname"=>$_POST['username']))
));
$this->success('修改成功!', U('User/index'));
} else {
$this->error('修改失败!', U('User/index'));
5 years ago
}
} else {
$map['id'] = $_GET['id'];
$Member = D('UcenterMember')->where($map)->find();
$au = D('AuthGroupAccess')->where(array('uid' => $_GET['id']))->find();
$this->assign("authid", $au["group_id"]);
$this->assign("houtai", $au["houtai"]);
$list = D('AuthGroup')->where(array('status' => 1))->select();
$username = $_POST['username'];
$password = $_POST['password'];
$this->assign('lists', $list);
$this->assign('list', $Member);
$this->assign('sd', $group);
$this->meta_title = '编辑管理员';
$this->m_title = '管理员列表';
$this->assign('commonset', M('Kuaijieicon')->where(['url' => 'User/index', 'status' => 1])->find());
5 years ago
$this->display();
}
}
public function bdwx()
{
$map['id'] = UID;
$Member = D('UcenterMember')->field('id,username,admin_openid,openid_sign')->where($map)->find();
$this->assign('id', $map['id']);
$this->assign('list', $Member);
5 years ago
$this->meta_title = '绑定微信';
$this->display();
}
public function updatelist($p = 0)
{
5 years ago
$page = intval($p);
$page = $page ? $page : 1; //默认显示第一页数据
if (isset($_REQUEST['row'])) {
$row = $_REQUEST['row'];
} else {
$row = 10;
}
if (isset($_REQUEST['op_account'])) {
if ($_REQUEST['op_account'] == '全部') {
5 years ago
unset($_REQUEST['op_account']);
} else {
$map['op_account'] = trim($_REQUEST['op_account']);
5 years ago
unset($_REQUEST['op_account']);
}
}
if (isset($_REQUEST['game_name'])) {
$map['game_name'] = trim($_REQUEST['game_name']);
5 years ago
unset($_REQUEST['game_name']);
}
if (isset($_REQUEST['account'])) {
$map['user_account'] = array('like', '%' . trim($_REQUEST['account']) . '%');
5 years ago
unset($_REQUEST['account']);
}
if (isset($_REQUEST['huobi'])) {
$map['type'] = $_REQUEST['huobi'];
5 years ago
unset($_REQUEST['huobi']);
}
if (isset($_REQUEST['timestart']) && isset($_REQUEST['timeend'])) {
$map['create_time'] = array('BETWEEN', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 24 * 60 * 60 - 1));
5 years ago
unset($_REQUEST['timestart']);
unset($_REQUEST['timeend']);
} elseif (isset($_REQUEST['timestart'])) {
$map['create_time'] = ['GT', strtotime(I('timestart'))];
unset($_REQUEST['timestart']);
} elseif (isset($_REQUEST['timeend'])) {
$map['create_time'] = ['LT', strtotime(I('timeend')) + 86399];
5 years ago
unset($_REQUEST['timeend']);
}
$list = M('balance_edit', 'tab_')
5 years ago
->where($map)
->order('create_time desc')
->page($page, $row)
->select();
$count = M('balance_edit', 'tab_')->where($map)->count();
5 years ago
//分页
$page = set_pagination($count, $row);
if ($page) {
$this->assign('_page', $page);
}
$this->assign('list', $list);
5 years ago
$this->meta_title = '修改记录';
$this->m_title = '账户修改记录';
$this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Member/login_record', 'status' => 1])->find());
5 years ago
$this->display('updatelist');
}
5 years ago
/**
* 获取用户注册错误信息
* @param integer $code 错误编码
5 years ago
* @return string 错误信息
*/
private function showRegError($code = 0)
{
5 years ago
switch ($code) {
case -1:
$error = '管理员账号长度必须在16个字符以内';
break;
case -2:
$error = '管理员账号被禁止注册!';
break;
case -3:
$error = '管理员账号被占用!';
break;
case -4:
$error = '管理员密码长度必须在6-30个字符之间';
break;
case -5:
$error = '邮箱格式不正确!';
break;
case -6:
$error = '邮箱长度必须在1-32个字符之间';
break;
case -7:
$error = '邮箱被禁止注册!';
break;
case -8:
$error = '邮箱被占用!';
break;
case -9:
$error = '手机格式不正确!';
break;
case -10:
$error = '手机被禁止注册!';
break;
case -11:
$error = '手机号被占用!';
break;
case -12:
$error = '二级密码长度必须在6-30个字符之间';
break;
default:
$error = '未知错误';
5 years ago
}
return $error;
}
public function get_openid()
{
5 years ago
$User = new UserApi;
if ($_POST['id'] > 999) {
$this->ajaxReturn(array('status' => 0, 'msg' => '管理员id不能大于999'));
5 years ago
}
$data = $User->verifyPwd($_POST['id'], $_POST['pwd']);
if (!$data) {
$this->ajaxReturn(array('status' => 0, 'msg' => '密码错误,请重新选择'));
5 years ago
}
$appid = C('wechat.appid');
5 years ago
$appsecret = C('wechat.appsecret');
$result = auto_get_access_token(RUNTIME_PATH . '/access_token_validity.txt');
if ($result['is_validity']) {
session('token', $result['access_token']);
$auth = new WechatAuth($appid, $appsecret, $result['access_token']);
} else {
$auth = new WechatAuth($appid, $appsecret);
5 years ago
$token = $auth->getAccessToken();
$token['expires_in_validity'] = time() + $token['expires_in'];
wite_text(json_encode($token), RUNTIME_PATH . '/access_token_validity.txt');
session('token', $token['access_token']);
5 years ago
}
$times = date('s', time());
5 years ago
// $scene_id=strrev($_POST['id'].$times);
$scene_id = $_POST['id'] . $times . $_POST['type'];
session('scene_id', $scene_id);
$ticket = $auth->qrcodeCreate($scene_id, 600);//10分钟
if ($ticket == '') {
$return = array('status' => 0, 'data' => '获取ticket失败');
5 years ago
}
$qrcode = $auth->showqrcode($ticket['ticket']);
$return = array('status' => 1, 'data' => $qrcode);
5 years ago
$this->ajaxReturn($return);
}
function checkpwd()
{
5 years ago
$User = new UserApi;
$data = $User->verifyPwd($_POST['id'], $_POST['pwd']);
$this->ajaxReturn(array('data' => $data));
5 years ago
}
function checkOpenidpic()
{
5 years ago
sleep(2);
$data = M('ucenter_member')->where(array('id' => $_REQUEST['id']))->find();
if ($data['openid_sign'] == session('scene_id')) {
$this->ajaxReturn(array("status" => 1));
} else {
$this->ajaxReturn(array("status" => 0));
5 years ago
}
}
public function delete($id)
{
5 years ago
M()->startTrans();
$nickname = M('Member')->where("uid = '{$id}'")->field("nickname")->find()['nickname'];
5 years ago
$res1 = M('member')->delete($id);
$res2 = M('ucenter_member')->delete($id);
$res3 = M('auth_group_access')->where(array('uid' => $id))->delete();
if ($res1 && $res2 && $res3) {
5 years ago
M()->commit();
addOperationLog(array(
"op_type"=>2,
"key"=> $nickname,
"url"=>U("User/index")
));
5 years ago
$this->success('删除成功');
} else {
5 years ago
M()->rollback();
$this->error('删除失败' . M()->getError());
5 years ago
}
}
public function rolelist()
{
5 years ago
$map = [];
5 years ago
if (isset($_REQUEST['game_name'])) {
$map['game_name'] = ['like', trim($_REQUEST['game_name']) . "%"];
5 years ago
unset($_REQUEST['game_name']);
}
if (isset($_REQUEST['server_id'])) {
$map['server_id'] = trim($_REQUEST['server_id']);
unset($_REQUEST['server_id']);
}
if (isset($_REQUEST['role_name'])) {
$map['role_name'] = trim($_REQUEST['role_name']);
unset($_REQUEST['role_name']);
}
if (isset($_REQUEST['role_id'])) {
$map['role_id'] = trim($_REQUEST['role_id']);
unset($_REQUEST['role_id']);
}
// $promoteRoot = getPowerPromoteIds();
// $data_empower_type = session('user_auth')['data_empower_type'];
//
// if ($promoteRoot) {
// $map['promote_id'] =array('in',$promoteRoot);
// } else if(!$promoteRoot&&$data_empower_type!=1){
// $map['id'] = array('lt',1);
// }
setPowerPromoteIds($map,'promote_id');
5 years ago
if (isset($_REQUEST['promote_id'])) {
5 years ago
$queryStr = '';
if ($_REQUEST['promote_id'] == 0) {
$map['promote_id'] = '0';
} else {
5 years ago
$queryStr = "chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}";
5 years ago
$promoter_ids = D("Promote")->where($queryStr)->field('id')->select();
$promoter_ids ? $map['promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))] : null;
}
5 years ago
}
if (isset($_REQUEST['game_type'])) {
$map['sdk_version'] = trim($_REQUEST['game_type']);
unset($_REQUEST['game_type']);
}
if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) {
$map['create_time'] = ['between', [strtotime(I('time_start')), strtotime(I('time_end')) + 86399]];
} elseif (isset($_REQUEST['time_start'])) {
$map['create_time'] = ['GT', strtotime(I('time_start'))];
} elseif (isset($_REQUEST['time_end'])) {
$map['create_time'] = ['LT', strtotime(I('time_end')) + 86399];
}
empty(I('user_account')) || $map['user_account'] = ['like', "%" . I('user_account') . "%"];
$this->checkListOrCountAuthRestMap($map,["role_id", "role_name", "user_account"]);
5 years ago
$list = $this->lists(M('user_play_info', 'tab_'), $map, 'play_time desc');
5 years ago
$this->assign('list', $list);
$this->meta_title = '角色数据';
$this->m_title = '角色查询';
$this->assign('commonset', M('Kuaijieicon')->where(['url' => 'User/rolelist', 'status' => 1])->find());
$this->assign("is_admin",is_administrator());
5 years ago
$show_data_power = (is_administrator()|| session('user_auth')['show_data']);
$this->assign('show_data_power', $show_data_power);
5 years ago
$this->display();
}
/**
* 更新游戏角色数据
* @param $id
*/
public function user_update($ids)
{
5 years ago
$res = D('User')->update_user_player($ids);
$this->success("更新成功:{$res['suc']}个,失败:{$res['ero']}");
}
5 years ago
/**
* 更新游戏角色数据
* @param $id
*/
public function age()
{
if (IS_POST) {
5 years ago
$data = $_POST;
$a = new ToolController();
$re = $a->save($data);
//操作日志
$type = $_REQUEST['type'];
$meta_title = ($_REQUEST['type'] == 1 ? "实名认证" : '防沉迷');
addOperationLog(array(
"op_type"=>1,
"key"=>$type,
"menu"=>"用户-玩家组-实名认证设置-".$meta_title,
"url"=>U("Member/age",array('type'=>$type))
));
\Think\Log::actionLog('User/age', 'User', 1);
5 years ago
$this->success('保存成功');
} else {
$data = I('type', 1) == 1 ? C('age') : C('age_prevent');
$this->assign('data', $data);
$this->meta_title = I('type', 1) == 1 ? "实名认证设置" : '防沉迷设置';
$this->m_title = I('type', 1) == 1 ? '实名认证设置' : '防沉迷设置';
$this->assign('commonset', M('Kuaijieicon')->where(['url' => 'User/age/type/' . I('type', 1), 'status' => 1])->find());
5 years ago
$this->display();
}
5 years ago
}
public function update_pwd()
{
if (IS_POST) {
if (strlen($_POST['new_pwd']) < 6 || strlen($_POST['new_pwd']) > 30) {
5 years ago
$this->error('密码格式不正确!');
}
$oldspwd = $this->think_ucenter_md5($_POST['password'], UC_AUTH_KEY);
$newpwd = $this->think_ucenter_md5($_POST['new_pwd'], UC_AUTH_KEY);
$Member = D('UcenterMember');
$rpwd = $Member->where(array('id' => session('user_auth.uid')))->find();
if ($oldspwd == $rpwd['password']) {
$Member->where(array('id' => session('user_auth.uid')))->save(['password' => $newpwd]);
$this->success('修改成功!', U('User/index'));
} else {
5 years ago
$this->error('原密码错误!');
}
}
$this->display();
}
public function get_server_lists($game_id = 0)
{
$server = M("server", "tab_");
5 years ago
$map['game_id'] = $game_id;
$lists = $server->field('id,server_name,game_name')->where($map)->select();
if (empty($lists)) {
return $this->ajaxReturn(array('status' => 0, 'data' => ''));
5 years ago
}
return $this->ajaxReturn(array('status' => 1, 'data' => $lists));
5 years ago
}
}