31 ?
int $nextExecDelay =
null
34 if (!method_exists(__CLASS__, $funcName))
39 $funcName = __CLASS__ .
'::' . $funcName .
'(';
40 foreach ($params as $value)
44 $funcName .= $value .
',';
46 else if (is_string($value))
48 $funcName .=
'\'' . $value .
'\'' .
',';
51 $funcName = trim($funcName,
',');
53 $res = \CAgent::getList(
56 'MODULE_ID' =>
'landing',
64 \CAgent::addAgent($funcName,
70 \ConvertTimeStamp(time() + \CTimeZone::GetOffset() + $nextExecDelay,
"FULL"));
74 \CAgent::addAgent($funcName,
'landing',
'N', $time);
90 $filterDomains = array_map(
function($domain)
92 return '%.' . $domain;
93 }, Domain::B24_DOMAINS);
96 $customDomainExist =
false;
97 $resDomain = Domain::getList([
99 'ID',
'DOMAIN',
'FAIL_COUNT'
102 '!DOMAIN' => $filterDomains
106 'DATE_MODIFY' =>
'asc'
109 while ($domain = $resDomain->fetch())
111 $customDomainExist =
true;
114 Domain::update($domain[
'ID'], [
121 if ($domain[
'FAIL_COUNT'] >= $maxFailCount - 1)
124 $resSite = Site::getList([
126 'ID',
'DOMAIN_ID',
'DOMAIN_NAME' =>
'DOMAIN.DOMAIN'
129 'DOMAIN_ID' => $domain[
'ID']
132 if ($rowSite = $resSite->fetch())
134 Debug::log(
'removeBadDomain-randomizeDomain', var_export($rowSite,
true));
135 Site::randomizeDomain($rowSite[
'ID']);
146 Domain::update($domain[
'ID'], [
147 'FAIL_COUNT' => intval($domain[
'FAIL_COUNT']) + 1
155 return $customDomainExist ? __CLASS__ .
'::' . __FUNCTION__ .
'();' :
'';
449 public static function checkFileExists(int $fileId): string
451 $file = \CFile::getFileArray($fileId);
456 if (!$file['SRC
'] || !preg_match('#^(https?:
460 $request =
new HttpClient([
"redirect" =>
false,]);
461 $request->query(HttpClient::HTTP_HEAD, $file[
'SRC']);
462 if ($request->getStatus() !== 200)
464 $filesToDelete = [$fileId];
468 'select' => [
'ORIGINAL_ID'],
470 'DUPLICATE_ID' => $fileId,
473 while ($original = $originals->fetch())
475 $filesToDelete[] = (int)$original[
'ORIGINAL_ID'];
479 'select' => [
'DUPLICATE_ID'],
481 'ORIGINAL_ID' => $filesToDelete,
484 while ($duplicate = $duplicates->fetch())
486 $filesToDelete[] = (int)$duplicate[
'DUPLICATE_ID'];
489 $filesToDelete = array_unique($filesToDelete);
492 $landingFiles = FileTable::getList([
493 'select' => [
'ID',
'ENTITY_ID'],
496 '=FILE_ID' => $filesToDelete,
499 $landingsToUpdate = [];
500 while ($landingFile = $landingFiles->fetch())
502 FileTable::delete((
int)$landingFile[
'ID']);
503 $landingsToUpdate[] = (int)$landingFile[
'ENTITY_ID'];
505 $landingsToUpdate = array_unique($landingsToUpdate);
511 'select' => [
'SITE_ID'],
513 '=ID' => $landingsToUpdate,
516 while ($site = $sites->fetch())
518 Site::update((
int)$site[
'SITE_ID'], []);
522 foreach ($filesToDelete as $fileToDelete)
524 \CFile::delete($fileToDelete);