Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
sessionexpander.php
1<?php
9namespace Bitrix\Main\UI;
10
14
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}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29