Beispiel #1
0
 public function grade_login()
 {
     if (!check_verify(I('code', ''))) {
         $this->error('验证码错误');
     }
     $username = I('username');
     $user = M('user')->where(array('username' => $username))->find();
     $pwd = I('password', '', 'md5');
     if (!$user | $user['password'] != $pwd) {
         $this->error('用户名或密码错误');
     }
     if ($user['lock']) {
         $this->error('用户被锁定,请联系管理员解锁');
     }
     $data = array('id' => $user['id'], 'logintime' => time(), 'loginip' => get_client_ip());
     M('user')->save($data);
     session(C('USER_AUTH_KEY'), $user['id']);
     session('username', $user['username']);
     session('lastlogintime', date('Y-m-d H:i', $user['logintime']));
     session('lastloginip', $user['loginip']);
     if ($user['username'] == C('RBAC_SUPERADMIN')) {
         session(C('ADMIN_AUTH_KEY'), true);
     }
     import('Org.Util.Rbac');
     Rbac::saveAccessList();
     //        dump($_SESSION);die;
     $this->redirect('Grade/Grade/grade_index');
 }
 public function send()
 {
     if (IS_POST) {
         $post_data = I('post.');
         if (!check_verify($post_data['verify'])) {
             $this->error('验证码输入错误!');
         }
         $post_data['send_from_id'] = $this->UserInfo['username'];
         $data = $this->Model->create($post_data);
         if ($data) {
             $result = $this->Model->add($data);
             if ($result) {
                 $this->success("操作成功!", U('outbox'));
             } else {
                 $error = $this->Model->getError();
                 $this->error($error ? $error : "操作失败!");
             }
         } else {
             $error = $this->Model->getError();
             $this->error($error ? $error : "操作失败!");
         }
     } else {
         $this->display();
     }
 }
Beispiel #3
0
 public function login($username = null, $password = null, $verify = null)
 {
     if (IS_POST) {
         $verify = I("post.verify", "", "trim");
         if (!check_verify($verify)) {
             $this->error('验证码输入错误!');
         }
         $username = I("post.username", "", "trim");
         $password = md5(I("post.password", "", "trim"));
         if (empty($username) || empty($password)) {
             $this->error("用户名或者密码不能为空,请重新输入!", U(C('AUTH_USER_GATEWAY')));
         }
         $map = array('username' => $username, 'password' => $password, 'status' => 1);
         $userinfo = M('User')->where($map)->find();
         if ($userinfo) {
             $AGA_Data = M('AuthGroupAccess')->where(array('uid' => $userinfo['id']))->find();
             $AG_Data = M('AuthGroup')->where(array('id' => $AGA_Data['group_id']))->find();
             $userinfo['group_title'] = $AG_Data['title'];
             session(C('AUTH_KEY'), $userinfo['id']);
             session('UserInfo', $userinfo);
             session('ModelKey.User', 1);
             //action_log('Admin_Login', 'User', $userinfo ['id']);
             $this->success("登录成功!", U(C('AUTH_USER_INDEX')));
         } else {
             $this->error("用户名密码错误或者此用户已被禁用!", U(C('AUTH_USER_GATEWAY')));
         }
     } else {
         $ModelKey = session('ModelKey.User');
         if (is_login() && $ModelKey == 1) {
             $this->redirect('Index/index');
         } else {
             $this->display();
         }
     }
 }
 public function login()
 {
     //判断是否已经登录
     $sessionuser['username'] = session('username');
     if (!empty($sessionuser['username'])) {
         $this->redirect('Index/index');
     }
     if ($_POST) {
         //登陆方法
         $user = D("admin");
         if (!check_verify($_POST['verify'])) {
             $this->error('验证码输入错误!');
         }
         if (!$user->create($_POST)) {
             // 如果创建失败 表示验证没有通过 输出错误提示信息
             $this->error($user->getError());
             //getError() \ThinkPHP\Library\Think\Model.class.php   返回模型的错误信息
         } else {
             $map['username'] = $_POST['username'];
             $map['password'] = hash('sha256', $_POST['password']);
             $result = $user->where($map)->select();
             if ($result) {
                 session('username', $map['username']);
                 $this->success('登陆成功', U('Index/index'));
             } else {
                 $this->error("用户名密码错误!");
             }
         }
     } else {
         $this->display();
         //登陆界面
     }
 }
