55 $http->
setHeader(
'x-apikey', $this->apiKey);
56 $res = Json::decode($http->post(self::EXTERNAL_CHECKER_URL_LOAD_URL, [
59 if (!isset($res[
'error']) && $res[
'data'] && $res[
'data'][
'id'])
61 $resAnalysis = Json::decode($http->get(self::EXTERNAL_CHECKER_URL_GET_ANALYSE . $res[
'data'][
'id']));
62 if (isset($resAnalysis[
'error']))
65 return $res[
'error'][
'status'];
68 self::STATUS_KEY_GOOD => $resAnalysis[
'data'][
'attributes'][
'stats'][self::STATUS_KEY_GOOD],
69 self::STATUS_KEY_AVERAGE => $resAnalysis[
'data'][
'attributes'][
'stats'][self::STATUS_KEY_AVERAGE],
70 self::STATUS_KEY_BAD => $resAnalysis[
'data'][
'attributes'][
'stats'][self::STATUS_KEY_BAD],
74 $total = $stats[self::STATUS_KEY_GOOD] + $stats[self::STATUS_KEY_AVERAGE] + $stats[self::STATUS_KEY_BAD];
76 $stats[self::STATUS_KEY_BAD] === 0
77 && $stats[self::STATUS_KEY_AVERAGE] <= $total * self::AVERAGE_STATUS_PERCENT * 0.01
84 self::STATUS_KEY_GOOD .
':' . $stats[self::STATUS_KEY_GOOD]
85 .
'_' . self::STATUS_KEY_AVERAGE .
':' . $stats[self::STATUS_KEY_AVERAGE]
86 .
'_' . self::STATUS_KEY_BAD .
':' . $stats[self::STATUS_KEY_BAD];
89 catch (\Exception $e){}
132 public function check(
string $url): bool
134 $url = mb_strtolower($url);
135 $urlMd5 = md5(explode(
'//', $url)[1] ?? $url);
136 $urlParts = parse_url($url);
137 $domain = $urlParts[
'host'] ??
null;
145 $res = UrlCheckerWhitelistTable::getList([
157 $res = UrlCheckerStatusTable::getList([
165 if ($row = $res->fetch())
171 return !$row[
'STATUS'];
176 $res = UrlCheckerStatusTable::add([
182 if ($res->isSuccess() && $status)
187 return $status ===
null;