コード例 #1
0
 public function loginAction()
 {
     session_start();
     if (IS_POST) {
         $username = I('post.username');
         $password = I('post.password');
         if (empty($username) || empty($password)) {
             $this->error('请输入用户名及密码');
         }
         $acl = new Acl();
         $user = $acl->getUser($username, true);
         if (!empty($user)) {
             $pwd = Utility::encodePassword($password, $user['salt']);
             if ($pwd != $user['password']) {
                 $this->error('您输入的密码错误');
             }
             if ($user['status'] == Acl::STATUS_DISABLED) {
                 $this->error('您的账号已经被禁用, 请联系系统管理员');
             }
             $user = coll_elements(array('uid', 'username', 'role'), $user);
             session('user', $user);
             $forward = I('get.forward');
             if (empty($forward)) {
                 $forward = U('bench/welcome/index');
             } else {
                 $forward = base64_decode($forward);
             }
             $this->success('成功登陆', $forward);
         } else {
             $this->error('您输入的用户名或密码错误');
         }
         exit;
     }
     $this->display('Wander/login');
 }
コード例 #2
0
ファイル: Acl.class.php プロジェクト: devsnippet/microbuilder
 public function modifyUser($uid, $user)
 {
     $uid = intval($uid);
     $input = coll_elements(array('password', 'role', 'status'), $user);
     $user = $this->getUser($uid);
     $input['password'] = Utility::encodePassword($input['password'], $user['salt']);
     $ret = $this->table('__USR_USERS__')->data($input)->where("`uid`={$uid}")->save();
     if ($ret !== false) {
         return true;
     }
     return error(-2, '保存用户数据失败, 请稍后重试');
 }
コード例 #3
0
 public function modifyAction($uid)
 {
     $uid = intval($uid);
     $user = $this->acl->getUser($uid, true);
     if (empty($user)) {
         $this->error('访问错误');
     }
     if (IS_POST) {
         $input = $this->validateForm(true);
         $input = coll_elements(array('password', 'role', 'status'), $input);
         $input['password'] = Utility::encodePassword($input['password'], $user['salt']);
         $ret = $this->acl->table('__USR_USERS__')->data($input)->where("`uid`={$uid}")->save();
         if (empty($ret)) {
             $this->error('保存用户信息失败, 请稍后重试');
         } else {
             $this->success('保存成功');
             exit;
         }
     }
     $this->assign('user', $user);
     $this->display('form');
 }
コード例 #4
0
ファイル: Member.class.php プロジェクト: vki/microbuilder
 public function create($member, $fan = null)
 {
     if (!preg_match('/^1\\d{10}$/', $member['mobile'])) {
         return error(-1, '你输入的手机号格式不正确');
     }
     $condition = '`mobile`=:mobile';
     $pars = array();
     $pars[':mobile'] = $member['mobile'];
     $exist = $this->table('__MMB_MEMBERS__')->where($condition)->bind($pars)->find();
     if (!empty($exist)) {
         return error(-2, '你输入的手机号已经注册过, 请直接登陆或者更换后重试');
     }
     $rec = coll_elements(array('mobile', 'password'), $member, '');
     $rec['salt'] = util_random(8);
     $rec['password'] = Utility::encodePassword($rec['password'], $rec['salt']);
     $condition = '`isdefault`=1';
     $pars = array();
     $group = $this->table('__MMB_GROUPS__')->where($condition)->bind($pars)->find();
     $rec['groupid'] = $group['id'];
     $rec['createtime'] = TIMESTAMP;
     $rec['joinfrom'] = $member['from'];
     if (empty($rec['joinfrom'])) {
         $rec['joinfrom'] = '';
     }
     $ret = $this->table('__MMB_MEMBERS__')->data($rec)->add();
     if (empty($ret)) {
         return error(-2, '系统错误, 创建会员失败, 请稍后重试');
     }
     $uid = $this->getLastInsID();
     $this->table('__MMB_PROFILES__')->data(array('uid' => $uid))->add();
     if (!empty($fan) && empty($fan['uid'])) {
         if ($rec['joinfrom'] == 'weixin') {
             $record = array();
             $record['uid'] = $uid;
             $this->table('__MMB_MAPPING_FANS__')->data($record)->where("`fanid`='{$fan['fanid']}' OR `unionid`='{$fan['unionid']}'")->save();
         }
     }
     return $uid;
 }