1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
event_message.php
См. документацию.
1<?php
8
10{
11 const AUDIT_TYPE = "#AUDIT_TYPE#";
12 const SITE_ID = "#SITE_ID#";
13 const USER_INFO = "#USER_INFO#";
14 const URL = "#URL#";
15 const VARIABLE_NAME = "#VARIABLE_NAME#";
16 const VARIABLE_VALUE = "#VARIABLE_VALUE#";
17 const VARIABLE_VALUE_BASE64 = "#VARIABLE_VALUE_BASE64#";
18 const REMOTE_ADDR = "#REMOTE_ADDR#";
19 const USER_AGENT = "#USER_AGENT#";
20 const USER_ID = "#USER_ID#";
21 const BX24_HOST = "#BX24_HOST_NAME#";
22
23 private $messageFormat = "";
24 private $userInfoFormat = "";
25 private $isUserInfoNeeded = false;
26 private $isB64MessageNeeded = false;
27
28 private $siteId = "";
29 private $userInfo = "";
30 private $url = "/";
31
32 private static $messagePlaceholders = array(
33 self::AUDIT_TYPE,
34 self::SITE_ID,
35 self::USER_INFO,
36 self::URL,
37 self::VARIABLE_NAME,
38 self::VARIABLE_VALUE,
39 self::VARIABLE_VALUE_BASE64
40 );
41
42 private static $userInfoPlaceholders = array(
43 self::REMOTE_ADDR,
44 self::USER_AGENT,
45 self::USER_ID
46 );
47
52 public function __construct($messageFormat = "", $userInfoFormat = "")
53 {
54 if ($messageFormat)
55 $this->messageFormat = $messageFormat;
56 else
57 $this->messageFormat = self::getDefaultMessageFormat();
58
59 if ($userInfoFormat)
60 $this->userInfoFormat = $userInfoFormat;
61 else
62 $this->userInfoFormat = self::getDefaultUserInfoFormat();
63
64 $this->isUserInfoNeeded = mb_strpos($messageFormat, self::USER_INFO) !== false;
65 $this->isB64MessageNeeded = mb_strpos($messageFormat, self::VARIABLE_VALUE_BASE64) !== false;
66
67 if (!defined("ADMIN_SECTION") || ADMIN_SECTION != true)
68 {
69 $this->siteId = defined('SITE_ID') ? SITE_ID : false;
70 }
71
72 $this->userInfo = $this->getUserInfo();
73 $this->url = preg_replace("/(&?sessid=[0-9a-z]+)/", "", $_SERVER["REQUEST_URI"]);
74 }
75
79 public static function getDefaultMessageFormat()
80 {
81 return implode(
82 ' | ',
83 array(self::AUDIT_TYPE, self::SITE_ID, self::USER_INFO, self::URL, self::VARIABLE_NAME, self::VARIABLE_VALUE_BASE64)
84 );
85 }
86
90 public static function getDefaultUserInfoFormat()
91 {
92 return implode(
93 ' | ',
94 array(self::REMOTE_ADDR, self::USER_ID)
95 );
96 }
97
101 public static function getAvailableMessagePlaceholders()
102 {
103 return self::$messagePlaceholders;
104 }
105
109 public static function getAvailableUserInfoPlaceholders()
110 {
111 return self::$userInfoPlaceholders;
112 }
113
120 public function format($auditType, $itemName, $itemDescription)
121 {
122 $description = mb_substr($itemDescription, 0, 2000);
123
124 $replacement = array(
125 self::AUDIT_TYPE => $auditType,
126 self::SITE_ID => $this->siteId,
127 self::USER_INFO => $this->userInfo,
128 self::URL => $this->url,
129 self::VARIABLE_NAME => $itemName,
130 self::VARIABLE_VALUE => $description
131 );
132
133 if ($this->isB64MessageNeeded)
134 $replacement[self::VARIABLE_VALUE_BASE64] = base64_encode($description);
135
136 if (defined("BX24_HOST_NAME"))
137 $replacement[self::BX24_HOST] = BX24_HOST_NAME;
138
139 return str_replace(
140 array_keys($replacement),
141 $replacement,
142 $this->messageFormat
143 );
144 }
145
149 private function getUserInfo()
150 {
151 if (!$this->isUserInfoNeeded)
152 return "";
153
154 global $USER;
155
156 if (is_object($USER))
157 $userId = $USER->GetID();
158 else
159 $userId = 0;
160
161 $replacement = array(
162 self::REMOTE_ADDR => $_SERVER["REMOTE_ADDR"],
163 self::USER_AGENT => $_SERVER["HTTP_USER_AGENT"],
164 self::USER_ID => $userId
165 );
166
167 return str_replace(
168 array_keys($replacement),
169 $replacement,
170 $this->userInfoFormat
171 );
172 }
173}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getDefaultUserInfoFormat()
Определения event_message.php:90
static getDefaultMessageFormat()
Определения event_message.php:79
static getAvailableUserInfoPlaceholders()
Определения event_message.php:109
static getAvailableMessagePlaceholders()
Определения event_message.php:101
__construct($messageFormat="", $userInfoFormat="")
Определения event_message.php:52
format($auditType, $itemName, $itemDescription)
Определения event_message.php:120
const VARIABLE_VALUE_BASE64
Определения event_message.php:17
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
if(Loader::includeModule( 'bitrix24')) elseif(Loader::includeModule('intranet') &&CIntranetUtils::getPortalZone() !=='ru') $description
Определения .description.php:24
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $USER
Определения csv_new_run.php:40
const ADMIN_SECTION
Определения rss.php:2