Beispiel #5
0
 /**
  * 入口函数。此函数会被自动调用
  * */
 public function run()
 {
     //检查验证码
     if (!(APP_DEBUG && C('Not_VerifyCode'))) {
         check_verify(I('post.verifycode')) or drop(EC_4741);
     }
     //尝试创建数据对象
     //users表
     $usersMo = new UsersModel();
     $usersMo->field('qq,password');
     $usersMo->create(I('post.'), Model::MODEL_INSERT) or drop($usersMo->getError());
     //invite_code表
     $icMo = new InviteCodeModel();
     $icMo->field('uid,invite_code');
     $icMo->create(array('invite_code' => I('post.invite_code'), 'uid' => $usersMo->getUid()), Model::MODEL_INSERT) or drop($icMo->getError());
     //数据检查
     if (I('post.password') != I('post.re_password')) {
         drop(EC_4742);
     }
     $this->checkInviteCode_0(I('post.invite_code')) or drop(EC_4751);
     $this->checkInviteCode_1(I('post.invite_code')) or drop(EC_4752);
     //注册信息
     $usersMo->add() or drop(EC_4761);
     $icMo->save() or drop(EC_4762);
     //生成登陆信息
     log_in($usersMo->getUid());
     //返回成功信息
     echo drop('1200,' . $usersMo->getUid(), true);
 }
 /**
  * 后台登录入口
  * @author lck
  */
 public function login()
 {
     if (IS_POST) {
         $_POST = I('post.');
         $where['user'] = $_POST['user'];
         $res = M('Manager_shop')->where($where)->find();
         if (!$res) {
             $this->error('用户名不存在!');
         } elseif ($res['pass'] != md5($_POST['pass'])) {
             $this->error('密码不正确!');
         } else {
             $res['data'] = $res;
             $res['status'] = 1;
         }
         if (!$res['status']) {
             $this->error($res['error']);
         } elseif (!check_verify($_POST['verify'])) {
             $this->error('验证码错误!');
         } else {
             D('Manager')->sign_account_shop(array('id' => $res['data']['id'], 'user' => $res['data']['user'], 'shopid' => $res['data']['shopid']));
             $arr['lastlogintime'] = time();
             $arr['lastloginip'] = get_client_ip();
             $arr['logintimes'] = $res['data']['logintimes'] + 1;
             M('Manager_shop')->where('id=' . $res['data']['id'])->save($arr);
             $this->redirect('Index/index');
         }
     } else {
         $this->display();
     }
 }
 /**
  * 用户登录
  */
 public function login()
 {
     if (I('get.dosubmit')) {
         $admin_db = D('Admin');
         $username = I('post.username', '', 'trim') ? I('post.username', '', 'trim') : $this->error('用户名不能为空', HTTP_REFERER);
         $password = I('post.password', '', 'trim') ? I('post.password', '', 'trim') : $this->error('密码不能为空', HTTP_REFERER);
         //验证码判断
         $code = I('post.code', '', 'trim') ? I('post.code', '', 'trim') : $this->error('请输入验证码', HTTP_REFERER);
         if (!check_verify($code, 'admin')) {
             $this->error('验证码错误!', HTTP_REFERER);
         }
         if ($admin_db->login($username, $password, $info)) {
             session('userid', $info['userid']);
             session('roleid', $info['roleid']);
             $save_time = 3600 * 7 * 24;
             cookie('username', $username, $save_time);
             if (I('post.savepwd')) {
                 cookie('password', $password, $save_time);
             } else {
                 cookie('password', null);
             }
             $this->success('登录成功', U('Index/index'));
         } else {
             $this->error($admin_db->error, HTTP_REFERER);
         }
     } else {
         $this->display();
     }
 }
 public function login()
 {
     if (isset($_POST['userid']) && !empty($_POST['userid']) && isset($_POST['userpwd']) && !empty($_POST['userpwd']) && isset($_POST['logincode']) && !empty($_POST['logincode'])) {
         $code = $_POST['logincode'];
         $userid = $_POST['userid'];
         $userpwd = $_POST['userpwd'];
         if (!check_verify($code)) {
             echo 2;
             exit;
         }
         $rsa = M("admin")->where("admin_name='{$userid}'")->count();
         if ($rsa == 0) {
             //账号不存在
             echo 3;
             exit;
         } else {
             $rsb = M("admin")->where("admin_name='{$userid}' and admin_pwd='" . md5($userpwd) . "'")->count();
             if ($rsb == 0) {
                 //账号或密码错误
                 echo 4;
             } else {
                 $_SESSION['userid'] = $userid;
                 echo 1;
             }
         }
     } else {
         echo '0';
     }
 }
 /**
  * 后台用户登录
  * @author 麦当苗儿 <*****@*****.**>
  */
 public function login($username = null, $password = null, $verify = null)
 {
     /* 读取数据库中的配置 */
     $config = S('DB_CONFIG_DATA');
     if (!$config) {
         $config = D('Config')->lists();
         S('DB_CONFIG_DATA', $config);
     }
     C($config);
     //添加配置
     if (IS_POST) {
         /* 检测验证码 TODO: */
         if (C('WEB_SITE_VERIFY') && !check_verify($verify)) {
             $this->error('验证码输入错误!');
         }
         /* 登录用户 */
         $User = D('Common/User');
         if ($User->login($username, $password, 'admin_login')) {
             //登录用户
             //TODO:跳转到登录前页面
             $this->success('登录成功!', U('Index/index'));
         } else {
             $this->error($User->getError());
         }
     } else {
         if (is_login()) {
             $this->redirect('Index/index');
         } else {
             $this->display();
         }
     }
 }
