Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
2
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
xiaowei
9 years ago
Commit
dd2f5daa6d29122c57d4b0161a42b347d5f3d12a
1 parent
246d28ea
防撞库
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
18 deletions
yohobuy/www.yohobuy.com/application/models/Passport/Passport.php
yohobuy/www.yohobuy.com/application/modules/Passport/controllers/Login.php
yohobuy/www.yohobuy.com/application/modules/Passport/controllers/Register.php
yohobuy/www.yohobuy.com/application/modules/Passport/controllers/Thirdlogin.php
yohobuy/www.yohobuy.com/application/models/Passport/Passport.php
View file @
dd2f5da
...
...
@@ -7,6 +7,7 @@ use LibModels\Web\Home\IndexData;
use
LibModels\Web\Home\UserData
;
use
WebPlugin\Images
;
use
WebPlugin\Captcha
;
use
WebPlugin\Cache
;
/**
* web登录注册等相关数据构建
...
...
@@ -134,4 +135,22 @@ class PassportModel
return
$ret
;
}
/*
* 重写递增计数 cache方法
* $key cache-key
* $offset 递增偏移量
* $initValue 初始化值
* $expiry 缓存时间
*/
public
static
function
increment
(
$key
,
$offset
=
1
,
$initValue
=
0
,
$expire
=
1800
)
{
//初始化key
if
(
!
Cache
::
get
(
$key
))
{
Cache
::
set
(
$key
,
$initValue
,
$expire
);
}
//增加偏移量
$cacheValue
=
intval
(
Cache
::
get
(
$key
))
+
$offset
;
Cache
::
set
(
$key
,
$cacheValue
,
$expire
);
}
}
...
...
yohobuy/www.yohobuy.com/application/modules/Passport/controllers/Login.php
View file @
dd2f5da
...
...
@@ -109,27 +109,22 @@ class LoginController extends WebAction
$ip
=
Helpers
::
getClientIp
();
$ipKey
=
md5
(
'ip_signin_'
.
$ip
);
$accountKey
=
md5
(
'account_signin_'
.
$account
);
if
(
!
Cache
::
get
(
$ipKey
))
{
Cache
::
set
(
$ipKey
,
0
);
}
if
(
!
Cache
::
get
(
$accountKey
))
{
Cache
::
set
(
$accountKey
,
0
);
}
Cache
::
increment
(
$ipKey
,
1
,
0
,
3600
);
PassportModel
::
increment
(
$ipKey
,
1
,
0
,
3600
);
$accountTimes
=
Cache
::
get
(
$accountKey
);
$ipTimes
=
Cache
::
get
(
$ipKey
);
if
(
$accountTimes
>
10
)
{
$data
=
array
(
'code'
=>
400
,
'message'
=>
'您的账号已被暂时锁定,请稍后再试'
,
'data'
=>
''
);
break
;
}
$ipTimes
=
Cache
::
get
(
$ipKey
);
if
(
$ipTimes
>
100
)
{
$data
=
array
(
'code'
=>
400
,
'message'
=>
'您尝试的次数过多,账号已被暂时锁定,请稍后再试'
,
'data'
=>
''
);
break
;
}
$data
=
LoginData
::
signin
(
$area
,
$account
,
$password
,
$shoppingKey
);
if
(
!
isset
(
$data
[
'code'
])
||
$data
[
'code'
]
!=
200
||
!
isset
(
$data
[
'data'
][
'uid'
]))
{
Cache
::
increment
(
$accountKey
,
1
,
0
,
1800
);
$data
=
array
(
'code'
=>
400
,
'message'
=>
'您输入的密码及账户名不匹配,是否<a href="'
.
Helpers
::
url
(
'/passport/back/index'
)
.
'" target="_blank">忘记密码?</a>'
,
'data'
=>
''
);
PassportModel
::
increment
(
$accountKey
,
1
,
0
,
1800
);
$data
=
array
(
'code'
=>
400
,
'message'
=>
'您输入的密码及账户名不匹配,是否<a href="'
.
Helpers
::
url
(
'/passport/back/index'
)
.
'" target="_blank">忘记密码?</a>'
,
'data'
=>
''
);
break
;
}
...
...
yohobuy/www.yohobuy.com/application/modules/Passport/controllers/Register.php
View file @
dd2f5da
...
...
@@ -48,10 +48,8 @@ class RegisterController extends WebAction
$ip
=
Helpers
::
getClientIp
();
$data
=
array
(
'code'
=>
400
,
'message'
=>
''
,
'data'
=>
''
);
$ipKey
=
md5
(
'ip_checkmobile_'
.
$ip
);
if
(
!
Cache
::
get
(
$ipKey
))
{
Cache
::
set
(
$ipKey
,
0
);
}
$ipTimes
=
Cache
::
increment
(
$ipKey
,
1
,
0
,
3600
);
PassportModel
::
increment
(
$ipKey
,
1
,
0
,
3600
);
$ipTimes
=
Cache
::
get
(
$ipKey
);
do
{
/* 判断是不是AJAX请求 */
if
(
!
$this
->
isAjax
())
{
...
...
@@ -132,10 +130,8 @@ class RegisterController extends WebAction
}
//发送代码
$sendCodeKey
=
md5
(
'send_code_'
.
$area
.
'_'
.
$mobile
);
if
(
!
Cache
::
get
(
$sendCodeKey
))
{
Cache
::
set
(
$sendCodeKey
,
0
);
}
$sendCodeTimes
=
Cache
::
increment
(
$sendCodeKey
,
1
,
0
,
3600
);
PassportModel
::
increment
(
$sendCodeKey
,
1
,
0
,
3600
);
$sendCodeTimes
=
Cache
::
get
(
$sendCodeKey
);
if
(
$sendCodeTimes
>
50
)
{
$data
[
'message'
]
=
'发送验证码太多'
;
break
;
...
...
yohobuy/www.yohobuy.com/application/modules/Passport/controllers/Thirdlogin.php
View file @
dd2f5da
...
...
@@ -25,6 +25,7 @@ class ThirdloginController extends WebAction
'openId'
=>
$openId
,
'sourceType'
=>
$sourceType
,
'region'
=>
RegData
::
getAreasData
(),
'serviceUrl'
=>
Helpers
::
url
(
'/help'
,
array
(
'category_id'
=>
9
))
);
$this
->
_view
->
display
(
'index'
,
$data
);
...
...
@@ -57,6 +58,7 @@ class ThirdloginController extends WebAction
* 绑定成功
*
*/
public
function
bindSuccessAction
()
{
...
...
Please
register
or
login
to post a comment