/** * 注册页 */ public function register() { $this->setMobTitle('注册'); $aRegisteredtype = I('post.registeredtype', '', 'op_t'); switch ($aRegisteredtype) { case "username": $aRegType = "username"; $aUsername = $username = I('post.username', '', 'op_t'); break; case "email": $aRegType = "email"; $aUsername = $username = I('post.email', '', 'op_t'); break; case "mobile": $aRegType = "mobile"; $aUsername = $username = I('post.mobnumber', '', 'op_t'); break; } //获取参数 // $aUsername = $username = I('post.username', '', 'op_t'); $aNickname = I('post.nickname', '', 'op_t'); $aPassword = I('post.password', '', 'op_t'); $aVerify = I('post.verify', '', 'op_t'); $aRegVerify = I('post.reg_verify', 0, 'intval'); // $aRegType = I('post.reg_type', '', 'op_t'); $aStep = I('get.step', 'start', 'op_t'); $aRole = I('post.role', 0, 'intval'); //dump($aVerify); $this->setTopTitle('欢迎注册'); if (!modC('REG_SWITCH', '', 'USERCONFIG')) { $this->error('注册已关闭'); } if (IS_POST) { //注册用户 /* $register_type = modC('REGISTER_TYPE', 'normal', 'Invite'); $register_type = explode(',', $register_type); if (!in_array('normal', $register_type)) { $this->ajaxReturn(array('status'=>0,'info'=>"请先输入邀请码,收到邀请的用户才能注册该网站!")); }*/ $return = check_action_limit('reg', 'ucenter_member', 1, 1, true); if ($return && !$return['state']) { $this->error($return['info'], $return['url']); } if (strlen($aNickname) <= intval(modC('NICKNAME_MIN_LENGTH', '2', 'USERCONFIG'))) { $this->error('昵称请不少于' . modC('NICKNAME_MIN_LENGTH', '2', 'USERCONFIG') . '个字符'); } if (strlen($aNickname) >= modC('NICKNAME_MAX_LENGTH', '32', 'USERCONFIG')) { $this->error('昵称请不多于' . modC('NICKNAME_MAX_LENGTH', '32', 'USERCONFIG') . '个字符'); } if (strlen($aUsername) <= modC('USERNAME_MIN_LENGTH', '2', 'USERCONFIG')) { $this->error('用户名请不少于' . modC('USERNAME_MIN_LENGTH', '2', 'USERCONFIG') . '个字符'); } if (strlen($aUsername) >= modC('USERNAME_MAX_LENGTH', '32', 'USERCONFIG')) { $this->error('用户名请不多于' . modC('USERNAME_MAX_LENGTH', '32', 'USERCONFIG') . '个字符'); } if (empty($aPassword)) { $this->error('请输入密码'); } if (strlen($aPassword) < 6 || strlen($aPassword) > 32) { $this->error('密码长度在6-32位之间'); } /* 检测验证码 */ if (check_verify_open('reg')) { // dump(check_verify_open('reg')); if (!check_verify($aVerify)) { $this->error('验证码输入错误。'); } } if (!$aRole) { $this->error('请选择角色。'); } if ($aRegType == 'mobile' && modC('MOBILE_VERIFY_TYPE', 0, 'USERCONFIG') == 1 || modC('EMAIL_VERIFY_TYPE', 0, 'USERCONFIG') == 2 && $aRegType == 'email') { if (!D('Verify')->checkVerify($aUsername, $aRegType, $aRegVerify, 0)) { $str = $aRegType == 'mobile' ? '手机' : '邮箱'; $this->error($str . '验证失败'); } } $aUnType = 0; //获取注册类型 check_username($aUsername, $email, $mobile, $aUnType); if ($aRegType == 'email' && $aUnType != 2) { $this->error('邮箱格式不正确'); } if ($aRegType == 'mobile' && $aUnType != 3) { $this->error('手机格式不正确'); } if ($aRegType == 'username' && $aUnType != 1) { $this->error('用户名格式不正确'); } if (!check_reg_type($aUnType)) { $this->error('该类型未开放注册。'); } $aCode = I('post.code', '', 'op_t'); if (!$this->checkInviteCode($aCode)) { $this->error('非法邀请码!'); } /* 注册用户 */ $uid = UCenterMember()->register($aUsername, $aNickname, $aPassword, $email, $mobile, $aUnType); if (0 < $uid) { //注册成功 $this->initInviteUser($uid, $aCode, $aRole); $this->initRoleUser($aRole, $uid); //初始化角色用户 if (modC('EMAIL_VERIFY_TYPE', 0, 'USERCONFIG') == 1 && $aUnType == 2) { set_user_status($uid, 3); $verify = D('Verify')->addVerify($email, 'email', $uid); $res = $this->sendActivateEmail($email, $verify, $uid); //发送激活邮件 // $this->success('注册成功,请登录邮箱进行激活'); } $uid = UCenterMember()->login($username, $aPassword, $aUnType); //通过账号密码取到uid $res = D('Mob/Member')->mobileLogin($uid, false, $aRole); //登陆 if ($res) { $this->ajaxReturn(array('status' => 1)); } else { $this->ajaxReturn(array('status' => 0, 'info' => '注册失败')); } } else { //注册失败,显示错误信息 $this->ajaxReturn(array('status' => 0, 'info' => '注册失败')); } } else { //显示注册表单 if (is_login()) { redirect(U(C('AFTER_LOGIN_JUMP_URL'))); } $this->checkRegisterType(); $aType = I('get.type', '', 'op_t'); $regSwitch = modC('REG_SWITCH', '', 'USERCONFIG'); $regSwitch = explode(',', $regSwitch); $this->assign('regSwitch', $regSwitch); $this->assign('step', $aStep); $this->assign('type', $aType == '' ? 'username' : $aType); $this->display(); } }
public function doLogin() { $aUsername = $username = I('post.username', '', 'op_t'); $aPassword = I('post.password', '', 'op_t'); $aVerify = I('post.verify', '', 'op_t'); $aRemember = I('post.remember', 0, 'intval'); /* 检测验证码 */ if (check_verify_open('login')) { if (!check_verify($aVerify)) { $res['info'] = "验证码输入错误。"; return $res; } } /* 调用UC登录接口登录 */ check_username($aUsername, $email, $mobile, $aUnType); if (!check_reg_type($aUnType)) { $res['info'] = "该类型未开放登录。"; } $uid = UCenterMember()->login($username, $aPassword, $aUnType); if (0 < $uid) { //UC登录成功 /* 登录用户 */ $Member = D('Member'); $args['uid'] = $uid; $args = array('uid' => $uid, 'nickname' => $username); check_and_add($args); if ($Member->login($uid, $aRemember == 1)) { //登录用户 //TODO:跳转到登录前页面 if (UC_SYNC && $uid != 1) { //同步登录到UC $ref = M('ucenter_user_link')->where(array('uid' => $uid))->find(); $html = ''; $html = uc_user_synlogin($ref['uc_uid']); } $oc_config = (include_once './OcApi/oc_config.php'); if ($oc_config['SSO_SWITCH']) { include_once './OcApi/OCenter/OCenter.php'; $OCApi = new \OCApi(); $html = $OCApi->ocSynLogin($uid); } $res['status'] = 1; $res['info'] = $html; //$this->success($html, get_nav_url(C('AFTER_LOGIN_JUMP_URL'))); } else { $res['info'] = $Member->getError(); } } else { //登录失败 switch ($uid) { case -1: $res['info'] = '用户不存在或被禁用!'; break; //系统级别禁用 //系统级别禁用 case -2: $res['info'] = '密码错误!'; break; default: $res['info'] = $uid; break; // 0-接口参数错误(调试阶段使用) } } return $res; }
/** * register 注册页面 * @author:xjw129xjt(肖骏涛) xjt@ourstu.com */ public function register() { //获取参数 $aUsername = $username = I('post.username', '', 'op_t'); $aNickname = I('post.nickname', '', 'op_t'); $aPassword = I('post.password', '', 'op_t'); $aVerify = I('post.verify', '', 'op_t'); $aRegVerify = I('post.reg_verify', '', 'op_t'); $aRegType = I('post.reg_type', '', 'op_t'); $aStep = I('get.step', 'start', 'op_t'); $aRole = I('post.role', 0, 'intval'); if (!modC('REG_SWITCH', '', 'USERCONFIG')) { $this->error(L('_ERROR_REGISTER_CLOSED_')); } if (IS_POST) { //注册用户 $return = check_action_limit('reg', 'ucenter_member', 1, 1, true); if ($return && !$return['state']) { $this->error($return['info'], $return['url']); } /* 检测验证码 */ if (check_verify_open('reg')) { if (!check_verify($aVerify)) { $this->error(L('_ERROR_VERIFY_CODE_') . L('_PERIOD_')); } } if (!$aRole) { $this->error(L('_ERROR_ROLE_SELECT_') . L('_PERIOD_')); } if ($aRegType == 'mobile' && modC('MOBILE_VERIFY_TYPE', 0, 'USERCONFIG') == 1 || modC('EMAIL_VERIFY_TYPE', 0, 'USERCONFIG') == 2 && $aRegType == 'email') { if (!D('Verify')->checkVerify($aUsername, $aRegType, $aRegVerify, 0)) { $str = $aRegType == 'mobile' ? L('_PHONE_') : L('_EMAIL_'); $this->error($str . L('_FAIL_VERIFY_')); } } $aUnType = 0; //获取注册类型 check_username($aUsername, $email, $mobile, $aUnType); if ($aRegType == 'email' && $aUnType != 2) { $this->error(L('_ERROR_EMAIL_FORMAT_')); } if ($aRegType == 'mobile' && $aUnType != 3) { $this->error(L('_ERROR_PHONE_FORMAT_')); } if ($aRegType == 'username' && $aUnType != 1) { $this->error(L('_ERROR_USERNAME_FORMAT_')); } if (!check_reg_type($aUnType)) { $this->error(L('_ERROR_REGISTER_NOT_OPENED_') . L('_PERIOD_')); } $aCode = I('post.code', '', 'op_t'); if (!$this->checkInviteCode($aCode)) { $this->error(L('_ERROR_INV_ILLEGAL_') . L('_EXCLAMATION_')); } /* 注册用户 */ $ucenterMemberModel = UCenterMember(); $uid = $ucenterMemberModel->register($aUsername, $aNickname, $aPassword, $email, $mobile, $aUnType); if (0 < $uid) { //注册成功 $this->initInviteUser($uid, $aCode, $aRole); $ucenterMemberModel->initRoleUser($aRole, $uid); //初始化角色用户 if (modC('EMAIL_VERIFY_TYPE', 0, 'USERCONFIG') == 1 && $aUnType == 2) { set_user_status($uid, 3); $verify = D('Verify')->addVerify($email, 'email', $uid); $res = $this->sendActivateEmail($email, $verify, $uid); //发送激活邮件 // $this->success('注册成功,请登录邮箱进行激活'); } $uid = $ucenterMemberModel->login($username, $aPassword, $aUnType); //通过账号密码取到uid D('Member')->login($uid, false, $aRole); //登陆 $this->success('', U('Ucenter/member/step', array('step' => get_next_step('start')))); } else { //注册失败,显示错误信息 $this->error($this->showRegError($uid)); } } else { //显示注册表单 if (is_login()) { redirect(U('Home/Index/index')); } $this->checkRegisterType(); $aType = I('get.type', '', 'op_t'); $regSwitch = modC('REG_SWITCH', '', 'USERCONFIG'); $regSwitch = explode(',', $regSwitch); $this->assign('regSwitch', $regSwitch); $this->assign('step', $aStep); $this->assign('type', $aType == '' ? 'username' : $aType); $this->display(); } }
/** * register 注册页面 * @author:xjw129xjt(肖骏涛) xjt@ourstu.com */ public function register() { //获取参数 $aUsername = $username = I('post.username', '', 'op_t'); $aNickname = I('post.nickname', '', 'op_t'); $aPassword = I('post.password', '', 'op_t'); $aVerify = I('post.verify', '', 'op_t'); $aRegVerify = I('post.reg_verify', 0, 'intval'); $aRegType = I('post.reg_type', '', 'op_t'); $aStep = I('get.step', 'start', 'op_t'); $aRole = I('post.role', 0, 'intval'); //$aTuijian = I('post.tuijian',0,'intval'); $aYaoqingma = I('post.yaoqingma', 0, 'intval'); if (!modC('REG_SWITCH', '', 'USERCONFIG')) { $this->error('注册已关闭'); } if (IS_POST) { //注册用户 $return = check_action_limit('reg', 'ucenter_member', 1, 1, true); if ($return && !$return['state']) { $this->error($return['info'], $return['url']); } /* 检测验证码 */ if (check_verify_open('reg')) { if (!check_verify($aVerify)) { $this->error('验证码输入错误。'); } } if (!$aRole) { $this->error('请选择角色。'); } /* 检测邀请码 */ if ($aYaoqingma) { $res = D('broker')->checkYaoqingma($aYaoqingma); if (!$res) { $this->error('sorry,邀请码不正确'); } } //检测短信 if ($aRegType == 'mobile' && modC('MOBILE_VERIFY_TYPE', 0, 'USERCONFIG') == 1 || modC('EMAIL_VERIFY_TYPE', 0, 'USERCONFIG') == 2 && $aRegType == 'email') { if (!D('Verify')->checkVerify($aUsername, $aRegType, $aRegVerify, 0)) { $str = $aRegType == 'mobile' ? '手机' : '邮箱'; $this->error($str . '验证失败'); } } $aUnType = 0; //获取注册类型 check_username($aUsername, $email, $mobile, $aUnType); if ($aRegType == 'email' && $aUnType != 2) { $this->error('邮箱格式不正确'); } if ($aRegType == 'mobile' && $aUnType != 3) { $this->error('手机格式不正确'); } if ($aRegType == 'username' && $aUnType != 1) { $this->error('用户名格式不正确'); } if (!check_reg_type($aUnType)) { $this->error('该类型未开放注册。'); } $aCode = I('post.code', '', 'op_t'); if (!$this->checkInviteCode($aCode)) { $this->error('非法邀请码!'); } /* 注册用户 */ $uid = UCenterMember()->register($aUsername, $aNickname, $aPassword, $email, $mobile, $aUnType); if (0 < $uid) { //注册成功 /////////////////// // 初始化说说 // /////////////////// $this->initialShuo($uid); $this->initInviteUser($uid, $aCode, $aRole); //邀请用户? $this->initRoleUser($aRole, $uid); //初始化角色用户 //通常用不上? if (modC('EMAIL_VERIFY_TYPE', 0, 'USERCONFIG') == 1 && $aUnType == 2) { set_user_status($uid, 3); $verify = D('Verify')->addVerify($email, 'email', $uid); $res = $this->sendActivateEmail($email, $verify, $uid); //发送激活邮件 // $this->success('注册成功,请登录邮箱进行激活'); } $uid = UCenterMember()->login($username, $aPassword, $aUnType); //通过账号密码取到uid //判断邀请码 if ($aYaoqingma) { $res = D('broker')->addPid($uid, $aYaoqingma); } D('Member')->login($uid, false, $aRole); //实际登陆 //$this->success('注册成功', U('Ucenter/member/step', array('step' => get_next_step('start')))); } else { //注册失败,显示错误信息 $this->error($this->showRegError($uid)); } } else { //显示注册表单 //已经把这部分代码迁移到mobregister中 if (is_login()) { redirect(U(C('AFTER_LOGIN_JUMP_URL'))); } $this->checkRegisterType(); $aType = I('get.type', '', 'op_t'); $regSwitch = modC('REG_SWITCH', '', 'USERCONFIG'); $regSwitch = explode(',', $regSwitch); $this->assign('regSwitch', $regSwitch); $this->assign('step', $aStep); $this->assign('type', $aType == '' ? 'username' : $aType); $this->display(); } }
?> " nullmsg="<?php echo L('_PW_INPUT_ERROR_'); ?> " datatype="*6-30" name="password"> <div class="input-group-addon"><a style="width: 100%;height: 100%" href="javascript:void(0);" onclick="change_show(this)">show</a></div> </div> </div> <div class="clearfix"></div> </div> <?php if (check_verify_open('login')) { ?> <div class="form-group"> <label for="verifyCode" class=".sr-only col-xs-12" style="display: none"></label> <div class="col-xs-4"> <input type="text" id="verifyCode" class="form-control" placeholder="<?php echo L('_VERIFY_CODE_'); ?> " errormsg="<?php echo L('_MI_CODE_NULL_'); ?> " nullmsg="<?php echo L('_MI_CODE_NULL_');
/** * register 注册页面 */ public function register($domain = null) { // $domain = return_url(); //获取参数 $aUsername = $username = I('post.username', '', 'op_t'); $aNickname = I('post.nickname', '', 'op_t'); $aPassword = I('post.password', '', 'op_t'); $aVerify = I('post.verify', '', 'op_t'); $aRegVerify = I('post.reg_verify', 0, 'intval'); $aRegType = I('post.reg_type', '', 'op_t'); $aStep = I('get.step', 'start', 'op_t'); $aRole = I('post.role', 0, 'intval'); $acid = I('post.cid', '', 'op_t'); $aCompany = ''; if (!modC('REG_SWITCH', '', 'USERCONFIG')) { $this->error('注册已关闭'); } if (IS_POST) { //注册用户 $return = check_action_limit('reg', 'ucenter_member', 1, 1, true); if ($return && !$return['state']) { $this->error($return['info'], $return['url']); } /* 检测验证码 */ if (check_verify_open('reg')) { if (!check_verify($aVerify)) { $this->error('验证码输入错误。'); } } /** * 手机验证码和邮箱验证码的验证 */ if ($aRegType == 'mobile' && modC('MOBILE_VERIFY_TYPE', 0, 'USERCONFIG') == 1 || modC('EMAIL_VERIFY_TYPE', 0, 'USERCONFIG') == 2 && $aRegType == 'email') { if (!D('Verify')->checkVerify($aUsername, $aRegType, $aRegVerify, 0)) { $str = $aRegType == 'mobile' ? '手机' : '邮箱'; $this->error($str . '验证失败'); } } /** * 根据编号查询集团 // 判断用户IP是否是公司集团IP */ if (!empty($acid) && $aRegType == 'company') { $company = M('Company')->find((int) $acid); $aCompany = $company['cname']; $checkIp = new \Expend\CheckIP($company['cip']); if (TRUE !== $checkIp->check(get_client_ip()) && ip2long(get_client_ip()) !== ip2long($company['cip'])) { $this->error('你的IP地址不是集团IP'); } } else { $acid = 0; } $aUnType = 0; //获取注册类型 check_username($aUsername, $email, $mobile, $aCompany, $aUnType); if ($aRegType == 'email' && $aUnType != 2) { $this->error('邮箱格式不正确'); } if ($aRegType == 'mobile' && $aUnType != 3) { $this->error('手机格式不正确'); } if ($aRegType == 'username' && $aUnType != 1) { $this->error('用户名格式不正确'); } if (!check_reg_type($aUnType)) { $this->error('该类型未开放注册。'); } /* 注册用户 */ $uid = UCenterMember()->register($aUsername, $aNickname, $aPassword, $email, $mobile, $acid, $aUnType, $domain); if (0 < $uid) { #初始化角色用户,并设置相关的用户角色信息 $this->initRoleUser($aRole, $uid); if (modC('EMAIL_VERIFY_TYPE', 0, 'USERCONFIG') == 1 && $aUnType == 2) { set_user_status($uid, 3); $verify = D('Verify')->addVerify($email, 'email', $uid); $res = $this->sendActivateEmail($email, $verify, $uid); //发送激活邮件 } $this->success('注册成功', U('Ucenter/member/register', array('mes' => 'login'))); } else { //注册失败,显示错误信息 $this->error($this->showRegError($uid)); } } else { //显示注册表单 if (is_login()) { redirect(U(C('AFTER_LOGIN_JUMP_URL'))); } if ($_GET['mes']) { $this->assign('mes', 'login'); } //显示集团 $company = D('Admin/Company')->show_company(); $this->assign('company_list', $company); $this->checkRegisterType(); $aType = I('get.type', '', 'op_t'); $regSwitch = modC('REG_SWITCH', '', 'USERCONFIG'); $regSwitch = explode(',', $regSwitch); $this->assign('regSwitch', $regSwitch); $this->assign('step', $aStep); $this->assign('type', $aType == '' ? 'username' : $aType); $this->display(); } }
/** * register 注册页面 * @author:xjw129xjt(肖骏涛) xjt@ourstu.com */ public function register() { //获取参数 $aUsername = $username = I('post.username', '', 'op_t'); $aNickname = I('post.nickname', '', 'op_t'); $aPassword = I('post.password', '', 'op_t'); $aVerify = I('post.verify', '', 'op_t'); $aRegVerify = I('post.reg_verify', 0, 'intval'); $aRegType = I('post.reg_type', '', 'op_t'); $aStep = I('get.step', 'start', 'op_t'); $aRole = I('post.role', 0, 'intval'); if (!modC('REG_SWITCH', '', 'USERCONFIG')) { $this->error('注册已关闭'); } if (IS_POST) { //注册用户 $return = check_action_limit('reg', 'ucenter_member', 1, 1, true); if ($return && !$return['state']) { $this->error($return['info'], $return['url']); } /* 检测验证码 */ if (check_verify_open('reg')) { if (!check_verify($aVerify)) { $this->error('验证码输入错误。'); } } if (!$aRole) { $this->error('请选择角色。'); } if ($aRegType == 'mobile' && modC('MOBILE_VERIFY_TYPE', 0, 'USERCONFIG') == 1 || modC('EMAIL_VERIFY_TYPE', 0, 'USERCONFIG') == 2 && $aRegType == 'email') { if (!D('Verify')->checkVerify($aUsername, $aRegType, $aRegVerify, 0)) { $str = $aRegType == 'mobile' ? '手机' : '邮箱'; $this->error($str . '验证失败'); } } $aUnType = 0; //获取注册类型 check_username($aUsername, $email, $mobile, $aUnType); if ($aRegType == 'email' && $aUnType != 2) { $this->error('邮箱格式不正确'); } if ($aRegType == 'mobile' && $aUnType != 3) { $this->error('手机格式不正确'); } if ($aRegType == 'username' && $aUnType != 1) { $this->error('用户名格式不正确'); } if (!check_reg_type($aUnType)) { $this->error('该类型未开放注册。'); } /* 注册用户 */ $uid = UCenterMember()->register($aUsername, $aNickname, $aPassword, $email, $mobile, $aUnType); if (0 < $uid) { //注册成功 $this->initRoleUser($aRole, $uid); //初始化角色用户 if (modC('EMAIL_VERIFY_TYPE', 0, 'USERCONFIG') == 1 && $aUnType == 2) { set_user_status($uid, 3); $verify = D('Verify')->addVerify($email, 'email', $uid); $res = $this->sendActivateEmail($email, $verify, $uid); //发送激活邮件 // $this->success('注册成功,请登录邮箱进行激活'); } $uid = UCenterMember()->login($username, $aPassword, $aUnType); //通过账号密码取到uid D('Member')->login($uid, false, $aRole); //登陆 $this->success('', U('Ucenter/member/step', array('step' => get_next_step('start')))); } else { //注册失败,显示错误信息 $this->error($this->showRegError($uid)); } } else { //显示注册表单 if (is_login()) { $url = C('AFTER_LOGIN_JUMP_URL'); redirect(U($url)); } //角色 $map['status'] = 1; $map['invite'] = 0; $roleList = D('Admin/Role')->selectByMap($map, 'sort asc', 'id,title'); $this->assign('role_list', $roleList); //角色end $aType = I('get.type', '', 'op_t'); $regSwitch = modC('REG_SWITCH', '', 'USERCONFIG'); $regSwitch = explode(',', $regSwitch); $this->assign('regSwitch', $regSwitch); $this->assign('step', $aStep); $this->assign('type', $aType == '' ? 'username' : $aType); $this->display(); } }
public function login() { $aUsername = $username = I('username', '', 'op_t'); $aPassword = I('password', '', 'op_t'); $aVerify = I('verify', '', 'op_t'); $aRemember = I('remember', 0, 'intval'); // 检测验证码 if (check_verify_open('login')) { if (!check_verify($aVerify)) { $res['info'] = "验证码输入错误。"; return $res; } } // 调用UC登录接口登录 check_username($aUsername, $email, $mobile, $aUnType); if (!check_reg_type($aUnType)) { $res['info'] = "该类型未开放登录。"; } $uid = UCenterMember()->login($username, $aPassword, $aUnType); if (0 < $uid) { //UC登录成功 // 登录用户 $Member = D('Member'); $args['uid'] = $uid; $args = array('uid' => $uid, 'nickname' => $username); check_and_add($args); if ($Member->mobileLogin($uid, $aRemember) == 1) { //登录用户 if (UC_SYNC && $uid != 1) { //同步登录到UC $ref = M('ucenter_user_link')->where(array('uid' => $uid))->find(); } $extra = array(); $extra['session_id'] = session_id(); $extra['uid'] = $uid; C(api('Config/lists')); $extra['weibo_words_limit'] = C('WEIBO_WORDS_COUNT'); $extra['version'] = C('APP_VERSION'); $extra['self'] = query_user(array('uid', 'nickname', 'avatar128', 'avatar256'), is_login()); $this->apiSuccess("登录成功", $extra); } else { $this->apiError('登陆成功'); } } else { //登录失败 switch ($uid) { case -1: $res['info'] = '用户不存在或被禁用!'; break; //系统级别禁用 //系统级别禁用 case -2: $res['info'] = '密码错误!'; break; default: $res['info'] = $uid; break; // 0-接口参数错误(调试阶段使用) } } dump(1111); $this->apiError($res['info']); }
public function doLogin() { $aUsername = $username = I('post.username', '', 'op_t'); $aPassword = I('post.password', '', 'op_t'); $aVerify = I('post.verify', '', 'op_t'); $aRemember = I('post.remember', 0, 'intval'); /* 检测验证码 */ if (check_verify_open('login')) { if (!check_verify($aVerify)) { $res['info'] = L('_INFO_VERIFY_CODE_INPUT_ERROR_') . L('_PERIOD_'); return $res; } } /* 调用UC登录接口登录 */ check_username($aUsername, $email, $mobile, $aUnType); if (!check_reg_type($aUnType)) { $res['info'] = L('_INFO_TYPE_NOT_OPENED_') . L('_PERIOD_'); } $uid = UCenterMember()->login($username, $aPassword, $aUnType); if (0 < $uid) { //UC登录成功 /* 登录用户 */ $Member = D('Member'); $args['uid'] = $uid; $args = array('uid' => $uid, 'nickname' => $username); check_and_add($args); if ($Member->login($uid, $aRemember == 1)) { //登录用户 //TODO:跳转到登录前页面 $html_uc = ''; if (UC_SYNC && $uid != 1) { include_once './api/uc_client/client.php'; //同步登录到UC $ref = M('ucenter_user_link')->where(array('uid' => $uid))->find(); $html_uc = uc_user_synlogin($ref['uc_uid']); } $oc_config = (include_once './OcApi/oc_config.php'); if ($oc_config['SSO_SWITCH']) { include_once './OcApi/OCenter/OCenter.php'; $OCApi = new \OCApi(); $html_oc = $OCApi->ocSynLogin($uid); } $html = empty($html_oc) ? $html_uc : $html_oc; $res['status'] = 1; $res['info'] = $html; //$this->success($html, get_nav_url(C('AFTER_LOGIN_JUMP_URL'))); } else { $res['info'] = $Member->getError(); } } else { //登录失败 switch ($uid) { case -1: $res['info'] = L('_INFO_USER_FORBIDDEN_'); break; //系统级别禁用 //系统级别禁用 case -2: $res['info'] = L('_INFO_PW_ERROR_') . L('_EXCLAMATION_'); break; default: $res['info'] = $uid; break; // 0-接口参数错误(调试阶段使用) } } return $res; }
/** * register 注册页面 * @author:xjw129xjt(肖骏涛) xjt@ourstu.com */ public function register() { //获取参数 $aUsername = $username = I('post.username', '', 'op_t'); $aNickname = I('post.nickname', '', 'op_t'); $aPassword = I('post.password', '', 'op_t'); $aVerify = I('post.verify', '', 'op_t'); $aRegVerify = I('post.reg_verify', 0, 'intval'); $aRegType = I('post.reg_type', '', 'op_t'); $aStep = I('get.step', 'start', 'op_t'); $aRole = I('post.role', 0, 'intval'); if (!modC('REG_SWITCH', '', 'USERCONFIG')) { $this->error('注册已关闭'); } if (IS_POST) { //注册用户 $return = check_action_limit('reg', 'ucenter_member', 1, 1, true); if ($return && !$return['state']) { $this->error($return['info'], $return['url']); } /* 检测验证码 */ if (check_verify_open('reg')) { if (!check_verify($aVerify)) { $this->error('验证码输入错误。'); } } if (!$aRole) { $this->error('请选择角色。'); } if ($aRegType == 'mobile' && modC('MOBILE_VERIFY_TYPE', 0, 'USERCONFIG') == 1 || modC('EMAIL_VERIFY_TYPE', 0, 'USERCONFIG') == 2 && $aRegType == 'email') { if (!D('Verify')->checkVerify($aUsername, $aRegType, $aRegVerify, 0)) { $str = $aRegType == 'mobile' ? '手机' : '邮箱'; $this->error($str . '验证失败'); } } $aUnType = 0; //获取注册类型 check_username($aUsername, $email, $mobile, $aUnType); if ($aRegType == 'email' && $aUnType != 2) { $this->error('邮箱格式不正确'); } if ($aRegType == 'mobile' && $aUnType != 3) { $this->error('手机格式不正确'); } if ($aRegType == 'username' && $aUnType != 1) { $this->error('用户名格式不正确'); } if (!check_reg_type($aUnType)) { $this->error('该类型未开放注册。'); } /* 在第三方系统中注册用户*/ //演示call_api方法调用第三方restful api 接口示例 /* $res = call_api("http://api.demo.com/?m=conference&c=publisherapi&a=public_register&mobile=".$aMobile. "&code=".$aRegVerify."&username="******"&password="******"&sex=%E7%94%B7&email=".UCenterMember()->rand_email()); //注册 $res = json_decode($res[1],true); $token = $res['result']['token']; if($res['code'] == '200'){ $res['status'] = true; $res['info'] = "reg "; }else{ $this->error($res['code']); } */ $aCode = I('post.code', '', 'op_t'); if (!$this->checkInviteCode($aCode)) { $this->error('非法邀请码!'); } /* 注册用户 */ $uid = UCenterMember()->register($aUsername, $aNickname, $aPassword, $email, $mobile, $aUnType); if (0 < $uid) { //注册成功 $this->initInviteUser($uid, $aCode, $aRole); $this->initRoleUser($aRole, $uid); //初始化角色用户 if (modC('EMAIL_VERIFY_TYPE', 0, 'USERCONFIG') == 1 && $aUnType == 2) { set_user_status($uid, 3); $verify = D('Verify')->addVerify($email, 'email', $uid); $res = $this->sendActivateEmail($email, $verify, $uid); //发送激活邮件 // $this->success('注册成功,请登录邮箱进行激活'); } $uid = UCenterMember()->login($username, $aPassword, $aUnType); //通过账号密码取到uid D('Common/Member')->login($uid, false, $aRole); //登陆 $this->success('', U('Ucenter/member/step', array('step' => get_next_step('start')))); } else { //注册失败,显示错误信息 $this->error($this->showRegError($uid)); } } else { //显示注册表单 if (is_login()) { redirect(U(C('AFTER_LOGIN_JUMP_URL'))); } $this->checkRegisterType(); $aType = I('get.type', '', 'op_t'); $regSwitch = modC('REG_SWITCH', '', 'USERCONFIG'); $regSwitch = explode(',', $regSwitch); $this->assign('regSwitch', $regSwitch); $this->assign('step', $aStep); $this->assign('type', $aType == '' ? 'username' : $aType); $this->display(); } }
</div> <div class="form-group"> <div class="password_block" style="position: relative;display: table;border-collapse: separate;"> <input type="password" id="inputPassword" class="form-control" check-length="6,30" placeholder="请输入密码" name="password"> <div class="input-group-addon"> <a style="width: 100%;height: 100%" href="javascript:void(0);" onclick="change_show(this)">show</a> </div> </div> <span class="help-block">请输入密码</span> <div class="clearfix"></div> </div> <?php if (check_verify_open('reg')) { ?> <div class="form-group"> <label for="verifyCode" class=".sr-only col-xs-12" style="display: none"></label> <div class="col-xs-4" style="padding: 0px;"> <input type="text" id="verifyCode" class="form-control" placeholder="验证码" errormsg="请填写正确的验证码" nullmsg="请填写验证码" datatype="*5-5" name="verify"> <span class="help-block">输入验证码</span> </div> <div class="col-xs-8 lg_lf_fm_verify"> <img class="verifyimg reloadverify img-responsive" alt="点击切换" src="<?php echo U('verify'); ?>