Example #1
0
 /**
  * 后台用户登录
  * @author 麦当苗儿 <*****@*****.**>
  */
 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();
         }
     }
 }
Example #2
0
 /**
  * 登录指定用户
  * @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;
 }
Example #3
0
 /**
  * 登录指定用户
  * @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;
 }
 /**
  * 后台用户登录
  * @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();
         }
     }
 }
 /**
  * 后台用户登录
  * @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();
         }
     }
 }
Example #6
0
 public function logout()
 {
     if (is_login()) {
         $user = new UserApi();
         $user->logout();
         $this->success('退出成功!', U('login'));
     } else {
         $this->redirect("Index/index");
     }
 }
 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 = "******";
         /* 调用注册接口注册用户 */
         $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');
     }
 }
 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;
 }
Example #9
0
 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);
     }
 }
Example #10
0
 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();
     }
 }
Example #11
0
 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);
 }
Example #12
0
 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', '*****@*****.**'), $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";
             //创建失败
         }
     }
 }
Example #13
0
 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;
 }
 /**
  * 后台用户登录
  */
 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();
         }
     }
 }
 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();
     }
 }
 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;
 }
 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();
 }
Example #18
0
 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;
 }
Example #19
0
 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, '修改失败');
     }
 }
Example #20
0
 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']);
     }
 }
Example #21
0
 public function order()
 {
     if (IS_POST) {
         $Order = D('Order');
         $order_id = 'NS' . date('YmdHis') . mt_rand(1000, 9999);
         $uid = is_login();
         if ($uid) {
             $result = $Order->input($order_id, $uid, 1);
         } else {
             $mobile = I('mobile', '', 'trim');
             /* 调用注册接口注册用户 */
             $User = new UserApi();
             $res = $User->checkMobile($mobile);
             if ($res == 1) {
                 $password = mt_rand(100000, 999999);
                 $uid = $User->register('', $password, '', $mobile);
                 if (0 < $uid) {
                     //注册成功
                     send_sms($mobile, '您的密码:' . $password);
                     $result = $Order->input($order_id, $uid, 1);
                 }
             } else {
                 $user_info = $User->getinfo($mobile, 3);
                 $result = $Order->input($order_id, $user_info[0], 1);
             }
         }
         if ($result) {
             $this->redirect('checkOrder', array('order_id' => $order_id));
         } else {
             $this->error('订单提交失败');
         }
     } else {
         $line_id = I('line_id', 0, 'intval');
         $tc_id = I('type_id', 0, 'intval');
         $date = I('date', 0, 'strtotime');
         if (empty($line_id) || empty($tc_id) || empty($date)) {
             $this->error('无效参数');
         }
         // 线路信息
         $line_info = M('Line')->find($line_id);
         // 套餐信息
         $map = array('line_id' => $line_id, 'end_time' => array('egt', strtotime('+' . $line_info['earlier_date'] . 'day')));
         $line_tc = M('LineTc')->where($map)->select();
         if (empty($line_tc)) {
             $this->error('没有报价方案');
         }
         $tc_info = array();
         foreach ($line_tc as $key => $value) {
             if ($value['tc_id'] == $tc_id) {
                 $tc_info = $value;
                 break;
             }
         }
         $ext_time = strtotime('+' . $line_info['earlier_date'] . 'day');
         $tc_str = explode(',', $tc_info['date_price_data']);
         foreach ($tc_str as $value) {
             list($k, $val) = explode('|', $value);
             $k = strtotime($k);
             if ($k <= $ext_time) {
                 continue;
             }
             if ($k == $date) {
                 $tc_info['price_info'] = explode('-', $val);
                 $tc_info['price_info'][] = date('Y-m-d', $k);
                 break;
             }
         }
         if (empty($tc_info['price_info'])) {
             $this->error('没有价格');
         }
         $this->assign('line_info', $line_info);
         $this->assign('line_tc', $line_tc);
         $this->assign('tc_info', $tc_info);
         $this->display();
     }
 }