Beispiel #10
0
 /**
  * [loginAuth 后台用户登录]
  * @param  [type] $username [用户名]
  * @param  [type] $password [密码]
  * @param  [type] $verify   [验证码]
  * @return [type]           [description]
  */
 public function loginAuth($username = null, $password = null, $verify = null)
 {
     if (IS_AJAX) {
         /* 检测验证码 TODO: */
         if (!check_verify($verify)) {
             $this->error('验证码输入错误!');
         }
         $User = D('Users');
         $uid = $User->login($username, $password);
         if (0 < $uid) {
             //登录成功
             $this->ajaxReturn(array('status' => 1, 'info' => '登录成功!', 'url' => U('Index/index')));
         } else {
             //登录失败
             switch ($uid) {
                 case -1:
                     $error = '用户不存在或被禁用!';
                     break;
                     //系统级别禁用
                 //系统级别禁用
                 case -2:
                     $error = '密码错误!';
                     break;
                 case -3:
                     $error = '用户组不存在或被禁用!';
                     break;
                 default:
                     $error = '未知错误!';
                     break;
                     // 0-接口参数错误(调试阶段使用)
             }
             $this->ajaxReturn(array('status' => 0, 'info' => $error));
         }
     }
 }
 public function login($username = null, $password = null, $verify = null)
 {
     $error = '';
     if (IS_POST && check_verify($verify)) {
         $Man = D('Manage');
         $mid = $Man->login($username, $password);
         if ($mid > 0) {
             session('user_auth', $mid);
             session('user_auth_sign', data_auth_sign($mid));
             $this->success('登录成功!', U('Index/index'));
         } else {
             switch ($mid) {
                 case -1:
                     $error = '用户不存在或被禁用!';
                     break;
                 case -2:
                     $error = '密码错误!';
                     break;
                 default:
                     $error = '未知错误!';
                     break;
             }
         }
     } elseif (IS_POST) {
         $error = '验证码输入错误!';
     }
     $this->assign("error", $error);
     $this->display();
 }
 public function login($username = null, $password = null, $verify = null, $autologin = false)
 {
     if (IS_POST || $autologin) {
         /* 检测验证码 TODO: */
         if (!check_verify($verify) && !$autologin) {
             $this->error('验证码输入错误!');
         }
         //自动判断用户名是哪个字段的
         $map[get_account_type($username)] = $username;
         $map['password'] = ainiku_ucenter_md5($password);
         $map['status'] = 1;
         //$map['member_group_id']=1;
         $map['is_adminlogin'] = 1;
         $user = D('MemberView')->where($map)->find();
         if (empty($user)) {
             //登录失败
             cookie('__uid__', null);
             return $autologin ? false : $this->error('用户名或密码错误!');
         } else {
             //登陆成功
             /* 记录登录SESSION和COOKIES */
             $auth = array('uid' => $user['member_id'], 'username' => $user['username'], 'last_login_time' => $user['update_time']);
             session('user_auth', $auth);
             session('uinfo', $user);
             session('user_auth_sign', data_auth_sign($auth));
             //更新用户登录信息
             $this->updateLogin($user['member_id']);
             //把用户密码加密保存到cookie中
             if (!$autologin) {
                 $u['u'] = ainiku_encrypt($username);
                 $u['p'] = ainiku_encrypt($password);
                 //如果有验证码的话就再次设置记录时间cookie
                 $a = I('post.remember');
                 $b = 0;
                 switch ($a) {
                     case 1:
                         $b = 24 * 3600;
                         break;
                     case 2:
                         $b = 24 * 3600 * 7;
                         break;
                     case 3:
                         $b = 24 * 3600 * 30;
                         break;
                     default:
                         $b = -1;
                 }
                 cookie('__uid__', $u, $b);
             }
             return $autologin ? $user['member_id'] : $this->success('登录成功!', U($user['admin_index'], array('mainmenu' => 'true')));
         }
     } else {
         if (is_login() || $this->autologin()) {
             $user = session('uinfo');
             redirect(U($user['admin_index'], array('mainmenu' => 'true')));
         } else {
             $this->display();
         }
     }
 }
 /**
  * 后台用户登录
  */
 public function login($username = null, $password = null, $verify = null)
 {
     if (IS_POST) {
         /* 检测验证码 TODO: */
         if (!check_verify($verify)) {
             $this->error('验证码输入错误!');
         }
         $db = M('user');
         $map['username'] = $username;
         $map['status'] = 1;
         $user = $db->where($map)->find();
         if (!$user) {
             $userExit = $db->where('username' . "='{$username}'")->find();
             if ($userExit) {
                 $this->error('帐号被禁用');
             } else {
                 $this->error('帐号不存在');
             }
         }
         if ($user['password'] != md5($password)) {
             $this->error('密码错误');
         }
         /* 记录登录SESSION和COOKIES */
         $auth = array('uid' => $user['id'], 'username' => $user['username'], 'fullname' => $user['fullname'], 'rid' => $user['role_id']);
         session('user', $auth);
         $this->success('登录成功!', U('Index/index'));
     } else {
         if (is_login()) {
             $this->redirect('Index/index');
         } else {
             $this->display();
         }
     }
 }
