本文整理汇总了PHP中check_action_limit函数的典型用法代码示例。如果您正苦于以下问题:PHP check_action_limit函数的具体用法?PHP check_action_limit怎么用?PHP check_action_limit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_action_limit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: msave
public function msave()
{
$uid = I('create_user_id');
$return = check_action_limit('commentgg_msave', 'Commentgg', $uid, $uid);
if ($return && !$return['state']) {
return $return['info'];
}
$commentgg = D('Common/Commentgg');
$tjnotice = D('Tjnotice');
$user = D('Common/User');
$data = date("Y-m-d H:i:s");
$comment['create_date'] = $data;
$comment['content'] = I('content');
if (transgress_keyword(I('content'))) {
$mr['result'] = '1';
$mr['message'] = '请修改一下评论内容!';
$this->ajaxReturn($mr);
}
$comment['content_id'] = I('content_id');
$comment['create_user_id'] = I('create_user_id');
$comment['rid'] = I('rid');
$rid = I('rid');
if ($rid) {
$comment['type'] = 2;
$ruid = $commentgg->findFieldById($rid, 'create_user_id');
} else {
$comment['type'] = 1;
}
$nid = $commentgg->add($comment);
$tjnotice->addcits($nid);
$data = $commentgg->find($nid);
$data['createUser'] = $user->find($data['create_user_id']);
if ($data['rid']) {
$ee = $commentgg->find($data['rid']);
$data['replyUser'] = $user->find($ee['create_user_id']);
}
$data['result'] = '0';
$data['message'] = '评论成功';
action_log('commentgg_msave', 'commentgg', $uid, $uid);
$this->ajaxReturn($data);
}
示例2: checkActionLimit
/**
* check_action_limit 行为限制
* @param null $action
* @param null $model
* @param null $record_id
* @param null $user_id
* @param bool $ip
* @author 郑钟良<zzl@ourstu.com>
*/
public function checkActionLimit($action = null, $model = null, $record_id = null, $user_id = null, $ip = false, $url = false)
{
$return = check_action_limit($action, $model, $record_id, $user_id, $ip);
if ($return && !$return['state']) {
if ($url === true) {
$url = $return['url'];
} elseif ($url === false) {
$url = '';
}
$this->error($return['info'], $url);
}
}
示例3: login
/**
* 用户登录认证
* @param string $username 用户名
* @param string $password 用户密码
* @param integer $type 用户名类型 (1-用户名,2-邮箱,3-手机,4-UID)
* @return integer 登录成功-用户ID,登录失败-错误编号
*/
public function login($username, $password, $type = 1)
{
if (UC_SYNC && $username != get_username(1) && $type == 1) {
return $this->ucLogin($username, $password);
}
$map = array();
switch ($type) {
case 1:
$map['username'] = $username;
break;
case 2:
$map['email'] = $username;
break;
case 3:
$map['mobile'] = $username;
break;
case 4:
$map['id'] = $username;
break;
default:
return 0;
//参数错误
}
/* 获取用户数据 */
$user = $this->where($map)->find();
$return = check_action_limit('input_password', 'ucenter_member', $user['id'], $user['id']);
if ($return && !$return['state']) {
return $return['info'];
}
if (is_array($user) && $user['status']) {
/* 验证用户密码 */
if (think_ucenter_md5($password, UC_AUTH_KEY) === $user['password']) {
$this->updateLogin($user['id']);
//更新用户登录信息
return $user['id'];
//登录成功,返回用户ID
} else {
action_log('input_password', 'ucenter_member', $user['id'], $user['id']);
return -2;
//密码错误
}
} else {
return -1;
//用户不存在或被禁用
}
}
示例4: register
/**
* 注册页
*/
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('非法邀请码!');
}
/* 注册用户 */
//.........这里部分代码省略.........
示例5: register
/**
* 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));
//.........这里部分代码省略.........
示例6: newAccount
public function newAccount()
{
$aUsername = I('post.username');
$aNickname = I('post.nickname');
$aPassword = I('post.password');
// 行为限制
$return = check_action_limit('reg', 'ucenter_member', 1, 1, true);
if ($return && !$return['state']) {
$this->error($return['info'], $return['url']);
}
$ucenterModel = UCenterMember();
$uid = $ucenterModel->register($aUsername, $aNickname, $aPassword);
if (0 < $uid) {
//注册成功
$this->addSyncLoginData($uid);
$this->initRoleUser(1, $uid);
//初始化角色用户
$uid = $ucenterModel->login($aUsername, $aPassword, 1);
//通过账号密码取到uid
$this->doLogin($uid);
$this->success('绑定成功!', session('login_http_referer'));
} else {
//注册失败,显示错误信息
$this->error(A('Ucenter/Member')->showRegError($uid));
}
}
示例7: doComment
/**
* doComment 发布评论
* @author:xjw129xjt(肖骏涛) xjt@ourstu.com
*/
public function doComment()
{
$this->checkIsLogin();
$aWeiboId = I('post.weibo_id', 0, 'intval');
$aContent = I('post.content', 0, 'op_t');
$aCommentId = I('post.comment_id', 0, 'intval');
$this->checkAuth(null, -1, L('_INFO_AUTHORITY_COMMENT_LACK_') . L('_PERIOD_'));
$return = check_action_limit('add_weibo_comment', 'weibo_comment', 0, is_login(), true);
if ($return && !$return['state']) {
$this->error($return['info']);
}
if (empty($aContent)) {
$this->error(L('_ERROR_CONTENT_CANNOT_EMPTY_'));
}
//发送评论
$result['data'] = send_comment($aWeiboId, $aContent, $aCommentId);
$result['html'] = R('Comment/comment_html', array('comment_id' => $result['data']), 'Widget');
$result['status'] = 1;
$result['info'] = L('_SUCCESS_COMMENT_') . L('_EXCLAMATION_') . cookie('score_tip');
//返回成功结果
$this->ajaxReturn($result);
}
示例8: register
/**
* 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();
}
}
示例9: register
/**
* 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);
//.........这里部分代码省略.........
示例10: doComment
/**
* doComment 发布评论
* @author:xjw129xjt(肖骏涛) xjt@ourstu.com
*/
public function doComment()
{
$this->checkIsLogin();
$aWeiboId = I('post.weibo_id', 0, 'intval');
$aContent = I('post.content', 0, 'op_t');
$aCommentId = I('post.comment_id', 0, 'intval');
$this->checkAuth(null, -1, '您无微博发布评论权限。');
$return = check_action_limit('add_weibo_comment', 'weibo_comment', 0, is_login(), true);
if ($return && !$return['state']) {
$this->error($return['info']);
}
if (empty($aContent)) {
$this->error('内容不能为空');
}
//发送评论
$result['data'] = send_comment($aWeiboId, $aContent, $aCommentId);
$result['html'] = R('Comment/comment_html', array('comment_id' => $result['data']), 'Widget');
$result['status'] = 1;
$result['info'] = '评论成功!' . cookie('score_tip');
//返回成功结果
$this->ajaxReturn($result);
}
示例11: doAddComment
/**
* 增加评论实现
*/
public function doAddComment()
{
if (!is_login()) {
$this->error('请您先登录', U('Mob/member/index'), 1);
}
$aContent = I('post.weibocontent', '', 'op_t');
//说点什么的内容
$aWeiboId = I('post.weiboId', 0, 'intval');
//要评论的微博的ID
$aCommentId = I('post.comment_id', 0, 'intval');
if (empty($aContent)) {
$this->error('评论内容不能为空。');
}
$this->checkAuth('Weibo/Index/doComment', -1, '您无微博评论权限。');
$return = check_action_limit('add_weibo_comment', 'weibo_comment', 0, is_login(), true);
//行为限制
if ($return && !$return['state']) {
$this->error($return['info']);
}
$new_id = send_comment($aWeiboId, $aContent, $aCommentId);
//发布评论
$weibocomment = D('WeiboComment')->where(array('status' => 1, 'id' => $new_id))->order('create_time desc')->select();
foreach ($weibocomment as &$k) {
$k['user'] = query_user(array('nickname', 'avatar32', 'uid'), $k['uid']);
$k['rand_title'] = mob_get_head_title($k['uid']);
$k['content'] = parse_weibo_mobile_content($k['content']);
}
if ($weibocomment) {
$data['html'] = "";
foreach ($weibocomment as $val) {
$this->assign("vl", $val);
$data['html'] .= $this->fetch("_weibocomment");
$data['status'] = 1;
}
} else {
$data['stutus'] = 0;
}
$this->ajaxReturn($data);
}
示例12: check_action_limit
/**
* check_action_limit 行为限制
* @param null $action
* @param null $model
* @param null $record_id
* @param null $user_id
* @param bool $ip
* @author 郑钟良<zzl@ourstu.com>
*/
public function check_action_limit($action = null, $model = null, $record_id = null, $user_id = null, $ip = false)
{
$return = check_action_limit($action, $model, $record_id, $user_id, $ip);
if ($return && !$return['state']) {
$this->error($return['info'], $return['url']);
}
}
示例13: register
/**
* 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();
}
}
示例14: register
public function register()
{
if (!modC('REG_SWITCH', '', 'USERCONFIG')) {
$this->apiError('注册已关闭');
}
//获取参数
$aUsername = $username = I('username', '', 'op_t');
$aNickname = I('nickname', '', 'op_t');
$aPassword = I('password', '', 'op_t');
$aVerify = I('verify', '', 'op_t');
$aRegVerify = I('reg_verify', 0, 'intval');
$aRegType = I('reg_type', '', 'op_t');
$aRole = I('role', '', 'op_t');
$aType = I('type', '', 'op_t');
//注册用户
$return = check_action_limit('reg', 'ucenter_member', 1, 1, true);
if ($return && !$return['state']) {
$this->apiError($return['info']);
}
/* 检测验证码 */
if (check_verify_open('reg')) {
if (!check_verify($aVerify)) {
$this->apiError('验证码输入错误。');
}
}
if (!$aRole) {
$this->apiError('请选择角色。');
}
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->apiError($str . '验证失败');
}
}
$aUnType = 0;
//获取注册类型
check_username($aUsername, $email, $mobile, $aUnType);
if ($aRegType == 'email' && $aUnType != 2) {
$this->apiError('邮箱格式不正确');
}
if ($aRegType == 'mobile' && $aUnType != 3) {
$this->apiError('手机格式不正确');
}
if ($aRegType == 'username' && $aUnType != 1) {
$this->apiError('用户名格式不正确');
}
if (!check_reg_type($aUnType)) {
$this->apiError('该类型未开放注册。');
}
$aCode = I('post.code', '', 'op_t');
if (!$this->checkInviteCode($aCode)) {
$this->apiError('非法邀请码!');
}
/* 注册用户 */
$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);
dump($verify);
$res = $this->sendActivateEmail($email, $verify, $uid);
//发送激活邮件
$this->apiSuccess('注册成功,请登录邮箱进行激活');
}
$uid = UCenterMember()->login($username, $aPassword, $aUnType);
//通过账号密码取到uid
D('Member')->login($uid, false, $aRole);
//登陆
$this->apiSuccess('注册成功,并登陆');
} else {
//注册失败,显示错误信息
$this->apiError($this->showRegError($uid));
}
}
示例15: login
/**
* 登录指定用户
* @param integer $uid 用户UID
* @param string $mobile 用户名
* @param string $password 用户密码
* @param bool $remember
* @param int $role_id 有值代表强制登录这个角色
* @return boolean ture-登录成功,false-登录失败
*/
public function login($uid, $mobile = '', $password = '', $remember = false, $role_id = 0)
{
/* 检测是否在当前应用注册 */
$map['uid'] = $uid;
$map['mobile'] = $mobile;
/* 获取用户数据 */
$user = $this->where($map)->find();
if ($role_id != 0) {
$user['last_login_role'] = $role_id;
} else {
if (!intval($user['last_login_role'])) {
$user['last_login_role'] = $user['show_role'];
}
}
$return = check_action_limit('input_password', 'ucuser', $user['uid'], $user['uid']);
if ($return && !$return['state']) {
return $return['info'];
}
if (is_array($user) && $user['status']) {
/* 验证用户密码 */
if (think_ucenter_md5($password, UC_AUTH_KEY) === $user['password']) {
$this->updateLogin($user['uid']);
//更新用户登录信息
return $user['uid'];
//登录成功,返回用户UID
} else {
return -2;
//密码错误
}
} else {
return -1;
//用户不存在或被禁用
}
//以下程序运行不到
session('temp_login_uid', $uid);
session('temp_login_role_id', $user['last_login_role']);
if ($user['status'] == 3) {
header('Content-Type:application/json; charset=utf-8');
$data['status'] = 1;
$data['url'] = U('Ucuser/Ucuser/activate');
exit(json_encode($data));
}
if (1 > $user['status']) {
$this->error = '用户未激活或已禁用!';
//应用级别禁用
return false;
}
/* 登录用户 */
$this->autoLogin($user, $remember);
session('temp_login_uid', null);
session('temp_login_role_id', null);
return true;
}