Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/burlakastudio.realcommenter/lib/ |
Upload File : |
<?php /** * ����� "��������� ����������� D7" ��� ������� * �������� ���� �����: www.realcommenter.com * �������� ���� �����������: burlaka.studio * ����� � ����������: ������� ������� (AlexeyGfi) -> alexeygfi@gmail.com */ namespace Burlakastudio\Realcommenter; use Bitrix\Main\Localization\Loc; use Bitrix\Main\SiteTable; use CEventLog; class ErrorNotificator { /** * ������� SITE_ID * @return mixed */ public static function getSiteId() { if (defined('SITE_ID') && SITE_ID) { return SITE_ID; } $site_arr = self::getSite(); return $site_arr['LID']; } protected static function getSite($site_id = false) { $site_filter = ['ACTIVE' => 'Y']; if ($site_id) { $site_filter['=LID'] = $site_id; } return SiteTable::getList([ 'select' => ['*'], 'filter' => $site_filter, 'limit' => 1 ])->fetchRaw(); } public static function sendError($msg) { self::saveInEventLog($msg); $emails = NOTIFICATOR::getSecurityEmailList(); if (!$emails) { return; } $siteId = SITE_ID ?: 's1'; $siteEmail = self::getSiteEmail($siteId); //��������� ����� define('ERROR_EMAIL', implode(',', $emails)); define('ERROR_EMAIL_FROM', $siteEmail); define('ERROR_EMAIL_REPLY_TO', $siteEmail); SendError($msg . "\n\n"); } /** * @param string|bool $siteLid * @return mixed|string */ protected static function getSiteEmail($siteLid = null) { if (!$siteLid) { if (!defined('SITE_ID') || !SITE_ID) { return ''; } $siteLid = SITE_ID; } $siteArr = self::getSite($siteLid); return $siteArr['EMAIL'] ?? null; } public static function getEventLogFields() { return [ 'SEVERITY' => 'SECURITY', 'AUDIT_TYPE_ID' => get_called_class(), 'MODULE_ID' => 'realcommenter_20', 'ITEM_ID' => '', ]; } /** * * @param $msg * @param array $replace_values ������, ����: * [ * 'AUDIT_TYPE_ID' => '', * 'MODULE_ID' => '', * 'ITEM_ID' => '', * ] */ public static function saveInEventLog($msg, $replace_values = []) { //...� ���� � ��� $event_fields = self::getEventLogFields(); foreach ($event_fields as $key => $value) { if ($replace_values[$key]) { $event_fields[$key] = $replace_values[$key]; continue; } /** * ���� � ������ ��� ���, � � ��������� ������� �������� _error */ if ($key === 'AUDIT_TYPE_ID') { $event_fields[$key] .= '_error'; } } $event_fields['DESCRIPTION'] = $msg; CEventLog::Add($event_fields); } /** * �� ���� ���������� ������� ��� �� �������� �������� ����� * * @param int $user_id * * @return array|false */ // protected static function get_user_event_info($user_id = 0) // { // // $user_arr = UserTable::getList( // [ // 'select' => ['ID', 'NAME', 'LAST_NAME', 'SECOND_NAME', 'TITLE', 'EMAIL'], // 'filter' => ['=ID' => $user_id], // 'limit' => 1 // ] // )->fetchRaw(); // // $user_arr['FORMATTED_NAME'] = CUser::FormatName( // CSite::GetNameFormat(), // $user_arr // ); // // return $user_arr; // } /** * @param bool $error_case * @return string */ public static function getErrorLang($error_case = false) { if (!$error_case) { return ''; } return Loc::getMessage($error_case); } }