4use \Bitrix\Main\Text\Encoding;
16 public static function checkDomain(
string $user,
string $password,
string $domain, ?
string &$error): ?bool
18 $domain = mb_strtolower($domain);
19 $domain = Encoding::convertEncoding($domain, SITE_CHARSET,
'UTF-8');
21 $result = \CMailRegru::checkDomain($user, $password, $domain, $error);
23 if ($result !==
false)
26 isset($result[
'domains'][0][
'dname']) &&
27 $result[
'domains'][0][
'dname'] == $domain
30 $result = $result[
'domains'][0];
31 if ($result[
'result'] ==
'Available')
35 else if ($result[
'error_code'] ==
'DOMAIN_ALREADY_EXISTS')
39 $error = $result[
'error_code'];
60 public static function suggestDomain(
string $user,
string $password,
string $word1,
string $word2, array $tlds, ?
string &$error): ?array
62 $word1 = Encoding::convertEncoding($word1, SITE_CHARSET,
'UTF-8');
63 $word2 = Encoding::convertEncoding($word2, SITE_CHARSET,
'UTF-8');
65 foreach ($tlds as &$v)
67 $v = Encoding::convertEncoding($v, SITE_CHARSET,
'UTF-8');
70 $result = \CMailRegru::suggestDomain($user, $password, $word1, $word2, $tlds, $error);
72 if ($result !==
false)
74 $suggestions = array();
75 if (!empty($result[
'suggestions']) && is_array($result[
'suggestions']))
77 foreach ($result[
'suggestions'] as $entry)
79 foreach ($entry[
'avail_in'] as $tlds)
81 $suggestions[] = Encoding::convertEncoding(
82 sprintf(
'%s.%s', $entry[
'name'], $tlds),
105 public static function createDomain(
string $user,
string $password,
string $domain, array $params, ?
string &$error): ?bool
107 $domain = mb_strtolower($domain);
108 $params = array_merge(
113 'ns0' =>
'ns1.reg.ru.',
114 'ns1' =>
'ns2.reg.ru.'
119 if (array_key_exists(
'ip', $params))
121 $params[
'enduser_ip'] = $params[
'ip'];
124 $domain = Encoding::convertEncoding($domain, SITE_CHARSET,
'UTF-8');
125 $params = Encoding::convertEncoding($params, SITE_CHARSET,
'UTF-8');
127 $result = \CMailRegru::createDomain($user, $password, $domain, $params, $error);
129 if ($result !==
false)
131 if (isset($result[
'dname']) && $result[
'dname'] == $domain)
137 $error = $result[
'error_code'] ??
'unknown';
152 public static function renewDomain(
string $user,
string $password,
string $domain, ?
string &$error): ?bool
154 $domain = Encoding::convertEncoding($domain, SITE_CHARSET,
'UTF-8');
155 $result = \CMailRegru::renewDomain($user, $password, $domain, [
'period' => 1], $error);
157 if ($result !==
false)
159 if (isset($result[
'dname']) && mb_strtolower($result[
'dname']) == mb_strtolower($domain))
181 public static function updateDns(
string $user,
string $password,
string $domain, array $params, ?
string &$error): ?bool
183 $domain = mb_strtolower($domain);
184 $domain = Encoding::convertEncoding($domain, SITE_CHARSET,
'UTF-8');
185 $params = Encoding::convertEncoding($params, SITE_CHARSET,
'UTF-8');
187 foreach ($params as $k => $record)
189 switch ($record[
'type'])
193 'action' =>
'add_alias',
195 'ipaddr' => $record[
'value']
200 'action' =>
'add_alias',
201 'subdomain' => $record[
'name'],
202 'ipaddr' => $record[
'value']
207 'action' =>
'add_cname',
208 'subdomain' => $record[
'name'],
209 'canonical_name' => $record[
'value']
214 'action' =>
'add_mx',
215 'subdomain' => $record[
'name'],
216 'mail_server' => $record[
'value'],
217 'priority' => $record[
'priority']
223 $result = \CMailRegru::updateDns($user, $password, $domain, $params, $error);
225 if ($result !==
false)
227 if (isset($result[
'dname']) && $result[
'dname'] == $domain)
229 if (isset($result[
'result']) && $result[
'result'] ==
'success')
235 $error = $result[
'error_code'] ??
'unknown';
254 public static function getDomainsList(
string $user,
string $password, ?
string &$error): ?array
256 $result = \CMailRegru::getDomainsList($user, $password, $error);
258 if ($result !==
false)
261 foreach ($result as $domain)
263 if (!empty($domain[
'dname']))
265 $list[$domain[
'dname']] = [
266 'domain_name' => $domain[
'dname'],
267 'creation_date' => $domain[
'creation_date'],
268 'expiration_date' => $domain[
'expiration_date'],
269 'status' => $domain[
'state']
static renewDomain(string $user, string $password, string $domain, ?string &$error)
static updateDns(string $user, string $password, string $domain, array $params, ?string &$error)
static suggestDomain(string $user, string $password, string $word1, string $word2, array $tlds, ?string &$error)
static checkDomain(string $user, string $password, string $domain, ?string &$error)
static createDomain(string $user, string $password, string $domain, array $params, ?string &$error)
static getDomainsList(string $user, string $password, ?string &$error)