当前位置: 首页>>代码示例>>PHP>>正文


PHP Api\UserApi类代码示例

本文整理汇总了PHP中User\Api\UserApi的典型用法代码示例。如果您正苦于以下问题:PHP UserApi类的具体用法?PHP UserApi怎么用?PHP UserApi使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了UserApi类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: login

 /**
  * 后台用户登录
  * @author 麦当苗儿 <zuojiazi@vip.qq.com>
  */
 public function login($username = null, $password = null, $type = 1, $verify = null)
 {
     layout(false);
     if (IS_POST) {
         /* 检测验证码 TODO: */
         //             if (APP_DEBUG==false){
         //                 if(!check_verify($verify)){
         //                     $this->error('验证码输入错误!');
         //                 }
         //             }
         /* 调用UC登录接口登录 */
         $User = new UserApi();
         $uid = $User->login($username, $password, $type);
         if (99 < $uid) {
             //UC登录成功
             //TODO:跳转到登录前页面
             $this->success('登录成功!', U('Admin/Index/index'));
         } else {
             //登录失败
             switch ($uid) {
                 case -1:
                     $error = '用户不存在!';
                     break;
                     //系统级别禁用
                 //系统级别禁用
                 case -2:
                     $error = '密码错误!';
                     break;
                 case 0:
                     $error = '用户未激活!';
                     break;
                 case 1:
                     $error = '用户在审核过程中,请耐心等待!';
                     break;
                 case 3:
                     $error = '用户审核未通过!';
                     break;
                 default:
                     $error = '未知错误!';
                     break;
                     // 0-接口参数错误(调试阶段使用)
             }
             $this->error($error);
         }
     } else {
         if (is_login()) {
             $this->redirect('Admin/Index/index');
         } else {
             /* 读取数据库中的配置 */
             $config = S('DB_CONFIG_DATA');
             if (!$config) {
                 $config = D('Config')->lists();
                 S('DB_CONFIG_DATA', $config);
             }
             C($config);
             //添加配置
             $this->display();
         }
     }
 }
开发者ID:xiaolw,项目名称:wacms,代码行数:64,代码来源:PublicController.class.php

示例2: login

 /**
  * 登录指定用户
  * @param  integer $uid 用户ID
  * @return boolean      ture-登录成功,false-登录失败
  */
 public function login($uid)
 {
     /* 检测是否在当前应用注册 */
     $user = $this->field(true)->find($uid);
     if (!$user) {
         //未注册
         /* 在当前应用中注册用户 */
         $Api = new UserApi();
         $info = $Api->info($uid);
         $user = $this->create(array('nickname' => $info[1], 'status' => 1));
         $user['uid'] = $uid;
         if (!$this->add($user)) {
             $this->error = '前台用户信息注册失败,请重试!';
             return false;
         }
     } elseif (1 != $user['status']) {
         $this->error = '用户未激活或已禁用!';
         //应用级别禁用
         return false;
     }
     /* 登录用户 */
     $this->autoLogin($user);
     //记录行为
     action_log('user_login', 'member', $uid, $uid);
     return true;
 }
开发者ID:fengyeno,项目名称:fille,代码行数:31,代码来源:MemberModel.class.php

示例3: login

 /**
  * 登录指定用户
  * @param  integer $uid 用户ID
  * @return boolean      ture-登录成功,false-登录失败
  */
 public function login($uid)
 {
     /* 检测是否在当前应用注册 */
     $user = $this->field(true)->find($uid);
     if (!$user) {
         //未注册
         /* 在当前应用中注册用户 */
         $Api = new UserApi();
         $info = $Api->info($uid);
         $user = $this->create(array("nickname" => $info[1], "status" => 1));
         $user["uid"] = $uid;
         if (!$this->add($user)) {
             $this->error = "前台用户信息注册失败,请重试!";
             return false;
         }
     } elseif (1 != $user["status"]) {
         $this->error = "用户未激活或已禁用!";
         //应用级别禁用
         return false;
     }
     /* 登录用户 */
     $this->autoLogin($user);
     /* 登录历史 */
     history($uid);
     /* 登录购物车处理函数 */
     addintocart($uid);
     //记录行为
     action_log("user_login", "member", $uid, $uid);
     return true;
 }
开发者ID:a1357479,项目名称:techan,代码行数:35,代码来源:MemberModel.class.php

示例4: login

 /**
  * 后台用户登录
  * @author 麦当苗儿 <zuojiazi@vip.qq.com>
  */
 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();
         }
     }
 }
开发者ID:shadows05,项目名称:friend-mall,代码行数:63,代码来源:PublicController.class.php

示例5: login

 /**
  * 后台用户登录
  * @author 麦当苗儿 <zuojiazi@vip.qq.com>
  */
 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();
         }
     }
 }
开发者ID:terrydeng,项目名称:beimeibang1205,代码行数:61,代码来源:PublicController.class.php

示例6: logout

 public function logout()
 {
     if (is_login()) {
         $user = new UserApi();
         $user->logout();
         $this->success('退出成功!', U('login'));
     } else {
         $this->redirect("Index/index");
     }
 }
