Showing
2 changed files
with
16 additions
and
5 deletions
@@ -101,8 +101,16 @@ class LoginController extends WebAction | @@ -101,8 +101,16 @@ class LoginController extends WebAction | ||
101 | $ip = Helpers::getClientIp(); | 101 | $ip = Helpers::getClientIp(); |
102 | $ipKey = md5('ip_signin_' . $ip); | 102 | $ipKey = md5('ip_signin_' . $ip); |
103 | $accountKey = md5('account_signin_' . $account); | 103 | $accountKey = md5('account_signin_' . $account); |
104 | - $accountTimes = Cache::increment($accountKey, 1, 0, 1800); | ||
105 | - $ipTimes = Cache::increment($ipKey, 1, 0, 3600); | 104 | + if(!Cache::get($ipKey)){ |
105 | + Cache::set($ipKey, 0); | ||
106 | + } | ||
107 | + if(!Cache::get($accountKey)){ | ||
108 | + Cache::set($accountKey, 0); | ||
109 | + } | ||
110 | + Cache::increment($accountKey, 1, 0, 1800); | ||
111 | + Cache::increment($ipKey, 1, 0, 3600); | ||
112 | + $accountTimes = Cache::get($accountKey); | ||
113 | + $ipTimes = Cache::get($ipKey); | ||
106 | if ($accountTimes > 10) { | 114 | if ($accountTimes > 10) { |
107 | $data = array('code' => 400, 'message' => '您输入的密码及账户名不匹配,是否忘记密码?', 'data' => ''); | 115 | $data = array('code' => 400, 'message' => '您输入的密码及账户名不匹配,是否忘记密码?', 'data' => ''); |
108 | break; | 116 | break; |
@@ -47,8 +47,11 @@ class RegisterController extends WebAction | @@ -47,8 +47,11 @@ class RegisterController extends WebAction | ||
47 | $area = intval(trim($this->post('area'), ' ')); | 47 | $area = intval(trim($this->post('area'), ' ')); |
48 | $ip = Helpers::getClientIp(); | 48 | $ip = Helpers::getClientIp(); |
49 | $data = array('code' => 400, 'message' => '', 'data' => ''); | 49 | $data = array('code' => 400, 'message' => '', 'data' => ''); |
50 | - $ip_key = md5('ip_checkmobile_' . $ip); | ||
51 | - $ip_times = Cache::increment($ip_key, 1, 0, 3600); | 50 | + $ipKey = md5('ip_checkmobile_' . $ip); |
51 | + if (!Cache::get($ipKey)) { | ||
52 | + Cache::set($ipKey, 0); | ||
53 | + } | ||
54 | + $ipTimes = Cache::increment($ipKey, 1, 0, 3600); | ||
52 | do{ | 55 | do{ |
53 | /* 判断是不是AJAX请求 */ | 56 | /* 判断是不是AJAX请求 */ |
54 | if (!$this->isAjax()) { | 57 | if (!$this->isAjax()) { |
@@ -59,7 +62,7 @@ class RegisterController extends WebAction | @@ -59,7 +62,7 @@ class RegisterController extends WebAction | ||
59 | $data['message'] = '手机号码格式不正确'; | 62 | $data['message'] = '手机号码格式不正确'; |
60 | break; | 63 | break; |
61 | } | 64 | } |
62 | - if ($ip_times >= 500) { | 65 | + if ($ipTimes >= 500) { |
63 | $data['message'] = '由于你IP受限无法注册'; | 66 | $data['message'] = '由于你IP受限无法注册'; |
64 | break; | 67 | break; |
65 | } | 68 | } |
-
Please register or login to post a comment