Server IP : 104.21.14.103 / Your IP : 18.116.42.136 Web Server : LiteSpeed System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : giankuin ( 1871) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/home/giankuin/thietke365.net/wp-content/plugins/mailpoet/lib/Subscribers/ |
Upload File : |
<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing namespace MailPoet\Subscribers; if (!defined('ABSPATH')) exit; use MailPoet\Doctrine\Repository; use MailPoet\Entities\SubscriberIPEntity; use MailPoetVendor\Carbon\Carbon; /** * @extends Repository<SubscriberIPEntity> */ class SubscriberIPsRepository extends Repository { protected function getEntityClassName() { return SubscriberIPEntity::class; } public function findOneByIPAndCreatedAtAfterTimeInSeconds(string $ip, int $seconds): ?SubscriberIPEntity { return $this->entityManager->createQueryBuilder() ->select('sip') ->from(SubscriberIPEntity::class, 'sip') ->where('sip.ip = :ip') ->andWhere('sip.createdAt >= :timeThreshold') ->setParameter('ip', $ip) ->setParameter('timeThreshold', (new Carbon())->subSeconds($seconds)) ->setMaxResults(1) ->getQuery() ->getOneOrNullResult(); } public function getCountByIPAndCreatedAtAfterTimeInSeconds(string $ip, int $seconds): int { return $this->entityManager->createQueryBuilder() ->select('COUNT(sip)') ->from(SubscriberIPEntity::class, 'sip') ->where('sip.ip = :ip') ->andWhere('sip.createdAt >= :timeThreshold') ->setParameter('ip', $ip) ->setParameter('timeThreshold', (new Carbon())->subSeconds($seconds)) ->getQuery() ->getSingleScalarResult(); } public function deleteCreatedAtBeforeTimeInSeconds(int $seconds): int { return (int)$this->entityManager->createQueryBuilder() ->delete() ->from(SubscriberIPEntity::class, 'sip') ->where('sip.createdAt < :timeThreshold') ->setParameter('timeThreshold', (new Carbon())->subSeconds($seconds)) ->getQuery() ->execute(); } }