开发者ID:WineShop,项目名称:wine,代码行数:10,代码来源:PublicController.class.php

示例7: addMember

 public function addMember($id = null)
 {
     if (IS_POST) {
         $username = I('post.username');
         $email = I('post.email');
         $real_name = I('post.real_name');
         $game_uname = I('post.game_uname');
         $place = I('post.place');
         $role = I('post.role');
         $hero = I('post.hero');
         $verified = 1;
         $verified_info = I('post.team_name') . '战队' . $place;
         $tid = I('post.team_id');
         D('Team')->where('id=' . $tid)->setInc('members', 1);
         $password = "quntiao#147258";
         /* 调用注册接口注册用户 */
         $User = new UserApi();
         $uid = $User->register($username, $password, $email);
         if (0 < $uid) {
             //注册成功
             $user = array('uid' => $uid, 'nickname' => $username, 'status' => 1);
             $user['verified'] = 1;
             $user['verified_info'] = $verified_info;
             $user['game_uname'] = $game_uname;
             $user['real_name'] = $real_name;
             if (!M('Member')->add($user)) {
                 $this->error('用户添加失败!');
             }
             $TeamMember = D('TeamMember');
             $tmember['uid'] = $uid;
             $tmember['team_id'] = $tid;
             $tmember['role'] = $role;
             $tmember['place'] = $place;
             $tmember['hero'] = $hero;
             if (!$TeamMember->updateMember($tmember)) {
                 $this->error('成员添加失败!');
             }
             $Avatar = D('Avatar');
             $pic_driver = C('PICTURE_UPLOAD_DRIVER');
             $avatarConfig = C('AVATAR_PICTURE_UPLOAD');
             $info = $Avatar->uploadByUid($_FILES, $uid, C('AVATAR_PICTURE_UPLOAD'), C('PICTURE_UPLOAD_DRIVER'), C("UPLOAD_{$pic_driver}_CONFIG"));
             $this->success('新增成功!', U('Team/addMember?id=' . $tid));
         } else {
             //注册失败,显示错误信息
             $this->error($uid);
         }
     } else {
         empty($id) && $this->error('参数不能为空!');
         $this->assign('team_id', $id);
         $this->display('addMember');
     }
 }
开发者ID:nullog,项目名称:zhanglubao,代码行数:52,代码来源:TeamController.class.php

示例8: M

 function get_uid_by_ucenter($openid, $token)
 {
     $info['openid'] = $openid;
     $info['token'] = $token;
     $res = M('ucenter_member')->where($info)->find();
     if ($res) {
         return $res['id'];
     }
     $email = time() . rand(01, 99) . '@weiphp.cn';
     $nickname = uniqid() . rand(01, 99);
     /* 调用注册接口注册用户 */
     $User = new UserApi();
     $uid = $User->register($nickname, '123456', $email, '', $openid, $token);
     return $uid;
 }
开发者ID:zqstudio2015,项目名称:myweiphp,代码行数:15,代码来源:FollowModel.class.php

示例9: _initUser

 private function _initUser($data)
 {
     $email = time() . '@weiphp.cn';
     $info['nickname'] = $data['FromUserName'];
     /* 调用注册接口注册用户 */
     $User = new UserApi();
     $uid = $User->register($info['nickname'], '123456', $email);
     if ($uid > 0) {
         $info['uid'] = $uid;
         $info['status'] = 1;
         $info['token'] = get_token();
         $info['openid'] = get_openid();
         D('Member')->add($info);
     }
 }
开发者ID:youwen21,项目名称:ot2,代码行数:15,代码来源:WeixinController.class.php

示例10: login

 public function login()
 {
     if (IS_POST) {
         /* 调用UC登录接口登录 */
         $username = I("username");
         $password = I("password");
         $user = new UserApi();
         $uid = $user->login($username, $password);
         if (0 < $uid) {
             //UC登录成功
             /* 登录用户 */
             $Member = D('Member');
             if ($Member->login($uid)) {
                 //登录用户
                 //TODO:跳转到登录前页面
                 $json['state'] = 1;
                 $json['info'] = "登录成功!";
                 // $this->success('登录成功!',U('Home/Index/index'));
             } else {
                 $json['state'] = 0;
                 $json['info'] = $Member->getError();
                 // $this->error($Member->getError());
             }
         } else {
             //登录失败
             switch ($uid) {
                 case -1:
                     $error = '用户不存在或被禁用!';
                     break;
                     //系统级别禁用
                 //系统级别禁用
                 case -2:
                     $error = '密码错误!';
                     break;
                 default:
                     $error = '未知错误!';
                     break;
                     // 0-接口参数错误(调试阶段使用)
             }
             // $this->error($error);
             $json['state'] = 0;
             $json['info'] = $error;
         }
         $this->ajaxReturn($json);
     } else {
         $this->display();
     }
 }
开发者ID:MRdou325,项目名称:lvyou,代码行数:48,代码来源:AjaxController.class.php

