51 public static function add(array $fields)
54 $error = new \Bitrix\Landing\Error;
56 $res = DomainCore::add($fields);
58 if ($res->isSuccess())
60 $result->setResult($res->getId());
64 $error->addFromResult($res);
65 $result->setError($error);
143 public static function check($domain, array $filter = [])
147 if (!is_string($domain))
152 $puny = new \CBXPunycode;
153 $domainOrig = $domain;
154 $domain = $puny->encode(trim($domain));
155 $tld = DomainCore::getTLD($domain);
162 'length' => mb_strlen($domain),
163 'limit' => self::DOMAIN_MAX_LENGTH,
170 if (mb_strlen($domain) > self::DOMAIN_MAX_LENGTH)
172 $return[
'errors'][
'wrongLength'] =
true;
174 if (!preg_match(self::DOMAIN_SYMBOLS_REGEXP, $domain))
176 $return[
'errors'][
'wrongSymbols'] =
true;
178 if (preg_match(self::DOMAIN_WRONG_SYMBOLS_REGEXP, $domainOrig))
180 $return[
'errors'][
'wrongSymbolCombination'] =
true;
182 if (strpos($domain,
'.') ===
false)
184 $return[
'errors'][
'wrongDomainLevel'] =
true;
186 if (is_array($return[
'errors']))
188 $return[
'available'] =
false;
189 $result->setResult($return);
195 if (!is_array($filter))
199 $filter[
'=DOMAIN'] = $return[
'domain'];
202 $res = DomainCore::getList([
208 $return[
'available'] = !($domainRow = $res->fetch());
211 if (!$return[
'available'])
213 $resSite = Site::getList(array(
218 'DOMAIN_ID' => $domainRow[
'ID'],
220 'CHECK_PERMISSIONS' =>
'N'
223 if ($resSite->fetch())
225 $return[
'available'] =
false;
226 $return[
'deleted'] =
true;
232 $return[
'available'] &&
243 $domainName = $return[
'domain'];
245 $isOnlineSite = str_ends_with($domainName,
'.b24site.online');
246 $isOnlineShop = str_ends_with($domainName,
'.b24shop.online');
249 $byDomainName = str_replace(
'.b24site.online',
'.bitrix24site.by', $domainName);
253 $byDomainName = str_replace(
'.b24shop.online',
'.bitrix24shop.by', $domainName);
255 $checkResult = $siteController::isDomainExists(
258 if ($byDomainName ===
'')
260 $return[
'available'] = $checkResult < 2;
264 $checkResultBy = $siteController::isDomainExists(
267 $return[
'available'] = $checkResult < 2 && $checkResultBy < 2;
277 $result->setResult($return);
290 $domainName = trim($domainName);
298 if ($regInstance && !$regInstance->enable())
300 $result->setResult($return);
305 $res = DomainCore::getList([
310 '=DOMAIN' => $domainName
315 $return[
'enable'] = $regInstance->isEnableForRegistration($domainName);
319 if (!$return[
'enable'])
321 $return[
'suggest'] = $regInstance->getSuggestedDomains($domainName, $tld);
324 $result->setResult($return);