Beispiel #14
0
 /**
  * 入口函数。此函数会被自动调用
  * */
 public function run()
 {
     //检查验证码
     if (!(APP_DEBUG && C('Not_VerifyCode'))) {
         check_verify(I('post.verifycode')) or drop(EC_4841);
     }
     //校验登陆信息
     test_token() or drop(EC_4842);
     //校验是否需要登记信息
     get_state() == '100' or drop(EC_4843);
     //获取uid
     $_POST['uid'] = cookie('uid');
     //尝试创建数据对象
     //user_inf表
     $uiMo = new UserInfModel();
     $uiMo->create(I('post.'), Model::MODEL_INSERT) or drop($uiMo->getError());
     //users表
     $uMo = new UsersModel();
     $uMo->field('uid,state');
     $uMo->create(array('uid' => $_POST['uid'], 'state' => 200), Model::MODEL_UPDATE) or drop($uMo->getError());
     //注册信息
     $uiMo->add() or drop(EC_4861);
     $uMo->save() or drop(EC_4862);
     //End 注册信息
     drop(true);
 }
 public function chuanciquery()
 {
     if (IS_POST) {
         //注册用户
         /* 检测验证码 */
         if (!check_verify($verify)) {
             $this->error('验证码输入错误!');
         }
         /* 检测密码 */
         if ($password != $repassword) {
             $this->error('密码和重复密码不一致!');
         }
         /* 调用注册接口注册用户 */
         $User = new UserApi();
         $uid = $User->register($username, $password, $email);
         if (0 < $uid) {
             //注册成功
             //TODO: 发送验证邮件
             $this->success('注册成功!', U('login'));
         } else {
             //注册失败,显示错误信息
             $this->error($this->showRegError($uid));
         }
     } else {
         //显示注册表单
         $this->display();
     }
 }
 /**
  * @author alexgordon
  * @param 传入用户名 $user_name
  * @param 传入密码 $user_pwd
  * @return 数组
  */
 public function login($data)
 {
     $info = array();
     if (!$data[admins_name]) {
         $info = array('status' => 0, 'info' => '用户名不能为空!');
         return $info;
     }
     if (!$data[admins_password]) {
         $info = array('status' => 0, 'info' => '密码不能为空!');
         return $info;
     }
     if (!$data[verify]) {
         $info = array('status' => 0, 'info' => '验证码不能为空!');
         return $info;
     }
     if (!check_verify($data[verify])) {
         $info = array('status' => 0, 'info' => '验证码错误!');
         return $info;
     }
     $user_info = $this->where("admins_name='{$data[admins_name]}' AND admins_password='******'")->find();
     // 		dump($this->getLastSql());
     if ($user_info) {
         $info = array('status' => 1, 'info' => '登陆成功!');
         D('Logging')->addlogging('1');
         session("admins_name", $user_info['admins_name']);
         session("admins_id", $user_info['admins_id']);
         return $info;
     } else {
         $info = array('status' => 0, 'info' => '登陆失败!');
         return $info;
     }
 }
 public function login($username = null, $password = null, $verify = null, $autologin = false)
 {
     if (IS_POST || $autologin) {
         /* 检测验证码 TODO: */
         if (!check_verify($verify) && !$autologin) {
             $this->error('验证码输入错误!');
         }
         $uid = D('Member')->login($username, $password);
         if (0 < $uid) {
             //UC登录成功//把用户密码加密保存到cookie中
             if (!$autologin) {
                 $u['u'] = ainiku_encrypt($username);
                 $u['p'] = ainiku_encrypt($password);
                 //如果有验证码的话就再次设置记录时间cookie
                 $a = I('post.remember');
                 $b = 0;
                 switch ($a) {
                     case 1:
                         $b = 24 * 3600;
                         break;
                     case 2:
                         $b = 24 * 3600 * 7;
                         break;
                     case 3:
                         $b = 24 * 3600 * 30;
                         break;
                     default:
                         $b = -1;
                 }
                 cookie('__uid__', $u, $b);
             }
             return $autologin ? $uid : $this->success('登录成功!', U('Index/index'));
         } else {
             //登录失败
             //清空cookie
             cookie('__uid__', null);
             switch ($uid) {
                 case -1:
                     $error = '用户不存在或被禁用!';
                     break;
                     //系统级别禁用
                 //系统级别禁用
                 case -2:
                     $error = '密码错误!';
                     break;
                 default:
                     $error = L('_UNKNOWN_ERROR_');
                     break;
                     // 0-接口参数错误(调试阶段使用)
             }
             return $autologin ? false : $this->error($error);
         }
     } else {
         if (is_login()) {
             redirect(U('Index/index'));
         } else {
             $this->display();
         }
     }
 }