Example #22
0
 public function finduid()
 {
     $uid = M('UsersDetail')->where(array('name' => $_POST['name'], 'phone' => $_POST['phone']))->getField('id');
     if (!$uid) {
         $User = new UserApi();
         $phone = $_POST['phone'];
         $name = $_POST['name'];
         $pwd = substr($phone, strlen($phone) - 6);
         $uid = $User->register($name, $pwd, $phone . '@guzhi.com');
         if ($uid > 0) {
             $user = array('id' => $uid, 'nickname' => $name, 'photo' => 0, 'status' => 1, 'reg_ip' => 2130706433, 'create_time' => NOW_TIME, 'update_time' => NOW_TIME);
             M('Users')->add($user);
             $detail = array('id' => $uid, 'name' => $name, 'card_id' => '', 'province' => '', 'city' => '', 'phone' => $phone);
             M('UsersDetail')->add($detail);
             $this->ajaxReturn(array('status' => 1, 'uid' => $uid, 'newuser' => 1));
         } else {
             $this->error($uid);
         }
     } else {
         $this->ajaxReturn(array('status' => 1, 'uid' => $uid));
     }
 }
Example #23
0
 public function add($username = '', $password = '', $repassword = '', $email = '')
 {
     if (IS_POST) {
         /* 检测密码 */
         if ($password != $repassword) {
             $this->error('密码和重复密码不一致!');
         }
         /* 调用注册接口注册用户 */
         $User = new UserApi();
         $uid = $User->register($username, $password, $email);
         if (0 < $uid) {
             //注册成功
             $user = array('uid' => $uid, 'nickname' => $username, 'status' => 1);
             if (!M('Member')->add($user)) {
                 $this->error('用户添加失败!');
             } else {
                 $this->success('用户添加成功!', U('index'));
             }
         } else {
             //注册失败,显示错误信息
             $this->error($this->showRegError($uid));
         }
     } else {
         $this->meta_title = '新增用户';
         $this->display();
     }
 }
 /**
  * 修改密码提交
  * @author huajie <*****@*****.**>
  */
 public function profile()
 {
     if (!is_login()) {
         $this->error('您还没有登陆', U('User/login'));
     }
     if (IS_POST) {
         //获取参数
         $uid = is_login();
         $password = I('post.old');
         $repassword = I('post.repassword');
         $data['password'] = I('post.password');
         empty($password) && $this->error('请输入原密码');
         empty($data['password']) && $this->error('请输入新密码');
         empty($repassword) && $this->error('请输入确认密码');
         if ($data['password'] !== $repassword) {
             $this->error('您输入的新密码与确认密码不一致');
         }
         $Api = new UserApi();
         $res = $Api->updateInfo($uid, $password, $data);
         if ($res['status']) {
             $this->success('修改密码成功!');
         } else {
             $this->error($res['info']);
         }
     } else {
         $this->display();
     }
 }
 /**
  * 我的资料
  */
 public function edit()
 {
     $uid = is_login();
     $user = new UserApi();
     $Member = D('Member');
     if (IS_POST) {
         /* UC信息更新 */
         $data['email'] = I('post.email');
         $data['mobile'] = I('post.mobile');
         $result_uc = $user->updateInfo2($uid, $data);
         /* Member表信息更新 */
         $data['truename'] = I('post.truename');
         $data['sex'] = I('post.sex');
         $data['qq'] = I('post.qq');
         $result = $Member->updateUserInfo($uid, $data);
         if ($result && $result_uc) {
             $this->success('修改成功', U('User/index'));
         } else {
             $this->error('修改失败');
         }
     } else {
         /* 调用UC获取用户信息 */
         $info_uc = $user->info($uid);
         /* 实例化Member模型获取用户信息 */
         $info = $Member->getUserInfo($uid);
         $this->assign('info_uc', $info_uc);
         $this->assign('info', $info);
     }
     $this->meta_title = '我的资料';
     $this->display();
 }
 /**
  * 修改密码提交
  * @author huajie <*****@*****.**>
  */
 public function submitPassword()
 {
     //获取参数
     $password = I('post.old');
     empty($password) && $this->error(L('_PLEASE_ENTER_THE_ORIGINAL_PASSWORD_'));
     $data['password'] = I('post.password');
     empty($data['password']) && $this->error(L('_PLEASE_ENTER_A_NEW_PASSWORD_'));
     $repassword = I('post.repassword');
     empty($repassword) && $this->error(L('_PLEASE_ENTER_THE_CONFIRMATION_PASSWORD_'));
     if ($data['password'] !== $repassword) {
         $this->error(L('_YOUR_NEW_PASSWORD_IS_NOT_CONSISTENT_WITH_THE_CONFIRMATION_PASSWORD_'));
     }
     $Api = new UserApi();
     $res = $Api->updateInfo(UID, $password, $data);
     if ($res['status']) {
         $this->success(L('_CHANGE_PASSWORD_SUCCESS_'));
     } else {
         $this->error(UCenterMember()->getErrorMessage($res['info']));
     }
 }
