• Модуль: landing
  • Путь к файлу: ~/bitrix/modules/landing/lib/urlchecker.php
  • Класс: BitrixLandingUrlChecker
  • Вызов: UrlChecker::check
public function check(string $url): bool
{
	$url = mb_strtolower($url);
	$urlMd5 = md5(explode('//', $url)[1] ?? $url);
	$urlParts = parse_url($url);
	$domain = $urlParts['host'] ?? null;

	if (!$domain)
	{
		return true;
	}

	// check domain in white list
	$res = UrlCheckerWhitelistTable::getList([
		'filter' => [
			'=DOMAIN' => $domain
		],
		'limit' => 1
	]);
	if ($res->fetch())
	{
		return true;
	}

	// check exists url
	$res = UrlCheckerStatusTable::getList([
		'select' => [
			'ID', 'STATUS'
		],
		'filter' => [
			'=HASH' => $urlMd5
		]
	]);
	if ($row = $res->fetch())
	{
		if ($row['STATUS'])
		{
			$this->saveHost($row['ID']);
		}
		return !$row['STATUS'];
	}

	// new check
	$status = $this->getUrlStatus($url);
	$res = UrlCheckerStatusTable::add([
		'STATUS' => $status,
		'HASH' => $urlMd5,
		'URL' => $url
	]);
	// save host if status is bad
	if ($res->isSuccess() && $status)
	{
		$this->saveHost($res->getId());
	}

	return $status === null;
}