Beispiel #18
0
 /**
  * 后台用户登陆
  */
 public function login($username = null, $password = null, $verify = null)
 {
     if (IS_POST) {
         if (!check_verify($verify)) {
             $this->error('3验证码输入错误!');
         }
         $db = M('admin');
         $data['username'] = $username;
         $admin = $db->where($data)->find();
         if (!$admin) {
             $this->error('1帐号不存在或被禁用');
         }
         if ($admin['password'] != md5($password)) {
             $this->error('2密码不正确');
         }
         $data = array('uid' => $admin['uid'], 'login' => array('exp', '`login` + 1'), 'login_time' => date('y-m-d-H-i-s'), 'login_ip' => get_client_ip());
         $db->save($data);
         $auth = array('uid' => $data['uid'], 'login_time' => $data['login_time'], 'role' => $admin['role'], 'email' => $admin['email'], 'username' => $username);
         session('admin', $auth);
         session('_uid', $data['uid']);
         session('username', $username);
         //			echo dump(session('admin'));
         $this->success('登陆成功', U('Index/index', '', ''));
     } else {
         if (a_is_login()) {
             $this->redirect("Index/index");
         } else {
             layout(false);
             $this->display();
         }
     }
 }
 public function loginsubmit()
 {
     $username = I('post.username');
     $password = I('post.password');
     $user_group = I('post.user_group');
     $verify = I('post.verify');
     if (!check_verify($verify)) {
         $this->error('验证码输入错误!');
     }
     $res = \Org\Util\Rbac::authenticate(array('username' => $username, 'group' => $user_group));
     if (false == $res) {
         $this->error('帐号不存在或密码错误!');
     } else {
         $signpassword = sign_password($password);
         if ($res['password'] != $signpassword) {
             $this->error('用户名或密码错误!');
         }
     }
     $member = M('Member')->where(array('id' => $res['id']))->find();
     //更新活动时间
     M('Member')->where(array('id' => $res['id']))->save(array('timeupdate' => date('Y-m-d H:i:s'), 'lastip' => get_client_ip()));
     session('member', $member);
     cookie('login', true);
     if ($res['username'] == C('SPECIAL_USER')) {
         session(C('ADMIN_AUTH_KEY'), true);
     }
     session(C('USER_AUTH_KEY'), $res['id']);
     // 缓存访问权限
     \Org\Util\Rbac::saveAccessList();
     $this->success('登陆成功!');
 }
 /**
  * 后台用户登录
  * @author 麦当苗儿 <*****@*****.**>
  */
 public function login($username = null, $password = null, $verify = null)
 {
     if (IS_POST) {
         /* 检测验证码 TODO: */
         if (!check_verify($verify)) {
             $this->error('验证码输入错误!');
         }
         /* 调用UC登录接口登录 */
         $User = new UserApi();
         $uid = $User->login($username, $password);
         if (0 < $uid) {
             //UC登录成功
             /* 登录用户 */
             $Member = D('Member');
             if ($Member->login($uid)) {
                 //登录用户
                 //TODO:跳转到登录前页面
                 if ($uid == 2) {
                     $this->success('登录成功!', U('User/index'));
                 } else {
                     $this->success('登录成功!', U('Home/Index/index'));
                 }
             } else {
                 $this->error($Member->getError());
             }
         } else {
             //登录失败
             switch ($uid) {
                 case -1:
                     $error = '用户不存在或被禁用!';
                     break;
                     //系统级别禁用
                 //系统级别禁用
                 case -2:
                     $error = '密码错误!';
                     break;
                 default:
                     $error = '未知错误!';
                     break;
                     // 0-接口参数错误(调试阶段使用)
             }
             $this->error($error);
         }
     } else {
         if (is_login()) {
             $this->redirect('Index/index');
         } else {
             /* 读取数据库中的配置 */
             $config = S('DB_CONFIG_DATA');
             if (!$config) {
                 $config = D('Config')->lists();
                 S('DB_CONFIG_DATA', $config);
             }
             C($config);
             //添加配置
             $this->display();
         }
     }
 }
 /**
  * 判断验证码是否正确
  */
 protected function checkCode($verify)
 {
     if (!check_verify($verify)) {
         return false;
     } else {
         return true;
     }
 }
 /**
  * 后台用户登录
  * @author 麦当苗儿 <*****@*****.**>
  */
 public function login($username = null, $password = null, $verify = null)
 {
     if (IS_POST) {
         /* 检测验证码 TODO: */
         if (APP_DEBUG == false) {
             if (!check_verify($verify)) {
                 $this->error(L('_VERIFICATION_CODE_INPUT_ERROR_'));
             }
         }
         /* 调用UC登录接口登录 */
         $User = new UserApi();
         $uid = $User->login($username, $password);
         if (0 < $uid) {
             //UC登录成功
             /* 登录用户 */
             $Member = M('Member');
             if ($Member->login($uid)) {
                 //登录用户
                 //TODO:跳转到登录前页面
                 $this->success(L('_LOGIN_SUCCESS_'), U('Index/index'));
             } else {
                 $this->error($Member->getError());
             }
         } else {
             //登录失败
             switch ($uid) {
                 case -1:
                     $error = L('_USERS_DO_NOT_EXIST_OR_ARE_DISABLED_');
                     break;
                     //系统级别禁用
                 //系统级别禁用
                 case -2:
                     $error = L('_PASSWORD_ERROR_');
                     break;
                 default:
                     $error = L('_UNKNOWN_ERROR_');
                     break;
                     // 0-接口参数错误(调试阶段使用)
             }
             $this->error($error);
         }
     } else {
         if (is_login()) {
             $this->redirect('Index/index');
         } else {
             /* 读取数据库中的配置 */
             $config = S('DB_CONFIG_DATA');
             if (!$config) {
                 $config = M('Config')->lists();
                 S('DB_CONFIG_DATA', $config);
             }
             C($config);
             //添加配置
             $this->display();
         }
     }
 }
