src/Biz/System/Service/Impl/IpBlacklistServiceImpl.php

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

namespace Biz\System\Service\Impl;

use Biz\BaseService;
use Biz\System\Service\IpBlacklistService;

class IpBlacklistServiceImpl extends BaseService implements IpBlacklistService
{
    public function increaseIpFailedCount($ip)
    {
        $setting = $this->getSettingService()->get('login_bind', array());
        $setting = array_merge(array('temporary_lock_minutes' => 20), $setting);

        $existIp = $this->getIpBlacklistDao()->getByIpAndType($ip, 'failed');
        if (empty($existIp)) {
            $ip = array(
                'ip' => $ip,
                'type' => 'failed',
                'counter' => 1,
                'expiredTime' => time() + ($setting['temporary_lock_minutes'] * 60),
                'createdTime' => time(),
            );
            $ip = $this->getIpBlacklistDao()->create($ip);

            return $ip['counter'];
        }

        if ($this->isIpExpired($existIp)) {
            $this->getIpBlacklistDao()->delete($existIp['id']);

            $ip = array(
                'ip' => $ip,
                'type' => 'failed',
                'counter' => 1,
                'expiredTime' => time() + ($setting['temporary_lock_minutes'] * 60),
                'createdTime' => time(),
            );
            $ip = $this->getIpBlacklistDao()->create($ip);

            return $ip['counter'];
        }

        $this->getIpBlacklistDao()->wave(array($existIp['id']), array('counter' => 1));

        return $existIp['counter'] + 1;
    }

    public function getIpFailedCount($ip)
    {
        $ip = $this->getIpBlacklistDao()->getByIpAndType($ip, 'failed');
        if (empty($ip)) {
            return 0;
        }

        if ($this->isIpExpired($ip)) {
            $this->getIpBlacklistDao()->delete($ip['id']);

            return 0;
        }

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。