Authored by xiaowei

限制恶意登录注册

... ... @@ -101,8 +101,16 @@ class LoginController extends WebAction
$ip = Helpers::getClientIp();
$ipKey = md5('ip_signin_' . $ip);
$accountKey = md5('account_signin_' . $account);
$accountTimes = Cache::increment($accountKey, 1, 0, 1800);
$ipTimes = Cache::increment($ipKey, 1, 0, 3600);
if(!Cache::get($ipKey)){
Cache::set($ipKey, 0);
}
if(!Cache::get($accountKey)){
Cache::set($accountKey, 0);
}
Cache::increment($accountKey, 1, 0, 1800);
Cache::increment($ipKey, 1, 0, 3600);
$accountTimes = Cache::get($accountKey);
$ipTimes = Cache::get($ipKey);
if ($accountTimes > 10) {
$data = array('code' => 400, 'message' => '您输入的密码及账户名不匹配,是否忘记密码?', 'data' => '');
break;
... ...
... ... @@ -47,8 +47,11 @@ class RegisterController extends WebAction
$area = intval(trim($this->post('area'), ' '));
$ip = Helpers::getClientIp();
$data = array('code' => 400, 'message' => '', 'data' => '');
$ip_key = md5('ip_checkmobile_' . $ip);
$ip_times = Cache::increment($ip_key, 1, 0, 3600);
$ipKey = md5('ip_checkmobile_' . $ip);
if (!Cache::get($ipKey)) {
Cache::set($ipKey, 0);
}
$ipTimes = Cache::increment($ipKey, 1, 0, 3600);
do{
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
... ... @@ -59,7 +62,7 @@ class RegisterController extends WebAction
$data['message'] = '手机号码格式不正确';
break;
}
if ($ip_times >= 500) {
if ($ipTimes >= 500) {
$data['message'] = '由于你IP受限无法注册';
break;
}
... ...