11use Bitrix\Crm\WebForm;
32 ?
int $nextExecDelay =
null
35 if (!method_exists(__CLASS__, $funcName))
40 $funcName = self::createFunctionName($funcName,
$params);
42 $res = \CAgent::getList(
45 'MODULE_ID' =>
'landing',
53 \CAgent::addAgent($funcName,
59 \ConvertTimeStamp(time() + \CTimeZone::GetOffset() + $nextExecDelay,
"FULL"));
63 \CAgent::addAgent($funcName,
'landing',
'N',
$time);
73 if (!method_exists(__CLASS__, $funcName))
78 $funcName = self::createFunctionName($funcName,
$params);
79 $res = \CAgent::getList(
82 'MODULE_ID' =>
'landing',
86 if ($agent =
$res->fetch())
88 \CAgent::Delete((
int)$agent[
'ID']);
92 private static function createFunctionName(
string $funcName,
array $params = []): string
94 $funcName = __CLASS__ .
'::' . $funcName .
'(';
99 $funcName .= $value .
',';
101 elseif (is_string($value))
103 $funcName .=
'\'' . $value .
'\'' .
',';
106 $funcName = trim($funcName,
',');
123 $filterDomains = array_map(
function ($domain) {
124 return '%.' . $domain;
125 }, Domain::B24_DOMAINS);
128 $customDomainExist =
false;
129 $resDomain = Domain::getList([
131 'ID',
'DOMAIN',
'FAIL_COUNT',
134 '!DOMAIN' => $filterDomains,
138 'DATE_MODIFY' =>
'asc',
141 while ($domain = $resDomain->fetch())
143 $customDomainExist =
true;
146 Domain::update($domain[
'ID'], [
147 'FAIL_COUNT' =>
null,
153 if ($domain[
'FAIL_COUNT'] >= $maxFailCount - 1)
156 $resSite = Site::getList([
158 'ID',
'DOMAIN_ID',
'DOMAIN_NAME' =>
'DOMAIN.DOMAIN',
161 'DOMAIN_ID' => $domain[
'ID'],
164 if ($rowSite = $resSite->fetch())
166 Debug::log(
'removeBadDomain-randomizeDomain', var_export($rowSite,
true));
167 Site::randomizeDomain($rowSite[
'ID']);
178 Domain::update($domain[
'ID'], [
179 'FAIL_COUNT' => intval($domain[
'FAIL_COUNT']) + 1,
187 return $customDomainExist ? __CLASS__ .
'::' . __FUNCTION__ .
'();' :
'';
202 return __CLASS__ .
'::' . __FUNCTION__ .
'(\'' . $scope .
'\');
';
210 protected static function getSubFolders(int $folderId): array
213 $res = Folder::getList([
218 'PARENT_ID
' => $folderId,
221 while ($row = $res->fetch())
223 $folders[] = $row['ID
'];
224 $folders = array_merge($folders, self::getSubFolders($row['ID
']));
235 public static function clearRecycle(?int $days = null): string
237 Rights::setGlobalOff();
239 $days = !is_null($days)
241 : (int)Manager::getOption('deleted_lifetime_days
');
243 $date = new DateTime;
244 $date->add('-
' . $days . ' days
');
246 // check folders to delete
247 $foldersToDelete = [-1];
248 $res = Folder::getList([
254 '<DATE_MODIFY
' => $date,
257 while ($row = $res->fetch())
259 $foldersToDelete[] = $row['ID
'];
260 $foldersToDelete = array_merge($foldersToDelete, self::getSubFolders($row['ID
']));
263 // first delete landings
264 $res = Landing::getList([
273 '<DATE_MODIFY
' => $date,
276 '=SITE.DELETED
' => 'Y
',
277 '<SITE.DATE_MODIFY
' => $date,
280 'FOLDER_ID
' => $foldersToDelete,
283 '=DELETED
' => ['Y
', 'N
'],
284 '=SITE.DELETED
' => ['Y
', 'N
'],
285 'CHECK_PERMISSIONS
' => 'N
',
288 'DATE_MODIFY
' => 'desc
',
291 while ($row = $res->fetch())
293 Lock::lockDeleteLanding($row['ID
'], false);
294 Landing::delete($row['ID
'], true)->isSuccess();
298 foreach (array_unique($foldersToDelete) as $folderId)
302 Folder::delete($folderId)->isSuccess();
307 $res = Site::getList([
313 '<DATE_MODIFY
' => $date,
314 'CHECK_PERMISSIONS
' => 'N
',
317 'DATE_MODIFY
' => 'desc
',
320 while ($row = $res->fetch())
322 Lock::lockDeleteSite($row['ID
'], false);
323 Site::delete($row['ID
'])->isSuccess();
326 Rights::setGlobalOn();
328 return __CLASS__ . '::
' . __FUNCTION__ . '();
';
336 public static function clearFiles(?int $count = null): string
338 $count = !is_null($count) ? $count : 30;
340 File::deleteFinal($count);
342 return __CLASS__ . '::
' . __FUNCTION__ . '(
' . $count . ');
';
350 public static function clearHistory(?int $days = null): string
352 Rights::setGlobalOff();
354 $newAgentName = __CLASS__ . '::
' . __FUNCTION__ . '(
' . ($days ?? '') . ');
';
356 $days = $days ?: (int)Manager::getOption('history_lifetime_days
');
357 $date = new DateTime();
358 $date->add('-
' . $days . ' days
');
360 $rows = HistoryTable::query()
361 ->setSelect(['ENTITY_ID
', 'ENTITY_TYPE
'])
363 ->where('DATE_CREATE
', '<
', $date)
366 foreach ($rows as $row)
368 $history = new History($row['ENTITY_ID
'], $row['ENTITY_TYPE
']);
369 $history->clearOld($days);
372 return $newAgentName;
379 public static function sendRestStatistic(): string
382 \Bitrix\Main\Loader::includeModule('rest
')
387 \Bitrix\Landing\PublicAction::REST_USAGE_TYPE_BLOCK => 'LANDING_BLOCK
',
388 \Bitrix\Landing\PublicAction::REST_USAGE_TYPE_PAGE => 'LANDING_PAGE
',
390 $data = PublicAction::getRestStat(false, true);
391 foreach ($data as $type => $stat)
393 if ($statCode[$type])
395 foreach ($stat as $clientId => $count)
397 \Bitrix\Rest\UsageStatTable::logLanding($clientId, $statCode[$type], $count);
401 \Bitrix\Rest\UsageStatTable::finalize();
404 return __CLASS__ . '::
' . __FUNCTION__ . '();
';
411 public static function clearTempFiles(): string
413 $dateTime = new DateTime();
415 $res = Internals\FileTable::getList([
422 '<FILE.TIMESTAMP_X
' => $dateTime->add('-60 minute
'),
425 while ($row = $res->fetch())
427 Internals\FileTable::update($row['ID
'], [
428 'FILE_ID
' => -1 * $row['FILE_ID
'],
432 return __CLASS__ . '::
' . __FUNCTION__ . '();
';
440 public static function repairFormUrls(int $lastLid = 0): string
442 if (Loader::includeModule('crm
'))
444 $formQuery = WebForm\Internals\LandingTable::query()
445 ->addSelect('FORM_ID
')
446 ->addSelect('LANDING_ID
')
447 ->addOrder('LANDING_ID
')
449 ->where('LANDING_ID
', '>
', $lastLid)
453 while ($form = $formQuery->fetch())
455 $blocksQuery = BlockTable::query()
457 ->where('LID
', $form['LANDING_ID
'])
458 ->where('CODE
', '66.90.form_new_default
')
461 while ($block = $blocksQuery->fetch())
463 Subtype\Form::setFormIdToBlock($block['ID
'], $form['FORM_ID
']);
465 $lastLid = (int)$form['LANDING_ID
'];
470 return __CLASS__ . '::
' . __FUNCTION__ . '(
' . $lastLid . ');
';
482 public static function checkFileExists(int $fileId): string
484 $file = \CFile::getFileArray($fileId);
489 if (!$file['SRC
'] || !preg_match('#^(https?:
494 $request->query(HttpClient::HTTP_HEAD, $file[
'SRC']);
497 $filesToDelete = [$fileId];
501 'select' => [
'ORIGINAL_ID'],
503 'DUPLICATE_ID' => $fileId,
506 while ($original = $originals->fetch())
508 $filesToDelete[] = (int)$original[
'ORIGINAL_ID'];
512 'select' => [
'DUPLICATE_ID'],
514 'ORIGINAL_ID' => $filesToDelete,
517 while ($duplicate = $duplicates->fetch())
519 $filesToDelete[] = (int)$duplicate[
'DUPLICATE_ID'];
522 $filesToDelete = array_unique($filesToDelete);
525 $landingFiles = FileTable::getList([
526 'select' => [
'ID',
'ENTITY_ID'],
529 '=FILE_ID' => $filesToDelete,
532 $landingsToUpdate = [];
533 while ($landingFile = $landingFiles->fetch())
535 FileTable::delete((
int)$landingFile[
'ID']);
536 $landingsToUpdate[] = (int)$landingFile[
'ENTITY_ID'];
538 $landingsToUpdate = array_unique($landingsToUpdate);
544 'select' => [
'SITE_ID'],
546 '=ID' => $landingsToUpdate,
551 Site::update((
int)
$site[
'SITE_ID'], []);
555 foreach ($filesToDelete as $fileToDelete)
557 \CFile::delete($fileToDelete);
572 $landing = Landing::createInstance($landingId);
573 if ($landing->publication())
587 if ($generation->initById($generationId))
589 $generation->execute();
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
static clearRecycleScope(string $scope, ?int $days=null)
static deleteUniqueAgent(string $funcName, array $params=[])
static executeGeneration(int $generationId)
static rePublicationLanding($landingId)
static clearRecycle(?int $days=null)
static addUniqueAgent(string $funcName, array $params=[], int $time=7200, ?int $nextExecDelay=null)
static log($itemId, $itemDesc, $typeId='LANDING_LOG')
static isDomainActive(string $domainName)
static clearCacheForSite(int $siteId)
static setScope($scope, array $params=[])
static getList(array $parameters=array())
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']