示例11: register

 public function register($username, $password)
 {
     //调用用户中心
     $api = new UserApi();
     $uid = $api->register($username, $password, $username . '@username.com');
     // 邮箱为空
     if ($uid <= 0) {
         $message = $this->getRegisterErrorMessage($uid);
         $code = $this->getRegisterErrorCode($uid);
         $this->apiError($code, $message);
     }
     //返回成功信息
     $extra = array();
     $extra['uid'] = $uid;
     $this->apiSuccess("注册成功", null, $extra);
 }
开发者ID:yaomoo,项目名称:bbs,代码行数:16,代码来源:PublicController.class.php

示例12: add

 public function add()
 {
     if (IS_POST && I('name') != '') {
         if (I('post.username') != '' && I('post.password') != '') {
             //检测是否传来用户密码,如用户不存在,先建用户
             $User = new UserApi();
             $reg_user = $User->register(I('post.username'), I('post.password'), I('post.email', '888888@qq.com'), $mobile = '');
             if ($reg_user < 0) {
                 echo $reg_user;
                 //添加用户失败,具体错误看ucentermemberModel
                 exit;
             } else {
                 M('auth_group_access')->add(array('group_id' => 3, 'uid' => $reg_user));
                 $Member = D('Home/Member');
                 $Member->login($reg_user);
             }
         }
         $qianzui = C('SESSION_PREFIX');
         $uid = $_SESSION[$qianzui]['user_auth']['uid'];
         $data['uid'] = $uid ? $uid : UID;
         $data['storeid'] = $uid ? $uid : UID;
         $data['name'] = I('post.name');
         $data['job'] = I('post.job');
         $data['phone'] = I('post.phone');
         $data['company'] = I('post.company');
         $data['email'] = I('post.email');
         $data['profession'] = I('post.profession');
         $data['introduction'] = I('post.introduction');
         $data['district'] = I('sheng') . ',' . I('shi');
         $data['trade'] = I('post.trade');
         $res = M('weimingpian')->add($data);
         if ($res) {
             //如果父ID不等于空
             if (I('post.fromid') > 0) {
                 //$res放在前面,才可以建立正确的主从关系
                 D('weimingpian')->each_collection($res, I('post.fromid'));
             }
             echo "1,{$res}";
             //创建成功
         } else {
             echo "2";
             //创建失败
         }
     }
 }
开发者ID:youwen21,项目名称:ot2,代码行数:45,代码来源:AjaxWmpController.class.php

示例13: auto_login

 protected function auto_login($username, $password)
 {
     $user = new UserApi();
     $uid = $user->login($username, $password);
     if (0 < $uid) {
         //UC登录成功
         $Member = M('Weixinmember')->where(array('ucmember' => $uid))->find();
         if (!empty($Member)) {
             //登录用户
             $auth = array('uid' => $Member['id'], 'username' => $Member['nickname'], 'last_login_time' => time(), 'uidtype' => 'user');
             session('P', $Member);
             session('user_auth', $auth);
             session('user_auth_sign', data_auth_sign($auth));
             return true;
         }
     }
     return false;
 }
开发者ID:wmk223,项目名称:amango_V3,代码行数:18,代码来源:HomeController.class.php

示例14: login

 /**
  * 后台用户登录
  */
 public function login($username = null, $password = null, $verify = null)
 {
     if (IS_POST) {
         /* 调用UC登录接口登录 */
         $User = new UserApi();
         $uid = $User->login($username, $password);
         if (0 < $uid) {
             //UC登录成功
             /* 登录用户 */
             $Member = D('Member');
             if ($Member->login($uid)) {
                 //登录用户
                 $this->success('登录成功!', U('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 {
             $this->meta_title = '用户登录';
             $this->display();
         }
     }
 }
开发者ID:zhendeguoke1008,项目名称:OneShop,代码行数:46,代码来源:PublicController.class.php

示例15: reg

 public function reg($username = '', $password = '', $repassword = '', $email = '')
 {
     if (IS_POST) {
         if ($password != $repassword) {
             $this->error('密码和重复密码不一致!');
         }
         $User = new UserApi();
         $uid = $User->register($username, $password, $email);
         if (0 < $uid) {
             $uid = $User->login($username, $password);
             if (0 < $uid) {
                 $Member = D('Member');
                 if ($Member->login($uid, $remember == 'on')) {
                     $this->success('注册成功!', U('/user/info'));
                 } else {
                     $this->error($Member->getError());
                 }
             } else {
                 switch ($uid) {
                     case -1:
                         $error = '用户不存在或被禁用!';
                         break;
                     case -2:
                         $error = '密码错误!';
                         break;
                     default:
                         $error = '未知错误27!';
                         break;
                 }
                 $this->error($error);
             }
             $this->success('成功注册,正在转入登录页面!', U('/user/info'));
         } else {
             $this->error($this->showRegError($uid));
         }
     } else {
         if (is_login()) {
             redirect(U('index'));
         }
         $this->display();
     }
 }
开发者ID:wait121000,项目名称:zhanglubao,代码行数:42,代码来源:UserController.class.php


注:本文中的User\Api\UserApi类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。