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/rospirotorg.ru/bitrix/modules/acrit.cleanmaster/classes/general/ |
Upload File : |
<?php use Acrit\Cleanmaster\Data\BitrixBlogCommentTable; class CCleanBlog { /** * удалять элементов за шаг */ const MESSAGE_PER_STEP = 10; public function GetStepCount() { return self::MESSAGE_PER_STEP; } public function MakeFilterArray($postSubstr, $author) { $arFilter = []; $postSubstr = trim($postSubstr); if ($postSubstr != '') { $arFilter['%=POST_TEXT'] = '%' . $postSubstr . '%'; } $author = trim($author); if ($author != '') { $arFilter['%=AUTHOR_NAME'] = '%' . $author . '%'; } return $arFilter; } /** * Получить кол-во спам-сообщений * * @param $postSubstr * @param $author * @return int */ public function GetCount($postSubstr, $author) { $arFilter = $this->MakeFilterArray($postSubstr, $author); $cnt = BitrixBlogCommentTable::getList([ 'select' => ['CNT'], 'runtime' => [ new \Bitrix\Main\Entity\ExpressionField('CNT', 'COUNT(*)') ], 'filter' => $arFilter, ])->fetch(); return $cnt['CNT']; } /** * Удаление комментариев * @param $postSubstr * @param $author * @param bool|int $noLimit = false * @return bool */ public function DeleteBlogMessageByFilter($postSubstr, $author, $noLimit = false) { $arFilter = $this->MakeFilterArray($postSubstr, $author); $params = [ 'order' => ['ID' => 'ASC'], 'select' => ['ID', 'AUTHOR_NAME', 'POST_TEXT'], 'filter' => $arFilter, 'limit' => self::MESSAGE_PER_STEP, // delete top items ]; if ($noLimit === true) { unset($params['limit']); } $rs = BitrixBlogCommentTable::getList($params); while ($ar = $rs->fetch()) { \CBlogComment::Delete($ar['ID']); } } public function GetExampleBlogMessageByFilter($postSubstr, $author) { $arFilter = $this->MakeFilterArray($postSubstr, $author); $rs = BitrixBlogCommentTable::getList([ 'order' => ['ID' => 'ASC'], 'select' => ['ID', 'AUTHOR_NAME', 'POST_TEXT'], 'filter' => $arFilter, 'limit' => 1, ]); return $rs->fetch(); } }