本文整理汇总了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();
}
}
}
示例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;
}
示例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;
}
示例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();
}
}
}
示例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();
}
}
}
示例6: logout
public function logout()
{
if (is_login()) {
$user = new UserApi();
$user->logout();
$this->success('退出成功!', U('login'));
} else {
$this->redirect("Index/index");
}
}
示例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');
}
}
示例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;
}
示例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);
}
}
示例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();
}
}
示例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);
}
示例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";
//创建失败
}
}
}
示例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;
}
示例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();
}
}
}
示例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();
}
}