1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
mainpage.php
См. документацию.
1
<?php
2
3
require_once(
$_SERVER
[
"DOCUMENT_ROOT"
] .
"/bitrix/modules/main/start.php"
);
4
5
class
CMainPage
6
{
7
public
static
function
GetSiteByHost
()
8
{
9
$cur_host =
$_SERVER
[
"HTTP_HOST"
];
10
$arURL = parse_url(
"http://"
. $cur_host);
11
if
($arURL[
"scheme"
] ==
''
&& $arURL[
"host"
] !=
''
)
12
{
13
$CURR_DOMAIN = $arURL[
"host"
];
14
}
15
else
16
{
17
$CURR_DOMAIN = $cur_host;
18
}
19
20
if
(mb_strpos($CURR_DOMAIN,
':'
) > 0)
21
{
22
$CURR_DOMAIN = mb_substr($CURR_DOMAIN, 0, mb_strpos($CURR_DOMAIN,
':'
));
23
}
24
$CURR_DOMAIN = trim($CURR_DOMAIN,
"\t\r\n\0 ."
);
25
26
global
$DB
;
27
$strSql =
28
"SELECT L.LID as SITE_ID "
.
29
"FROM b_lang L, b_lang_domain LD "
.
30
"WHERE L.ACTIVE='Y' "
.
31
" AND L.LID=LD.LID "
.
32
" AND '"
.
$DB
->ForSql(
"."
. $CURR_DOMAIN, 255) .
"' LIKE "
.
$DB
->Concat(
"'%.'"
,
"LD.DOMAIN"
) .
" "
.
33
"ORDER BY "
.
$DB
->Length(
"LD.DOMAIN"
) .
" DESC, L.SORT"
;
34
35
$res
=
$DB
->Query($strSql);
36
if
(
$ar_res
=
$res
->Fetch())
37
{
38
return
$ar_res
[
"SITE_ID"
];
39
}
40
41
$sl = CSite::GetDefList();
42
while
($slang = $sl->Fetch())
43
{
44
if
($slang[
"DEF"
] ==
"Y"
)
45
{
46
return
$slang[
"SITE_ID"
];
47
}
48
}
49
50
return
false
;
51
}
52
53
public
static
function
GetSiteByAcceptLanguage
($compare_site_id=
false
)
54
{
55
$site_id
=
false
;
56
$last_site_id =
''
;
57
$arSites
= [];
58
59
$rsSites
= CSite::GetDefList();
60
while
($arSite =
$rsSites
->Fetch())
61
{
62
$last_site_id = $arSite[
"ID"
];
63
if
($arSite[
"DEF"
] ==
"Y"
)
64
{
65
$site_id
= $arSite[
"ID"
];
66
}
67
$arSites
[] = $arSite;
68
}
69
70
$arUserLang = explode(
","
,
$_SERVER
[
"HTTP_ACCEPT_LANGUAGE"
]);
71
if
(is_array($arUserLang))
72
{
73
foreach
($arUserLang as $user_lid)
74
{
75
$user_lid = mb_strtolower(mb_substr($user_lid, 0, 2));
76
foreach
(
$arSites
as $arSite)
77
{
78
$sid = ($compare_site_id) ? mb_strtolower($arSite[
"ID"
]) : mb_strtolower($arSite[
"LANGUAGE_ID"
]);
79
if
($user_lid == $sid)
80
{
81
return
$arSite[
"ID"
];
82
}
83
}
84
}
85
}
86
if
(
$site_id
==
''
)
87
{
88
return
$last_site_id;
89
}
90
return
$site_id
;
91
}
92
93
public
static
function
RedirectToSite
(
$site
)
94
{
95
if
(
$site
==
''
)
96
{
97
return
;
98
}
99
$db_site = CSite::GetByID(
$site
);
100
if
($arSite = $db_site->Fetch())
101
{
102
$arSite[
"DIR"
] = rtrim($arSite[
"DIR"
],
' \/'
);
103
if
($arSite[
"DIR"
] !=
''
)
104
{
105
LocalRedirect
(($arSite[
"SERVER_NAME"
] !=
''
?
"http://"
. $arSite[
"SERVER_NAME"
] :
''
) . $arSite[
"DIR"
] .
$_SERVER
[
"REQUEST_URI"
],
true
);
106
}
107
}
108
}
109
110
public
static
function
GetIncludeSitePage
(
$site
)
111
{
112
if
(
$site
==
''
)
113
{
114
return
false
;
115
}
116
$db_site = CSite::GetByID(
$site
);
117
if
($arSite = $db_site->Fetch())
118
{
119
$arSite[
"DIR"
] = rtrim($arSite[
"DIR"
],
' \/'
);
120
$cur_page =
GetPagePath
();
121
if
($arSite[
"DIR"
] !=
''
)
122
{
123
$_SERVER
[
"REQUEST_URI"
] = $arSite[
"DIR"
] . $cur_page;
124
return
$_SERVER
[
"DOCUMENT_ROOT"
] .
$_SERVER
[
"REQUEST_URI"
];
125
}
126
}
127
return
false
;
128
}
129
}
$arSites
$arSites
Определения
options.php:15
$ar_res
$ar_res
Определения
options_user_settings_set.php:16
CMainPage
Определения
mainpage.php:6
CMainPage\GetSiteByAcceptLanguage
static GetSiteByAcceptLanguage($compare_site_id=false)
Определения
mainpage.php:53
CMainPage\GetIncludeSitePage
static GetIncludeSitePage($site)
Определения
mainpage.php:110
CMainPage\RedirectToSite
static RedirectToSite($site)
Определения
mainpage.php:93
CMainPage\GetSiteByHost
static GetSiteByHost()
Определения
mainpage.php:7
$rsSites
$rsSites
Определения
options.php:477
$res
$res
Определения
filter_act.php:7
$_SERVER
$_SERVER["DOCUMENT_ROOT"]
Определения
cron_frame.php:9
$DB
global $DB
Определения
cron_frame.php:29
GetPagePath
GetPagePath($page=false, $get_index_page=null)
Определения
tools.php:3139
LocalRedirect
LocalRedirect($url, $skip_security_check=false, $status="302 Found")
Определения
tools.php:4005
$site_id
$site_id
Определения
sonet_set_content_view.php:9
$site
$site
Определения
yandex_run.php:614
bitrix
modules
main
include
mainpage.php
Создано системой
1.14.0