1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
domain.php
См. документацию.
1
<?php
2
namespace
Bitrix\Landing;
3
4
use \Bitrix\Main\Config\Option;
5
use \Bitrix\Main\Context;
6
use \Bitrix\Main\Web\Uri;
7
8
class
Domain
extends
\Bitrix\Landing\Internals\BaseTable
9
{
14
const
B24_DOMAINS
= [
15
'bitrix24.site'
,
16
'bitrix24.shop'
,
17
'bitrix24site.by'
,
18
'bitrix24shop.by'
,
19
'bitrix24site.ua'
,
20
'bitrix24site.ru'
,
21
'bitrix24shop.ru'
,
22
'b24site.online'
,
23
'b24shop.online'
,
24
];
25
30
public
static
$internalClass
=
'DomainTable'
;
31
36
protected
static
function
getDomainName
()
37
{
38
static
$domain =
null
;
39
40
if
(!$domain)
41
{
42
$context
=
\Bitrix\Main\Application::getInstance
()->getContext();
43
$server =
$context
->getServer();
44
$domain = $server->getServerName();
45
if
(!$domain)
46
{
47
$domain = $server->getHttpHost();
48
}
49
}
50
51
return
$domain;
52
}
53
61
public
static
function
getBitrix24Subdomain
(
string
$domainName, ?
string
&$baseUrl =
null
): ?string
62
{
63
$re =
'/^([^\.]+)\.('
. implode(
'|'
, self::B24_DOMAINS) .
')$/i'
;
64
if
(preg_match($re, $domainName,
$matches
))
65
{
66
$baseUrl =
".{$matches[2]}"
;
67
return
$matches
[1];
68
}
69
70
return
null
;
71
}
72
80
public
static
function
getBitrix24Postfix
(
string
$type
): string
81
{
82
$zone =
Manager::getZone
();
83
$postfix = (
$type
===
'STORE'
) ?
'.bitrix24.shop'
:
'.bitrix24.site'
;
84
$type
= mb_strtoupper(
$type
);
85
86
// local domain
87
if
(in_array($zone, [
'ru'
]))
88
{
89
$postfix =
'.'
;
90
$postfix .= (
$type
===
'STORE'
) ?
'bitrix24shop'
:
'bitrix24site'
;
91
$postfix .=
'.'
. $zone;
92
}
93
if
(in_array($zone, [
'by'
]))
94
{
95
if
(
$type
===
'STORE'
)
96
{
97
$postfix =
'.b24shop.online'
;
98
}
99
else
100
{
101
$postfix =
'.b24site.online'
;
102
}
103
}
104
105
return
$postfix;
106
}
107
112
public
static
function
canRegisterInBitrix24
(): bool
113
{
114
try
115
{
116
Manager::getExternalSiteController
()::isDomainExists(
'repo.bitrix24.site'
);
117
}
118
catch
(\
Bitrix
\
Main
\
SystemException
$ex)
119
{
120
return
false
;
121
}
122
123
return
true
;
124
}
125
130
public
static
function
createDefault
()
131
{
132
$res
= self::add(
array
(
133
'ACTIVE'
=>
'Y'
,
134
'DOMAIN'
=> self::getDomainName()
135
));
136
if
(
$res
->isSuccess())
137
{
138
return
$res
->getId();
139
}
140
141
return
false
;
142
}
143
148
public
static
function
getCurrentId
()
149
{
150
$res
= self::getList(
array
(
151
'filter'
=>
array
(
152
'=ACTIVE'
=>
'Y'
,
153
'=DOMAIN'
=> self::getDomainName()
154
)
155
));
156
if
($row =
$res
->fetch())
157
{
158
return
$row[
'ID'
];
159
}
160
else
161
{
162
return
self::createDefault();
163
}
164
}
165
170
public
static
function
getProtocolList
()
171
{
172
return \Bitrix\Landing\Internals\DomainTable::getProtocolList();
173
}
174
179
public
static
function
getHostUrl
()
180
{
181
static
$hostUrl =
null
;
182
183
if
($hostUrl !==
null
)
184
{
185
return
$hostUrl;
186
}
187
188
$request
= Context::getCurrent()->getRequest();
189
$protocol
= (
$request
->isHttps() ?
'https://'
:
'http://'
);
190
191
if
(defined(
'SITE_SERVER_NAME'
) && SITE_SERVER_NAME)
192
{
193
$host
= SITE_SERVER_NAME;
194
}
195
else
196
{
197
$host
= Option::get(
'main'
,
'server_name'
,
$request
->getHttpHost());
198
}
199
200
$hostUrl = rtrim(
$protocol
.
$host
,
'/'
);
201
202
return
$hostUrl;
203
}
204
210
public
static
function
getTLD
(
string
$domainName): string
211
{
212
$domainName = mb_strtolower(trim($domainName));
213
$domainNameParts = explode(
'.'
, $domainName);
214
$domainNameTld = $domainNameParts[
count
($domainNameParts) - 1];
215
216
if
($domainNameParts[
count
($domainNameParts) - 2] ==
'com'
)
217
{
218
$domainNameTld =
'com.'
. $domainNameTld;
219
}
220
221
return
$domainNameTld;
222
}
223
}
$type
$type
Определения
options.php:106
$request
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения
catalog_reindex.php:36
Bitrix\Landing\Domain\getBitrix24Postfix
static getBitrix24Postfix(string $type)
Определения
domain.php:80
Bitrix\Landing\Domain\getProtocolList
static getProtocolList()
Определения
domain.php:170
Bitrix\Landing\Domain\getCurrentId
static getCurrentId()
Определения
domain.php:148
Bitrix\Landing\Domain\$internalClass
static $internalClass
Определения
domain.php:30
Bitrix\Landing\Domain\getDomainName
static getDomainName()
Определения
domain.php:36
Bitrix\Landing\Domain\createDefault
static createDefault()
Определения
domain.php:130
Bitrix\Landing\Domain\getBitrix24Subdomain
static getBitrix24Subdomain(string $domainName, ?string &$baseUrl=null)
Определения
domain.php:61
Bitrix\Landing\Domain\getHostUrl
static getHostUrl()
Определения
domain.php:179
Bitrix\Landing\Domain\getTLD
static getTLD(string $domainName)
Определения
domain.php:210
Bitrix\Landing\Domain\canRegisterInBitrix24
static canRegisterInBitrix24()
Определения
domain.php:112
Bitrix\Landing\Domain\B24_DOMAINS
const B24_DOMAINS
Определения
domain.php:14
Bitrix\Landing\Internals\BaseTable
Определения
base.php:7
Bitrix\Landing\Manager\getZone
static getZone()
Определения
manager.php:930
Bitrix\Landing\Manager\getExternalSiteController
static getExternalSiteController()
Определения
manager.php:1379
Bitrix\Main\Application\getInstance
static getInstance()
Определения
application.php:98
Bitrix\Main\SystemException
Определения
SystemException.php:9
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$res
$res
Определения
filter_act.php:7
$protocol
$protocol
Определения
.description.php:9
$context
$context
Определения
csv_new_setup.php:223
Bitrix\Landing\Domain
Определения
provider.php:2
Bitrix\Main
Bitrix\Main\$host
$host
Определения
mysql_to_pgsql.php:32
Bitrix
count
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения
waybill.php:936
$matches
$matches
Определения
index.php:22
bitrix
modules
landing
lib
domain.php
Создано системой
1.14.0