Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
sessionexpander.php
1
<?php
9
namespace
Bitrix\Main\UI
;
10
11
use
Bitrix\Main\Security\Sign
;
12
use
Bitrix\Main\Config
;
13
use
Bitrix\Main\Localization\Loc
;
14
15
class
SessionExpander
16
{
20
public
static
function
init
()
21
{
22
global $USER;
23
24
$sessid = bitrix_sessid();
25
26
$signer =
new
Sign\Signer
();
27
$signedSessId = $signer->sign($sessid, static::getSalt());
28
29
\CJSCore::Init([
'ajax'
,
'ls'
]);
30
31
$jsCode =
'<script type="text/javascript">'
.
"\n"
;
32
33
$showMess = ($USER->IsAuthorized() && Config\Option::get(
"main"
,
"session_show_message"
,
"Y"
) <>
"N"
);
34
if
($showMess)
35
{
36
$policy = $USER->GetSecurityPolicy();
37
$message = \CUtil::JSEscape(
Loc::getMessage
(
"MAIN_SESS_MESS"
, array(
"#TIMEOUT#"
=> (
int
)$policy[
"SESSION_TIMEOUT"
])));
38
$jsCode .=
'BX.message({"SessExpired": \''
.$message.
'\'
});
'."\n";
39
}
40
41
$jsCode .= '
bxSession.Expand(\
''
.$signedSessId.
'\'
);
'."\n".'
</script>
';
42
43
$asset = \Bitrix\Main\Page\Asset::getInstance();
44
$asset->addJs('
/
bitrix
/js/main/session.js
');
45
$asset->addString($jsCode);
46
}
47
53
public static function getSignedValue($signedParam)
54
{
55
try
56
{
57
$signer = new Sign\Signer();
58
$string = $signer->unsign($signedParam, static::getSalt());
59
return $string;
60
}
61
catch(\Bitrix\Main\SystemException $exception)
62
{
63
return false;
64
}
65
}
66
67
protected static function getSalt()
68
{
69
global $USER;
70
71
$context = \Bitrix\Main\Context::getCurrent();
72
73
return md5(
74
$context->getRequest()->getCookie("UIDH").
75
"|".$USER->GetID().
76
"|".$context->getServer()->getRemoteAddr()
77
);
78
}
79
}
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\Security\Sign\Signer
Definition
signer.php:13
Bitrix\Main\UI\SessionExpander
Definition
sessionexpander.php:16
Bitrix\Main\UI\SessionExpander\init
static init()
Definition
sessionexpander.php:20
Bitrix\Main\Config
Definition
configuration.php:2
Bitrix\Main\Security\Sign
Definition
badsignatureexception.php:2
Bitrix\Main\UI
bitrix
modules
main
lib
ui
sessionexpander.php
Создано системой
1.10.0