Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
register.php
1<?php
3
4use \Bitrix\Landing\Manager;
5use \Bitrix\Main\Web\HttpClient;
6
8{
12 const B24_SERVICE_DETECT_IP = 'https://ip.bitrix24.site/getipforzone/?bx24_zone=';
13
17 const B24_SERVICE_DETECT_DOMAIN = 'https://ip.bitrix24.site/getdomainstatus/?bx24_site_domain=';
18
22 const B24_DEFAULT_DNS_IP = '52.59.124.117';
23
27 const B24_DEFAULT_DNS_CNAME = 'lb.bitrix24.site.';
28
33 public static function getInstance(): ?Provider
34 {
35 return new Provider\Bitrix24();
36 }
37
43 protected static function getINA(?string $tld = null): string
44 {
45 $http = new HttpClient;
46 $zone = ($tld == 'kz') ? 'kz' : Manager::getZone();
47 $ip = $http->get(self::B24_SERVICE_DETECT_IP . $zone);
48 $ip = \CUtil::jsObjectToPhp($ip);
49
50 return isset($ip['IP']) ? $ip['IP'] : self::B24_DEFAULT_DNS_IP;
51 }
52
58 public static function getDNSRecords(?string $tld = null): array
59 {
60 static $result = null;
61
62 if ($result !== null)
63 {
64 return $result;
65 }
66
67 $result = [
68 'INA' => self::getINA($tld),
70 ];
71
72 return $result;
73 }
74
80 public static function isDomainActive(string $domainName): bool
81 {
82 $http = new HttpClient;
83 $status = $http->get(self::B24_SERVICE_DETECT_DOMAIN . $domainName);
84 $status = \CUtil::jsObjectToPhp($status);
85 // protect from bad answer
86 if (!isset($status['status']))
87 {
88 return true;
89 }
90 return $status['status'] === 'ready';
91 }
92}
static getINA(?string $tld=null)
Definition register.php:43
static getDNSRecords(?string $tld=null)
Definition register.php:58
static isDomainActive(string $domainName)
Definition register.php:80