Beispiel #23
0
 public function check_verify()
 {
     $verify = I('verify');
     if (check_verify($verify)) {
         echo 1;
     } else {
         echo 0;
     }
 }
 /**
  * 后台用户登录
  */
 public function login($account = null, $password = null, $verify = null)
 {
     if (IS_POST) {
         if (!check_verify($verify)) {
             $this->error('验证码输入错误!');
         }
         $where['mobile'] = $account;
         $userModel = D('User');
         $user = $userModel->field('uid,uname,password,salt,status')->where($where)->find() or $this->error('此账号不存在!');
         $userModel->password($password, $user['salt']) == $user['password'] or $this->error('登录密码错误!');
         $user['status'] > 0 or $this->error('此账号已被禁用!');
         $userModel->login_success($user['uid'], $user['uname']);
         $uid = $user['uid'];
         $_POST['password'] = '******';
         action_log('系统', '登录');
         if (is_administrator($uid)) {
             $this->success('登录成功!', '/');
             exit;
         }
         // 检查是否有首页权限,若没有,则跳转到第一个有权限的页面去
         $rule_ids = [];
         $rules = M()->table('zj_system_auth_group g')->join('zj_system_auth_group_access ga ON g.id=ga.group_id')->where('g.status=1 AND ga.uid=' . $uid)->getField('rules', true);
         if ($rules) {
             foreach ($rules as $rule) {
                 if ($rule) {
                     $rule_ids = array_merge($rule_ids, explode(',', $rule));
                 }
             }
         }
         $rule_ids or $this->error('此账号无管理员权限!');
         $rules = M('system_auth_rule')->where(['id' => ['in', $rule_ids], 'status' => 1])->getField('name', true) or $this->error('此账号无有效权限!');
         // 获取首页地址
         if (in_array('Admin/Index/index', $rules)) {
             $next = '/';
         } else {
             $next = U(substr($rules[0], 6));
             foreach ($rules as $rule) {
                 if (strpos($rule, 'index')) {
                     $next = U(substr($rule, 6));
                     break;
                 }
             }
         }
         // 输出地址
         $this->success('登录成功!', $next);
     } else {
         if (is_login()) {
             $this->redirect('/');
         } else {
             C('COLOR_STYLE', 'default_color');
             $this->display('Public/login');
         }
     }
 }
