Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/burlakastudio.realcommenter/lib/ |
Upload File : |
<?php /** * ����� "��������� ����������� D7" ��� ������� * �������� ���� �����: www.realcommenter.com * �������� ���� �����������: burlaka.studio * ����� � ����������: ������� ������� (AlexeyGfi) -> alexeygfi@gmail.com */ namespace Burlakastudio\Realcommenter; use Bitrix\Main\Type\DateTime; class SanctionsAgent { protected static $agentName = '\Burlakastudio\Realcommenter\SanctionsAgent::checkSanctionsFadeOut();'; /** * ���� ������� �������������� � ����� �����������, * ������ �� �����. * ...���� �� ������ �� */ public static function agentCpu() { if (Sanctions::inUse()) { if (!self::getAgent()) { self::addAgent(); } } else if (self::getAgent()) { self::deleteAgent(); } } private static function getAgent() { $agentsRes = \CAgent::GetList( [], [ 'MODULE_ID' => TOOLS::getModuleName(), 'NAME' => self::$agentName // TODO: ����� �������� ] ); if ($agentArr = $agentsRes->Fetch()) { return $agentArr; } return null; } private static function addAgent() { $arFields = [ 'NAME' => self::$agentName, 'MODULE_ID' => TOOLS::getModuleName(), 'ACTIVE' => 'Y', 'IS_PERIOD' => 'N', 'AGENT_INTERVAL' => '86400', 'NEXT_EXEC' => (new DateTime())->add('-1 hour'), ]; $agentRes = \CAgent::Add($arFields); if (!$agentRes) { global $DB; \CEventLog::Log( 'ERROR', 'RealcommenterSanctionsError', TOOLS::getModuleName(), '', 'ERROR: ' . $DB->db_Error . "\nSQL: " . $DB->db_ErrorSQL ); return false; } return $agentRes; } private static function deleteAgent(): bool { $agentArr = self::getAgent(); if (!$agentArr) { return true; } return \CAgent::Delete($agentArr['ID']); } public static function checkSanctionsFadeOut() { /** * (!) ���� ������� ������������� -- ������ ������ (������) * * ������ �������� � �� �� ���� �������������� * ������ �������� � �� �� ���� ����� * * ...������ ������ (�� ����� ��), ����: * - �������������� ��� ���� ��� * - ���� ��������� ��������� */ if (!Sanctions::inUse()) { self::agentCpu(); return ''; } $warningDropDaysPeriod = intval(OPTIONS::get('warningDropDaysPeriod')); if ($warningDropDaysPeriod) { $warningOlderThan = new DateTime(); $warningOlderThan->add("-{$warningDropDaysPeriod} days"); $result = Sanctions::getListEx([ 'filter' => [ '>UF_WARNINGS' => 0, '!UF_USER_ID' => 0, '<UF_DATE_MODIFY' => $warningOlderThan ] ]); foreach($result as $res) { // ���� ���������� ����������, �������� �� Sanctions::skipWarning($res['UF_USER_ID']); } } $banDropDaysPeriod = intval(OPTIONS::get('banDropDaysPeriod')); if ($banDropDaysPeriod) { $banOlderThan = new DateTime(); $banOlderThan->add("-{$banDropDaysPeriod} days"); $result = Sanctions::getListEx([ 'filter' => [ '>UF_BAN' => 0, '!UF_USER_ID' => 0, '<UF_DATE_MODIFY' => $banOlderThan ] ]); foreach($result as $res) { // ���� ���������� ����������, �������� �� Sanctions::dropTheBan($res['UF_USER_ID']); } } return self::$agentName; } }