Example #27
0
 function bindAccount()
 {
     if ($_GET['password'] & $_GET['username']) {
         /* 调用UC登录接口登录 */
         $user = new UserApi();
         $uid = $user->login($_GET['username'], $_GET['password']);
         if (0 < $uid) {
             //UC登录成功
             $Member = D('Users');
             $Member->login($uid);
             if ($Member->login($uid)) {
                 //登录用户
                 $currentUser = M('UcenterMember')->where(" id = '" . $uid . "'")->find();
                 if ($currentUser['openid'] == null || ($currentUser['openid'] = '')) {
                     $this->ajaxReturn(array('success' => false, 'info' => '该账号已绑定其他微信账号!', 'errorcode' => 1));
                 }
                 $currentUser['openid'] = $_GET['openid'];
                 $update = M('UcenterMember')->save($currentUser);
                 if ($update == 1) {
                     //$this->redirect('/MCenter/index');
                     $this->ajaxReturn(array('success' => true, 'info' => '该微信已成功和您的账号绑定!'));
                 }
                 $this->ajaxReturn(array('success' => false, 'info' => '绑定失败,请重新绑定!', 'url' => '/MCenter/index'));
             } else {
                 $error = $Member->getError();
                 if ($error == 0) {
                     $this->error('该用户未激活,请联系管理员。');
                 }
                 $this->ajaxReturn(array('success' => false, 'info' => $error));
             }
         } else {
             $this->ajaxReturn(array('success' => false, 'info' => '用户未登录!!'));
             return;
         }
     }
 }