Beispiel #25
0
 /**
  * 管理员忘记密码
  */
 public function forget($email = null, $verify = null)
 {
     if (IS_POST) {
         $result = array();
         if (!check_verify($verify)) {
             $this->error('验证码输入错误!');
         } else {
             $this->success('验证码输入正确!');
         }
     } else {
         $this->display();
     }
 }
 public function login()
 {
     if (IS_POST) {
         $_POST = I('post.');
         $res = D('Member')->check_account($_POST);
         if (!$res['status']) {
             if (IS_AJAX) {
                 $this->ajaxReturn(array('status' => 0, 'error' => $res['error']));
             } else {
                 $this->error($res['error']);
             }
         } else {
             if (!check_verify($_POST['verify'])) {
                 if (IS_AJAX) {
                     $this->ajaxReturn(array('status' => 0, 'error' => '验证码错误!'));
                 } else {
                     $this->error('验证码错误!');
                 }
             }
             D('Member')->sign_account(array('id' => $res['data']['id'], 'user' => $res['data']['user']));
             //记录登录时间
             D('Member')->save_item(array('id' => $res['data']['id'], 'last_login_time' => NOW_TIME));
             //记录账号cookie
             if ($_POST['remember']) {
                 cookie('user', $_POST['user']);
             } else {
                 cookie('user', null);
             }
             if ($_POST['back_url']) {
                 if (IS_AJAX) {
                     $this->ajaxReturn(array('status' => 1, 'back_url' => think_decrypt($_POST['back_url'])));
                 } else {
                     $this->redirect(think_decrypt($_POST['back_url']));
                 }
                 redirect(think_decrypt($_POST['back_url']), 1, '登录成功!');
             } else {
                 if (IS_AJAX) {
                     $this->ajaxReturn(array('status' => 1, 'back_url' => U('Member/Index/index')));
                 } else {
                     $this->success('登录成功!', 'Index/index');
                 }
             }
         }
     } else {
         //验证是否登录
         if ($id = D('Member')->is_login()) {
             $this->redirect('Index/index');
         }
         $this->display();
     }
 }
 public function register()
 {
     if (IS_POST) {
         $post = I('post.');
         if (!check_verify($post['verify'])) {
             $this->error('验证码输入错误!');
         }
         if ($post['password'] != $post['password_confirm']) {
             $this->error('密码和重复密码不一致!');
         }
         if (!ereg("^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\\.[a-zA-Z0-9_-])+", $post['email'])) {
             $this->error('邮箱格式不正确');
         }
         $UserLog = M('UserLogin');
         $uid = $UserLog->field('id')->where('email="' . $post['email'] . '"')->find();
         if ($uid) {
             $this->error('您输入的邮箱已被注册!');
         }
         $post['reg_time'] = $post['last_login_time'] = time();
         $post['reg_ip'] = $post['last_login_ip'] = iptolong(get_client_ip());
         $post['password'] = md5($post['password']);
         $post['status'] = 1;
         $UserLog->create($post);
         $uid = $UserLog->add();
         if ($uid) {
             cookie('cache_id', $uid);
             cookie('em', $post['email']);
             $emailurl = preg_replace("/^([a-zA-Z0-9_-])+@(([a-zA-Z0-9_-])+)\\.([a-zA-Z0-9_-])+/", "http://mail.\\2.com", $post['email']);
             //邮箱验证码
             $mail_verify = $uid . '_' . substr(md5($post['email']), 0, 5);
             $mail_verify_url = $_SERVER['HTTP_HOST'] . U('Login/email_verify', 'mail_verify=' . $mail_verify);
             $this->assign('email', $post['email']);
             $this->assign('emailurl', $emailurl);
             $this->assign('mail_verify_url', $mail_verify_url);
             $mail_con = $this->fetch('emailverifycon');
             //发送邮件
             load('@.function_mail');
             $mail_res = sendmail($post['email'], '[途经网]邮箱验证', $mail_con);
             if ($mail_res) {
                 $this->display();
             } else {
                 $this->error('邮件发送失败,请联系客服进行问题反馈', U('Login/login'));
             }
         } else {
             $this->error('操作失败,请稍后重试!');
         }
     } else {
         $this->error('您访问的页面有误');
     }
 }
 function join()
 {
     $voteId = I('vote_id');
     $optionId = I('option_id');
     $verify = I('verify');
     $voteInfo = D('Addons://Vote/ShopVote')->getInfo($voteId);
     if ($this->_is_overtime($voteInfo)) {
         // $this->error ( "请在指定的时间内投票" );
         $ajax_result['error'] = '投票活动时间已经过期';
         $this->ajaxReturn($ajax_result);
         return false;
     }
     if ($this->_is_join($voteInfo, $optionId)) {
         // $this->error ( "您已经投过,请不要重复投" );
         $ajax_result['error'] = '您已经投过票了';
         $this->ajaxReturn($ajax_result);
         return false;
     }
     if ($voteInfo['is_verify'] && (empty($verify) || !check_verify($verify))) {
         $ajax_result['error'] = '请输入正确的验证码';
         $this->ajaxReturn($ajax_result);
         return false;
     }
     // 如果没投过,就添加
     $data["uid"] = $this->mid;
     $data["vote_id"] = $voteId;
     $data["token"] = get_token();
     $data["ctime"] = time();
     $data['option_id'] = $optionId;
     $addid = M('shop_vote_log')->add($data);
     $newlog = D('Addons://Vote/ShopVoteOption')->getUserVoteLog($voteId, $data["uid"], true);
     // 更新投票数
     $map['id'] = $optionId;
     D('Addons://Vote/ShopVoteOption')->where($map)->setInc('opt_count');
     D('Addons://Vote/ShopVoteOption')->getInfo($optionId, true);
     D('Addons://Vote/ShopVoteOption')->getOptions($voteId, true);
     if ($addid) {
         if ($voteInfo['select_type'] == 2) {
             $also = $voteInfo['multi_num'] - count($newlog);
         }
         if ($also <= 0) {
             $ajax_result['success'] = '投票成功';
         } else {
             $ajax_result['success'] = '投票成功,你还可再投' . $also . ' 票!';
         }
     } else {
         $ajax_result['error'] = '投票失败';
     }
     $this->ajaxReturn($ajax_result);
 }
