作者:xiaol
项目:wacm
/**
* 后台用户登录
* @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();
}
}
}
作者:fengyen
项目:fill
/**
* 登录指定用户
* @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;
}
作者:a135747
项目:techa
/**
* 登录指定用户
* @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;
}
作者:shadows0
项目:friend-mal
/**
* 后台用户登录
* @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();
}
}
}
作者:terryden
项目:beimeibang120
/**
* 后台用户登录
* @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();
}
}
}
作者:WineSho
项目:win
public function logout()
{
if (is_login()) {
$user = new UserApi();
$user->logout();
$this->success('退出成功!', U('login'));
} else {
$this->redirect("Index/index");
}
}
作者:nullo
项目:zhangluba
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');
}
}
作者:zqstudio201
项目:myweiph
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;
}
作者:youwen2
项目:ot
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);
}
}
作者:MRdou32
项目:lvyo
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();
}
}
作者:yaomo
项目:bb
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);
}
作者:youwen2
项目:ot
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";
//创建失败
}
}
}
作者:wmk22
项目:amango_V
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;
}
作者:zhendeguoke100
项目:OneSho
/**
* 后台用户登录
*/
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();
}
}
}
作者:wait12100
项目:zhangluba
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();
}
}
作者:rainly12
项目:zyz
private function getmoreinfo($encrypted_data)
{
$dataarray = explode('&', $encrypted_data);
$user = new UserApi();
$username = rtrim($dataarray[0], "");
//$dataarray[0];
$password = rtrim($dataarray[1], "");
//$dataarray[1];
$uid = $user->login($username, $password);
if ($uid > 0) {
$userinfo = M('UcenterMember')->where('id=' . $uid)->field('username,email,mobile')->find();
$encrypttext = $userinfo['username'] . '&' . $userinfo['email'] . '&' . $userinfo['mobile'];
$data['success'] = true;
$data['info'] = rawurlencode($this->encrypt($encrypttext));
} else {
$data['success'] = false;
$data['errorcode'] = 40002;
$data['errmsg'] = "Invalid username password";
}
return $data;
}
作者:gitchenz
项目:solosho
public function index()
{
// cookie自动登录
if (!is_login() && cookie('username') && cookie('password')) {
$username = cookie('username');
$password = cookie('password');
$username = safe_replace($username);
//过滤
$user = new UserApi();
$uid = $user->login($username, $password);
if (0 < $uid) {
//UC登录成功
/* 登录用户 */
$Member = D("Member");
if ($Member->login($uid)) {
//登录用户,记录日志
addUserLog('cookie登陆成功', $uid);
}
}
}
if (1 == C('IP_TONGJI')) {
$title = "index";
/**首页统计代码实现 status=1**/
$record = IpLookup("", 1, $title);
}
/** 幻灯片* */
$slide = D('slide')->get_slide();
$this->assign('slide', $slide);
/** 顶级栏目* */
$tree = D('Category')->maketree();
$this->assign('tree', $tree);
/** 公告分类**/
$notice = M('document')->order('id desc')->where("category_id='56'")->limit(8)->select();
$this->assign('notice', $notice);
/** 活动分类**/
$activity = M('document')->order('id desc')->where("category_id='70'")->limit(8)->select();
$this->assign('activity', $activity);
$this->meta_title = '首页';
$this->display();
}
作者:rainly12
项目:zyz
public function invest($id)
{
$data = $this->find($id);
$uid = M('UsersDetail')->where(array('phone' => $data['phone']))->getField('id');
if ($uid) {
$invest = M('ProjectInvestor')->where(array('project_id' => $data['pid'], 'investor_id' => $uid, 'status' => array('egt', 0)))->find();
if ($invest) {
$this->error = '该用户已在聚募投资该项目';
return false;
}
$invest = array('investor_id' => $uid, 'project_id' => $data['pid'], 'fund' => $data['fund'], 'step' => 4, 'status' => 9, 'pay_way' => 0, 'bak' => $data['from_way']);
D('ProjectInvestor')->invest($invest);
} else {
$api = new UserApi();
$ret = $api->register($data['phone'], substr($data['cardid'], -6), $data['phone']);
if ($ret < 0) {
Log::write('用户注册失败:(' . $ret . ')');
$this->error = '新用户注册失败,请联系管理员';
return false;
} else {
$uid = $ret;
}
$Member = M('Users');
$temp = array('id' => $uid, 'nickname' => $data['phone'], 'status' => 1, 'photo_url' => '/Public/Home/images/default_face/' . rand(1, 14) . '.jpg', 'reg_ip' => get_client_ip(1), 'create_time' => NOW_TIME, 'reg_time' => NOW_TIME);
$temp = $Member->create($temp);
$ret = $Member->add($temp);
$detail = array('id' => $uid, 'phone' => $data['phone'], 'name' => $data['real_name'], 'card_id' => $data['cardid'], 'create_time' => NOW_TIME, 'update_time' => NOW_TIME);
M('UsersDetail')->add($detail);
$auth = array('uid' => $uid, 'auth_id' => 0, 'status' => 9);
M('UserAuth')->add($auth);
$auth['auth_id'] = 1;
M('UserAuth')->add($auth);
$invest = array('investor_id' => $uid, 'project_id' => $data['pid'], 'fund' => $data['fund'], 'step' => 4, 'status' => 9, 'pay_way' => '0', 'bak' => $data['from_way']);
D('ProjectInvestor')->invest($invest);
}
$this->save(array('id' => $id, 'uid' => $uid, 'state' => 1));
return true;
}
作者:fengyen
项目:fill
public function changepwd()
{
// if(IS_POST){
$arr = I('post.');
if (!$arr['oldpwd'] || !$arr['password']) {
$this->apiError(0, '参数错误');
}
$user = new UserApi();
$data['password'] = $arr['password'];
$res = $user->updateInfo($this->uid, $arr['oldpwd'], $data);
// }
if ($res['status']) {
$this->apiSuccess('success');
} else {
$this->apiError(0, '修改失败');
}
}
作者:Willsho
项目:OLC
public function changucenter()
{
if (!is_login()) {
$this->error('您还没有登陆', U('User/login'));
}
//获取参数
$uid = is_login();
$oldpassword = I('post.oldpassword');
$repassword = I('post.repassword');
$password = I('post.password');
// $data['email'] = I('post.email');
if ($password != $repassword) {
$this->error('两次密码输入不一致');
}
if (!empty($password)) {
$data['password'] = $password;
}
$data['id'] = $uid;
$Api = new UserApi();
$res = $Api->updateInfo($uid, $oldpassword, $data);
if ($res['status']) {
$this->success('修改成功!');
} else {
$this->error($res['info']);
}
}