Example #28
0
 public function login()
 {
     $username = I('username');
     $password = I('password');
     $token = I('token');
     $type = I('type');
     $type = $type ? $type : 1;
     if (!$password || !$username) {
         $this->apiError(0, '未知的用户');
     }
     /* 调用UC登录接口登录 */
     $user = new UserApi();
     /*用户名类型 (1-用户名,2-邮箱,3-手机,4-UID)*/
     /*$type=1;*/
     $uid = $user->login($username, $password, 1);
     if (0 < $uid) {
         //UC登录成功
         /* 登录用户 */
         $Member = D('Member');
         if ($Member->login($uid)) {
             //登录用户
             $arr['ukey'] = $this->getKey($uid);
             if (!$arr['ukey']) {
                 $arr['ukey'] = $this->newKey($uid);
             }
             $userInfo = $this->getUserInfo($uid);
             if ($userInfo['vip']) {
                 /*注册容联*/
                 $info = M('ucenter_member')->find($uid);
                 if (!$info['subaccountsid']) {
                     $count = $this->newRonglian($username);
                     if ($count['status'] == '000000') {
                         $count['id'] = $uid;
                         unset($count['status']);
                         M('ucenter_member')->save($count);
                     } elseif ($count['status'] == '111150') {
                         /*帐号重复*/
                         $count = M('ucenter_member')->where(array('username' => array('like', $username . '_del%')))->find();
                         if ($count) {
                             $count1['id'] = $uid;
                             $count1['subAccountSid'] = $count['subaccountsid'];
                             $count1['subToken'] = $count['subtoken'];
                             $count1['voipAccount'] = $count['voipaccount'];
                             $count1['voipPwd'] = $count['voippwd'];
                             M('ucenter_member')->save($count1);
                         }
                     }
                     $arr['subAccountSid'] = $count['subaccountsid'];
                     $arr['subToken'] = $count['subtoken'];
                     $arr['voipAccount'] = $count['voipaccount'];
                     $arr['voipPwd'] = $count['voippwd'];
                 } else {
                     $arr['subAccountSid'] = $info['subaccountsid'];
                     $arr['subToken'] = $info['subtoken'];
                     $arr['voipAccount'] = $info['voipaccount'];
                     $arr['voipPwd'] = $info['voippwd'];
                 }
             } else {
                 $arr['subAccountSid'] = '';
                 $arr['subToken'] = '';
                 $arr['voipAccount'] = '';
                 $arr['voipPwd'] = '';
             }
             /*绑定推送*/
             //                if($token && !$this->checkBind($token,$uid)){
             //                    $this->bindToken($token,$uid,$type);
             //                }
             $per = C('USER_DATE_SXF');
             $coin = C("USER_DATE_COIN");
             $coin = $coin * $per / 100;
             $arr['freezing_coin'] = C("USER_DATE_COIN");
             $arr['phone_coin'] = C("USER_WATCH_PHONE");
             $arr['custom'] = C('USER_CUSTOM');
             $arr['shop_onoff'] = C('SHOP_ONOFF');
             $arr['company'] = "http://" . $_SERVER['HTTP_HOST'] . U('Msg/company');
             $arr['sxf'] = $coin;
             $arr['uid'] = $uid;
             $arr['pay_im'] = C('PAY_IM');
             $this->apiSuccess('成功', $arr);
         } else {
             $this->apiError(0, $Member->getError());
         }
     } else {
         //登录失败
         switch ($uid) {
             case -1:
                 $error = '用户不存在或被禁用!';
                 break;
                 //系统级别禁用
             //系统级别禁用
             case -2:
                 $error = '密码错误!';
                 break;
             default:
                 $error = $uid;
                 break;
                 // 0-接口参数错误(调试阶段使用)
         }
         $this->apiError($uid, $error);
     }
 }
Example #29
0
 /**
  * 修改密码提交
  * @author
  */
 public function profile()
 {
     if (IS_POST) {
         if (!($uid = is_login())) {
             $this->ajaxError("您还没有登陆,请先登陆");
         }
         //获取参数
         $password = I("post.old");
         $repassword = I("post.repassword");
         $data["password"] = I("post.password");
         empty($password) && $this->ajaxError("请输入原密码");
         empty($data["password"]) && $this->ajaxError("请输入新密码");
         empty($repassword) && $this->ajaxError("请输入确认密码");
         if ($data["password"] !== $repassword) {
             $this->ajaxError("您输入的新密码与确认密码不一致");
         }
         $Api = new UserApi();
         $res = $Api->updateInfo($uid, $password, $data);
         if ($res['status']) {
             $Api->logout();
             $this->ajaxSuccess("修改密码成功!请重新登录");
         } else {
             $this->ajaxError($res["info"]);
         }
     } else {
         if (!($uid = is_login())) {
             $this->error("您还没有登陆,请先登陆", U('/'), 2);
         }
         $this->meta_title = '修改密码';
         $this->display();
     }
 }
Example #30
0
 /**
  * 修改密码提交
  * @author huajie <*****@*****.**>
  */
 public function submitPassword()
 {
     //获取参数
     $password = I('post.old');
     empty($password) && $this->error('请输入原密码');
     $data['password'] = I('post.password');
     empty($data['password']) && $this->error('请输入新密码');
     $repassword = I('post.repassword');
     empty($repassword) && $this->error('请输入确认密码');
     if ($data['password'] !== $repassword) {
         $this->error('您输入的新密码与确认密码不一致');
     }
     $Api = new UserApi();
     $res = $Api->updateInfo(UID, $password, $data);
     if ($res['status']) {
         $this->success('修改密码成功!');
     } else {
         $this->error(UCenterMember()->getErrorMessage($res['info']));
     }
 }