Beispiel #29
0
 public function login()
 {
     D('Admin')->logout();
     if (isLogin()) {
         $this->redirect('Index/welcome');
         exit;
     }
     if (IS_POST) {
         $name = trim($_POST['user_name']);
         $pwd = trim($_POST['password']);
         $captcha = trim($_POST['captcha']);
         $token = trim($_POST['token']);
         if ($name == '' || $pwd == '') {
             $this->error('用户名或密码为空!', U('login'));
             exit;
         }
         if ($captcha == '' || !check_verify($captcha, 1)) {
             $this->error('验证码输入错误!', U('login'));
             exit;
         }
         if ($token == '' || $token != session('admin_token')) {
             $this->error('非法请求!', U('login'));
             exit;
         }
         $lg_sn = D('Admin')->admin_login($name, $pwd);
         if ($lg_sn > 0) {
             session('admin_token', null);
             session('Module', MODULE_NAME);
             $this->success('登录成功!', U('Index/index'));
             exit;
         } else {
             switch ($lg_sn) {
                 case -1:
                     $error = '用户名或密码错误!';
                     break;
                 case -2:
                     $error = '用户名或密码错误!';
                     break;
                 default:
                     $error = '未知错误!';
                     break;
             }
             $this->error($error, U('login'));
         }
     } else {
         session('admin_token', md5(uniqid(rand(), TRUE)));
         $this->assign('token', session('admin_token'));
         $this->display();
     }
 }
 /**
  * 后台用户登录
  * @author datahome改写 <*****@*****.**>
  */
 public function login($username = null, $password = null, $verify = null)
 {
     if (IS_POST) {
         // 检测验证码
         if (!check_verify($verify)) {
             //$this->error('验证码输入错误!');
         }
         //调用 Member 模型的 login 方法,验证用户名、密码
         $Member = D('Member');
         $uid = $Member->login($username, $password);
         if (0 < $uid) {
             // 登录成功,$uid 为登录的 UID
             //跳转到登录前页面
             $this->success('登录成功!', U('Index/index'));
         } else {
             //登录失败
             switch ($uid) {
                 case -1:
                     $error = '用户不存在或被禁用!';
                     break;
                     //系统级别禁用
                 //系统级别禁用
                 case -2:
                     $error = '密码错误!';
                     break;
                 default:
                     $error = '未知错误!';
                     break;
                     // 0-接口参数错误(调试阶段使用)
             }
             $this->error($error);
         }
     } else {
         if (is_login()) {
             $this->redirect('Index/index');
         } else {
             /* 读取数据库中的配置 */
             $config = S('DB_CONFIG_DATA');
             if (!$config) {
                 $config = D('Config')->lists();
                 S('DB_CONFIG_DATA', $config);
             }
             C($config);
             //添加配置
             $this->display();
         }
     }
 }