This commit is contained in:
root
2025-11-13 19:52:28 +03:00
parent 8aeeb05b7d
commit 807dec3b6c
4646 changed files with 163445 additions and 626017 deletions

View File

@@ -793,45 +793,144 @@ class CComponentUtil
"ADDITIONAL_VALUES" => "N"
);
}
elseif ($arParamKeys[$i] == "USER_CONSENT")
elseif ($arParamKeys[$i] == 'USER_CONSENT')
{
$arComponentParameters["GROUPS"]["USER_CONSENT"] = array(
"NAME" => GetMessage("COMP_GROUP_USER_CONSENT"),
"SORT" => 350
);
$arComponentParameters['GROUPS']['USER_CONSENT'] = [
'NAME' => GetMessage('COMP_GROUP_USER_CONSENT'),
'SORT' => 350,
];
$arComponentParameters["PARAMETERS"]["USER_CONSENT"] = array(
"PARENT" => "USER_CONSENT",
"NAME" => GetMessage("COMP_PROP_USER_CONSENT_USE"),
"TYPE" => "CHECKBOX",
"DEFAULT" => "N",
"ADDITIONAL_VALUES" => "N"
);
$arComponentParameters['PARAMETERS']['USER_CONSENT'] = [
'PARENT' => 'USER_CONSENT',
'NAME' => GetMessage('COMP_PROP_USER_CONSENT_USE'),
'TYPE' => 'CHECKBOX',
'DEFAULT' => 'N',
'ADDITIONAL_VALUES' => 'N',
];
$arComponentParameters["PARAMETERS"]["USER_CONSENT_ID"] = array(
"PARENT" => "USER_CONSENT",
"NAME" => GetMessage("COMP_PROP_USER_CONSENT_ID"),
"TYPE" => "LIST",
"VALUES" => array(GetMessage("COMP_PROP_USER_CONSENT_ID_DEF")) + \Bitrix\Main\UserConsent\Agreement::getActiveList(),
"MULTIPLE" => "N",
"DEFAULT" => "",
);
$isMultiple = isset($arComponentParameters['PARAMETERS']['USER_CONSENT_IDS']);
if ($isMultiple)
{
$agreements = \Bitrix\Main\UserConsent\Agreement::getActiveList();
if (array_key_exists('USER_CONSENT_IDS', $arCurrentValues))
{
$userConsentIds =
is_array($arCurrentValues['USER_CONSENT_IDS'])
? $arCurrentValues['USER_CONSENT_IDS']
: [$arCurrentValues['USER_CONSENT_IDS']]
;
}
else
{
$userConsentIds = null;
}
$defaultUserConsentId = null;
$defaultUserConsentChecked = null;
$arComponentParameters["PARAMETERS"]["USER_CONSENT_IS_CHECKED"] = array(
"PARENT" => "USER_CONSENT",
"NAME" => GetMessage("COMP_PROP_USER_CONSENT_IS_CHECKED"),
"TYPE" => "CHECKBOX",
"DEFAULT" => "Y",
"ADDITIONAL_VALUES" => "N"
);
if (!$userConsentIds)
{
if (
isset($arCurrentValues['USER_CONSENT_ID'])
&& !isset($arCurrentValues['USER_CONSENT_IS_CHECKED_' . $arCurrentValues['USER_CONSENT_ID']])
)
{
$defaultUserConsentId =
$agreements[(int)$arCurrentValues['USER_CONSENT_ID']]
? (int)$arCurrentValues['USER_CONSENT_ID']
: null
;
$userConsentIds = [$arCurrentValues['USER_CONSENT_ID']];
if (isset($arCurrentValues['USER_CONSENT_IS_CHECKED']))
{
$defaultUserConsentChecked =
$arCurrentValues['USER_CONSENT_IS_CHECKED'] === 'Y'
? 'Y'
: 'N'
;
}
}
else
{
$userConsentIds = [];
}
}
$arComponentParameters['PARAMETERS']['USER_CONSENT_IDS'] = [
'PARENT' => 'USER_CONSENT',
'NAME' => GetMessage('COMP_PROP_USER_CONSENT_IDS'),
'TYPE' => 'LIST',
'VALUES' => $agreements,
'MULTIPLE' => 'Y',
'DEFAULT' => $defaultUserConsentId ? [$defaultUserConsentId] : '',
'REFRESH' => 'Y',
];
foreach ($userConsentIds as $userConsentId)
{
if (!is_scalar($userConsentId))
{
continue;
}
$arComponentParameters["PARAMETERS"]["USER_CONSENT_IS_LOADED"] = array(
"PARENT" => "USER_CONSENT",
"NAME" => GetMessage("COMP_PROP_USER_CONSENT_IS_LOADED"),
"TYPE" => "CHECKBOX",
"DEFAULT" => "N",
"ADDITIONAL_VALUES" => "N"
);
$userConsentId = (int)$userConsentId;
if ($userConsentId <= 0)
{
continue;
}
if (!isset($agreements[$userConsentId]))
{
continue;
}
$arComponentParameters['PARAMETERS']['USER_CONSENT_IS_CHECKED_' . $userConsentId] = [
'PARENT' => 'USER_CONSENT',
'NAME' => GetMessage(
'COMP_PROP_USER_CONSENT_IS_CHECKED_WITH_NAME',
['#NAME#' => $agreements[$userConsentId]],
),
'TYPE' => 'CHECKBOX',
'DEFAULT' => $defaultUserConsentId === $userConsentId ? $defaultUserConsentChecked : 'N',
'ADDITIONAL_VALUES' => 'N',
];
$arComponentParameters['PARAMETERS']['USER_CONSENT_REQUIRED_' . $userConsentId] = [
'PARENT' => 'USER_CONSENT',
'NAME' => GetMessage(
'COMP_PROP_USER_CONSENT_REQUIRED_WITH_NAME',
['#NAME#' => $agreements[$userConsentId]],
),
'TYPE' => 'CHECKBOX',
'DEFAULT' => 'Y',
'ADDITIONAL_VALUES' => 'N',
];
}
}
else
{
$arComponentParameters['PARAMETERS']['USER_CONSENT_ID'] = [
'PARENT' => 'USER_CONSENT',
'NAME' => GetMessage('COMP_PROP_USER_CONSENT_ID'),
'TYPE' => 'LIST',
'VALUES' => [GetMessage('COMP_PROP_USER_CONSENT_ID_DEF')] + \Bitrix\Main\UserConsent\Agreement::getActiveList(),
'MULTIPLE' => 'N',
'DEFAULT' => '',
];
$arComponentParameters['PARAMETERS']['USER_CONSENT_IS_CHECKED'] = [
'PARENT' => 'USER_CONSENT',
'NAME' => GetMessage('COMP_PROP_USER_CONSENT_IS_CHECKED'),
'TYPE' => 'CHECKBOX',
'DEFAULT' => 'Y',
'ADDITIONAL_VALUES' => 'N'
];
}
$arComponentParameters['PARAMETERS']['USER_CONSENT_IS_LOADED'] = [
'PARENT' => 'USER_CONSENT',
'NAME' => GetMessage('COMP_PROP_USER_CONSENT_IS_LOADED'),
'TYPE' => 'CHECKBOX',
'DEFAULT' => 'N',
'ADDITIONAL_VALUES' => 'N'
];
}
else
{

View File

@@ -1,17 +1,15 @@
<?php
/**
* Bitrix Framework
* @package bitrix
* @subpackage main
* @copyright 2001-2020 Bitrix
* @copyright 2001-2025 Bitrix
*/
use Bitrix\Main\Mail;
/**
* @deprecated
*/
class CAllEvent
class CEvent
{
public static $EVENT_SITE_PARAMS = [];
@@ -30,49 +28,37 @@ class CAllEvent
return Mail\EventManager::cleanUpAgent();
}
public static function SendImmediate($event, $lid, $arFields, $Duplicate = "Y", $message_id = "", $files = array(), $languageId = '', array $filesContent = [])
public static function SendImmediate($event, $lid, $arFields, $Duplicate = "Y", $message_id = "", $files = [], $languageId = '', array $filesContent = [])
{
foreach(GetModuleEvents("main", "OnBeforeEventAdd", true) as $arEvent)
if(ExecuteModuleEventEx($arEvent, array(&$event, &$lid, &$arFields, &$message_id, &$files, &$languageId)) === false)
return false;
if(!is_array($arFields))
{
$arFields = array();
}
$arLocalFields = array(
$arLocalFields = [
"EVENT_NAME" => $event,
"C_FIELDS" => $arFields,
"LID" => (is_array($lid)? implode(",", $lid) : $lid),
"DUPLICATE" => ($Duplicate != "N"? "Y" : "N"),
"MESSAGE_ID" => (intval($message_id) > 0? intval($message_id): ""),
"LID" => $lid,
"DUPLICATE" => ($Duplicate != "N" ? "Y" : "N"),
"MESSAGE_ID" => (intval($message_id) > 0 ? intval($message_id) : ""),
"DATE_INSERT" => GetTime(time(), "FULL"),
"FILE" => $files,
"LANGUAGE_ID" => ($languageId == ''? LANGUAGE_ID : $languageId),
"LANGUAGE_ID" => ($languageId == '' ? LANGUAGE_ID : $languageId),
"ID" => "0",
"FILES_CONTENT" => $filesContent,
);
];
return Mail\Event::sendImmediate($arLocalFields);
$result = Mail\Event::sendImmediate($arLocalFields);
return $result === Mail\Event::SEND_RESULT_NONE ? false : $result;
}
public static function Send($event, $lid, $arFields, $Duplicate = "Y", $message_id="", $files=array(), $languageId = '')
public static function Send($event, $lid, $arFields, $Duplicate = "Y", $message_id = "", $files = [], $languageId = '')
{
foreach(GetModuleEvents("main", "OnBeforeEventAdd", true) as $arEvent)
if(ExecuteModuleEventEx($arEvent, array(&$event, &$lid, &$arFields, &$message_id, &$files, &$languageId)) === false)
return false;
$arLocalFields = array(
$arLocalFields = [
"EVENT_NAME" => $event,
"C_FIELDS" => $arFields,
"LID" => (is_array($lid)? implode(",", $lid) : $lid),
"DUPLICATE" => ($Duplicate != "N"? "Y" : "N"),
"LID" => $lid,
"DUPLICATE" => ($Duplicate != "N" ? "Y" : "N"),
"MESSAGE_ID" => (intval($message_id) > 0 ? intval($message_id) : ""),
"FILE" => $files,
"LANGUAGE_ID" => ($languageId == ''? LANGUAGE_ID : $languageId),
);
if(intval($message_id) > 0)
$arLocalFields["MESSAGE_ID"] = intval($message_id);
"LANGUAGE_ID" => ($languageId == '' ? LANGUAGE_ID : $languageId),
];
$result = Mail\Event::send($arLocalFields);
@@ -86,16 +72,18 @@ class CAllEvent
public static function fieldencode($s)
{
if(is_array($s))
if (is_array($s))
{
$ret_val = '';
foreach($s as $v)
$ret_val .= ($ret_val <> ''? ', ':'').CEvent::fieldencode($v);
foreach ($s as $v)
{
$ret_val .= ($ret_val <> '' ? ', ' : '') . CEvent::fieldencode($v);
}
}
else
{
$ret_val = str_replace("%", "%2", $s);
$ret_val = str_replace("&","%1", $ret_val);
$ret_val = str_replace("&", "%1", $ret_val);
$ret_val = str_replace("=", "%3", $ret_val);
}
return $ret_val;
@@ -104,8 +92,8 @@ class CAllEvent
public static function ExtractMailFields($str)
{
$ar = explode("&", $str);
$newar = array();
foreach($ar as $val)
$newar = [];
foreach ($ar as $val)
{
$val = str_replace("%1", "&", $val);
$tar = explode("=", $val);
@@ -115,54 +103,60 @@ class CAllEvent
$val = str_replace("%3", "=", $val);
$key = str_replace("%2", "%", $key);
$val = str_replace("%2", "%", $val);
if($key != "")
if ($key != "")
{
$newar[$key] = $val;
}
}
return $newar;
}
public static function GetSiteFieldsArray($site_id)
{
if($site_id !== false && isset(static::$EVENT_SITE_PARAMS[$site_id]))
if ($site_id !== false && isset(static::$EVENT_SITE_PARAMS[$site_id]))
{
return static::$EVENT_SITE_PARAMS[$site_id];
}
$SITE_NAME = COption::GetOptionString("main", "site_name", $GLOBALS["SERVER_NAME"]);
$SERVER_NAME = COption::GetOptionString("main", "server_name", $GLOBALS["SERVER_NAME"]);
$DEFAULT_EMAIL_FROM = COption::GetOptionString("main", "email_from", "admin@".$GLOBALS["SERVER_NAME"]);
$DEFAULT_EMAIL_FROM = COption::GetOptionString("main", "email_from", "admin@" . $GLOBALS["SERVER_NAME"]);
if($site_id <> '')
if ($site_id <> '')
{
$dbSite = CSite::GetByID($site_id);
if($arSite = $dbSite->Fetch())
if ($arSite = $dbSite->Fetch())
{
static::$EVENT_SITE_PARAMS[$site_id] = array(
"SITE_NAME" => ($arSite["SITE_NAME"]<>''? $arSite["SITE_NAME"] : $SITE_NAME),
"SERVER_NAME" => ($arSite["SERVER_NAME"]<>''? $arSite["SERVER_NAME"] : $SERVER_NAME),
"DEFAULT_EMAIL_FROM" => ($arSite["EMAIL"]<>''? $arSite["EMAIL"] : $DEFAULT_EMAIL_FROM),
static::$EVENT_SITE_PARAMS[$site_id] = [
"SITE_NAME" => ($arSite["SITE_NAME"] <> '' ? $arSite["SITE_NAME"] : $SITE_NAME),
"SERVER_NAME" => ($arSite["SERVER_NAME"] <> '' ? $arSite["SERVER_NAME"] : $SERVER_NAME),
"DEFAULT_EMAIL_FROM" => ($arSite["EMAIL"] <> '' ? $arSite["EMAIL"] : $DEFAULT_EMAIL_FROM),
"SITE_ID" => $arSite['ID'],
"SITE_DIR" => $arSite['DIR'],
);
];
return static::$EVENT_SITE_PARAMS[$site_id];
}
}
return array(
return [
"SITE_NAME" => $SITE_NAME,
"SERVER_NAME" => $SERVER_NAME,
"DEFAULT_EMAIL_FROM" => $DEFAULT_EMAIL_FROM
);
"DEFAULT_EMAIL_FROM" => $DEFAULT_EMAIL_FROM,
];
}
public static function ReplaceTemplate($str, $ar, $bNewLineToBreak=false)
public static function ReplaceTemplate($str, $ar, $bNewLineToBreak = false)
{
$str = str_replace("%", "%2", $str);
foreach($ar as $key=>$val)
foreach ($ar as $key => $val)
{
if($bNewLineToBreak && !str_contains($val, "<"))
if ($bNewLineToBreak && !str_contains($val, "<"))
{
$val = nl2br($val);
}
$val = str_replace("%", "%2", $val);
$val = str_replace("#", "%1", $val);
$str = str_replace("#".$key."#", $val, $str);
$str = str_replace("#" . $key . "#", $val, $str);
}
$str = str_replace("%1", "#", $str);
$str = str_replace("%2", "%", $str);
@@ -215,7 +209,7 @@ class CAllEvent
*/
public static function HandleEvent($arEvent)
{
if(isset($arEvent['C_FIELDS']))
if (isset($arEvent['C_FIELDS']))
{
$arEvent['FIELDS'] = $arEvent['C_FIELDS'];
unset($arEvent['C_FIELDS']);
@@ -224,7 +218,3 @@ class CAllEvent
return Mail\Event::handleEvent($arEvent);
}
}
class CEvent extends CAllEvent
{
}

View File

@@ -370,6 +370,9 @@ class CEventLog
"USER_DELETE" => "[USER_DELETE] " . GetMessage("MAIN_EVENTLOG_USER_DELETE"),
"USER_INFO" => "[USER_INFO] " . GetMessage("MAIN_EVENTLOG_USER_INFO"),
"USER_LOGIN" => "[USER_LOGIN] " . GetMessage("MAIN_EVENTLOG_USER_LOGIN"),
"USER_LOGIN_INCORRECT_CAPTCHA" => "[USER_LOGIN_INCORRECT_CAPTCHA] " . GetMessage("MAIN_EVENTLOG_USER_LOGIN_INCORRECT_CAPTCHA"),
"USER_LOGIN_BLOCKED" => "[USER_LOGIN_BLOCKED] " . GetMessage("MAIN_EVENTLOG_USER_LOGIN_BLOCKED"),
"USER_LOGIN_NOT_FOUND" => "[USER_LOGIN_NOT_FOUND] " . GetMessage("MAIN_EVENTLOG_USER_LOGIN_NOT_FOUND"),
"USER_LOGINBYHASH" => "[USER_LOGINBYHASH] " . GetMessage("MAIN_EVENTLOG_USER_LOGINBYHASH_FAILED"),
"USER_LOGOUT" => "[USER_LOGOUT] " . GetMessage("MAIN_EVENTLOG_USER_LOGOUT"),
"USER_PASSWORD_CHANGED" => "[USER_PASSWORD_CHANGED] " . GetMessage("MAIN_EVENTLOG_USER_PASSWORD_CHANGED"),

View File

@@ -8,6 +8,7 @@
use Bitrix\Main\Mail;
use Bitrix\Main\Mail\Internal\EventTypeTable;
use Bitrix\Main\ORM\Query\Query;
IncludeModuleLangFile(__FILE__);
@@ -947,7 +948,7 @@ class CEventType
$arSearch['!EVENT_NAME'] = null;
$arQuerySelect = ['ID1' => 'EVENT_NAME', 'EVENT_NAME1' => 'EVENT_NAME'];
$query1 = new \Bitrix\Main\Entity\Query(Mail\Internal\EventMessageTable::getEntity());
$query1 = new Query(Mail\Internal\EventMessageTable::getEntity());
$query1->setSelect($arQuerySelect);
$query1->setFilter(array_merge($arSearch, $arSearch1));
$query1->registerRuntimeField('EVENT_MESSAGE_TYPE', [
@@ -955,7 +956,7 @@ class CEventType
'reference' => ['=this.EVENT_NAME' => 'ref.EVENT_NAME'],
]);
$query2 = new \Bitrix\Main\Entity\Query(Mail\Internal\EventTypeTable::getEntity());
$query2 = new Query(Mail\Internal\EventTypeTable::getEntity());
$query2->setSelect($arQuerySelect);
$query2->setFilter(array_merge($arSearch, $arSearch2));
$query2->registerRuntimeField('EVENT_MESSAGE', [

View File

@@ -18,6 +18,7 @@ use Bitrix\Main\File\Image\Rectangle;
use Bitrix\Main\File\Internal;
use Bitrix\Main\ORM\Query;
use Bitrix\Main\Security;
use Bitrix\Main\Web\Http\Range;
IncludeModuleLangFile(__FILE__);
@@ -2786,15 +2787,15 @@ function ImgShw(ID, width, height, alt)
/**
* @param int|array $arFile
* @param array $arOptions
* @param array $options
* @return bool
*/
public static function ViewByUser($arFile, $arOptions = [])
public static function ViewByUser($arFile, $options = [])
{
$previewManager = new Viewer\PreviewManager();
if ($previewManager->isInternalRequest($arFile, $arOptions))
if ($previewManager->isInternalRequest($arFile, $options))
{
$previewManager->processViewByUserRequest($arFile, $arOptions);
$previewManager->processViewByUserRequest($arFile, $options);
}
/** @global CMain $APPLICATION */
@@ -2802,46 +2803,41 @@ function ImgShw(ID, width, height, alt)
$fastDownload = (COption::GetOptionString('main', 'bx_fast_download', 'N') == 'Y');
$attachment_name = "";
$content_type = "";
$specialchars = false;
$force_download = false;
$cache_time = 10800;
$attachmentName = "";
$contentType = "";
$forceDownload = false;
$cacheTime = 10800;
$fromClouds = false;
$filename = '';
$fromTemp = false;
if (is_array($arOptions))
if (is_array($options))
{
if (isset($arOptions["content_type"]))
if (isset($options["content_type"]))
{
$content_type = $arOptions["content_type"];
$contentType = $options["content_type"];
}
if (isset($arOptions["specialchars"]))
if (isset($options["force_download"]))
{
$specialchars = $arOptions["specialchars"];
$forceDownload = $options["force_download"];
}
if (isset($arOptions["force_download"]))
if (isset($options["cache_time"]))
{
$force_download = $arOptions["force_download"];
$cacheTime = intval($options["cache_time"]);
}
if (isset($arOptions["cache_time"]))
if (isset($options["attachment_name"]))
{
$cache_time = intval($arOptions["cache_time"]);
$attachmentName = $options["attachment_name"];
}
if (isset($arOptions["attachment_name"]))
if (isset($options["fast_download"]))
{
$attachment_name = $arOptions["attachment_name"];
}
if (isset($arOptions["fast_download"]))
{
$fastDownload = (bool)$arOptions["fast_download"];
$fastDownload = (bool)$options["fast_download"];
}
}
if ($cache_time < 0)
if ($cacheTime < 0)
{
$cache_time = 0;
$cacheTime = 0;
}
if (is_array($arFile))
@@ -2878,21 +2874,21 @@ function ImgShw(ID, width, height, alt)
return false;
}
if ($content_type == '' && isset($arFile["CONTENT_TYPE"]))
if ($contentType == '' && isset($arFile["CONTENT_TYPE"]))
{
$content_type = $arFile["CONTENT_TYPE"];
$contentType = $arFile["CONTENT_TYPE"];
}
//we produce resized jpg for original bmp
if ($content_type == '' || $content_type == "image/bmp")
if ($contentType == '' || $contentType == "image/bmp")
{
if (isset($arFile["tmp_name"]))
{
$content_type = static::GetContentType($arFile["tmp_name"], true);
$contentType = static::GetContentType($arFile["tmp_name"], true);
}
else
{
$content_type = static::GetContentType($_SERVER["DOCUMENT_ROOT"] . $filename);
$contentType = static::GetContentType($_SERVER["DOCUMENT_ROOT"] . $filename);
}
}
@@ -2915,30 +2911,25 @@ function ImgShw(ID, width, height, alt)
$name = str_replace(["\n", "\r"], '', $name);
if ($attachment_name)
if ($attachmentName)
{
$attachment_name = str_replace(["\n", "\r"], '', $attachment_name);
$attachmentName = str_replace(["\n", "\r"], '', $attachmentName);
}
else
{
$attachment_name = $name;
$attachmentName = $name;
}
if (!$force_download)
if (!$forceDownload)
{
if (!static::IsImage($name, $content_type) || $arFile["HEIGHT"] <= 0 || $arFile["WIDTH"] <= 0)
if (!static::IsImage($name, $contentType) || $arFile["HEIGHT"] <= 0 || $arFile["WIDTH"] <= 0)
{
//only valid images can be downloaded inline
$force_download = true;
$forceDownload = true;
}
}
$content_type = Web\MimeType::normalize($content_type);
if ($force_download)
{
$specialchars = false;
}
$contentType = Web\MimeType::normalize($contentType);
$src = null;
$file = null;
@@ -2947,7 +2938,7 @@ function ImgShw(ID, width, height, alt)
{
$file = new IO\File($_SERVER['DOCUMENT_ROOT'] . $filename);
}
elseif (isset($arFile['tmp_name']))
elseif (!empty($arFile['tmp_name']))
{
$file = new IO\File($arFile['tmp_name']);
}
@@ -2978,35 +2969,43 @@ function ImgShw(ID, width, height, alt)
$APPLICATION->RestartBuffer();
$APPLICATION->EndBufferContentMan();
$cur_pos = 0;
$response = \Bitrix\Main\Context::getCurrent()->getResponse();
$curPos = 0;
$filesize = (isset($arFile["FILE_SIZE"]) && (int)$arFile["FILE_SIZE"] > 0 ? (int)$arFile["FILE_SIZE"] : (int)($arFile["size"] ?? 0));
$size = $filesize - 1;
$p = strpos($_SERVER["HTTP_RANGE"] ?? '', "=");
if (intval($p) > 0)
$contentLength = $filesize;
$range = null;
$acceptRanged = is_resource($src) || $fastDownload;
if (!empty($_SERVER["HTTP_RANGE"]) && $acceptRanged)
{
$bytes = substr($_SERVER["HTTP_RANGE"], $p + 1);
$p = strpos($bytes, "-");
if ($p !== false)
$ranges = Range::createFromString($_SERVER["HTTP_RANGE"], $filesize);
if ($ranges === null || count($ranges) > 1)
{
$cur_pos = (float)substr($bytes, 0, $p);
$size = (float)substr($bytes, $p + 1);
if ($size <= 0)
{
$size = $filesize - 1;
}
if ($cur_pos > $size)
{
$cur_pos = 0;
$size = $filesize - 1;
}
// TODO: Multiple ranges are not supported
$response
->setStatus("416 Requested Range Not Satisfiable")
->addHeader("Content-Range", "bytes */$filesize")
;
$response->writeHeaders();
self::terminate();
}
$range = $ranges[0];
$curPos = $range->getStart();
$size = $range->getEnd();
$contentLength = $size - $curPos + 1;
}
if ($file instanceof IO\File)
{
$filetime = $file->getModificationTime();
}
elseif (isset($arFile["tmp_name"]) && $arFile["tmp_name"] <> '')
elseif (!empty($arFile["tmp_name"]))
{
$tmpFile = new IO\File($arFile["tmp_name"]);
$filetime = $tmpFile->getModificationTime();
@@ -3016,32 +3015,40 @@ function ImgShw(ID, width, height, alt)
$filetime = intval(MakeTimeStamp($arFile["TIMESTAMP_X"]));
}
$response = \Bitrix\Main\Context::getCurrent()->getResponse();
if ($_SERVER["REQUEST_METHOD"] == "HEAD")
{
$response->setStatus("200 OK")
->addHeader("Accept-Ranges", "bytes")
->addHeader("Content-Type", $content_type)
->addHeader("Content-Length", ($size - $cur_pos + 1))
$response
->setStatus("200 OK")
->addHeader("Content-Type", $contentType)
->addHeader("Content-Length", $contentLength)
;
if ($acceptRanged)
{
// ranges are supported only for local files
$response->addHeader("Accept-Ranges", "bytes");
}
if ($filetime > 0)
{
$response->addHeader("Last-Modified", date("r", $filetime));
}
$response->writeHeaders();
}
else
{
$lastModified = '';
if ($cache_time > 0)
if ($cacheTime > 0)
{
//Handle ETag
$ETag = md5($filename . $filesize . $filetime);
if (array_key_exists("HTTP_IF_NONE_MATCH", $_SERVER) && ($_SERVER['HTTP_IF_NONE_MATCH'] === $ETag))
if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] === $ETag)
{
$response->setStatus("304 Not Modified");
$response->addHeader("Cache-Control", "private, max-age=" . $cache_time . ", pre-check=" . $cache_time);
$response
->setStatus("304 Not Modified")
->addHeader("Cache-Control", "private, max-age=" . $cacheTime . ", pre-check=" . $cacheTime)
;
$response->writeHeaders();
self::terminate();
@@ -3053,10 +3060,12 @@ function ImgShw(ID, width, height, alt)
if ($filetime > 0)
{
$lastModified = gmdate('D, d M Y H:i:s', $filetime) . ' GMT';
if (array_key_exists("HTTP_IF_MODIFIED_SINCE", $_SERVER) && ($_SERVER['HTTP_IF_MODIFIED_SINCE'] === $lastModified))
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] === $lastModified)
{
$response->setStatus("304 Not Modified");
$response->addHeader("Cache-Control", "private, max-age=" . $cache_time . ", pre-check=" . $cache_time);
$response
->setStatus("304 Not Modified")
->addHeader("Cache-Control", "private, max-age=" . $cacheTime . ", pre-check=" . $cacheTime)
;
$response->writeHeaders();
self::terminate();
@@ -3064,54 +3073,40 @@ function ImgShw(ID, width, height, alt)
}
}
$utfName = Uri::urnEncode($attachment_name);
$translitName = CUtil::translit($attachment_name, LANGUAGE_ID, [
$utfName = Uri::urnEncode($attachmentName);
$translitName = CUtil::translit($attachmentName, LANGUAGE_ID, [
"max_len" => 1024,
"safe_chars" => ".",
"replace_space" => '-',
"change_case" => false,
]);
if ($force_download)
// $range shows that we are sending partial content (range request)
if ($range)
{
//Disable zlib for old versions of php <= 5.3.0
//it has broken Content-Length handling
if (ini_get('zlib.output_compression'))
{
ini_set('zlib.output_compression', 'Off');
}
// $p shows that we are sending partial content (range request)
if ($p)
{
$response->setStatus("206 Partial Content");
}
else
{
$response->SetStatus("200 OK");
}
$response->addHeader("Content-Type", $content_type)
->addHeader("Content-Disposition", "attachment; filename=\"" . $translitName . "\"; filename*=utf-8''" . $utfName)
->addHeader("Content-Transfer-Encoding", "binary")
->addHeader("Content-Length", ($size - $cur_pos + 1))
$response
->setStatus("206 Partial Content")
->addHeader("Accept-Ranges", "bytes")
->addHeader("Content-Range", "bytes " . $range->getStart() . "-" . $range->getEnd() . "/" . $filesize)
;
if (is_resource($src))
{
$response->addHeader("Accept-Ranges", "bytes");
$response->addHeader("Content-Range", "bytes " . $cur_pos . "-" . $size . "/" . $filesize);
}
}
else
{
$response->addHeader("Content-Type", $content_type);
$response->addHeader("Content-Disposition", "inline; filename=\"" . $translitName . "\"; filename*=utf-8''" . $utfName);
$response->SetStatus("200 OK");
}
if ($cache_time > 0)
$contentDisposition = $forceDownload ? "attachment" : "inline";
$response
->addHeader("Content-Type", $contentType)
->addHeader("Content-Disposition", $contentDisposition . "; filename=\"" . $translitName . "\"; filename*=utf-8''" . $utfName)
->addHeader("Content-Transfer-Encoding", "binary")
->addHeader('Content-Length', $contentLength)
;
if ($cacheTime > 0)
{
$response->addHeader("Cache-Control", "private, max-age=" . $cache_time . ", pre-check=" . $cache_time);
$response->addHeader("Cache-Control", "private, max-age=" . $cacheTime . ", pre-check=" . $cacheTime);
if ($filetime > 0)
{
$response->addHeader('Last-Modified', $lastModified);
@@ -3122,80 +3117,66 @@ function ImgShw(ID, width, height, alt)
$response->addHeader("Cache-Control", "no-cache, must-revalidate, post-check=0, pre-check=0");
}
$response->addHeader("Expires", "0");
$response->addHeader("Pragma", "public");
$response
->addHeader("Expires", "0")
->addHeader("Pragma", "public")
;
$filenameEncoded = Uri::urnEncode($filename);
// Download from front-end
if ($fastDownload)
{
// Download from front-end
$filenameEncoded = Uri::urnEncode($filename);
if ($fromClouds)
{
$filenameDisableProto = preg_replace('~^(https?)(\://)~i', '\\1.', $filenameEncoded);
$filenameDisableProto = preg_replace('~^(https?)(://)~i', '\\1.', $filenameEncoded);
$cloudUploadPath = COption::GetOptionString('main', 'bx_cloud_upload', '/upload/bx_cloud_upload/');
$response->addHeader('X-Accel-Redirect', rawurlencode($cloudUploadPath . $filenameDisableProto));
}
else
{
$response->addHeader('X-Accel-Redirect', $filenameEncoded);
$filenameEncoded = rawurlencode($cloudUploadPath . $filenameDisableProto);
}
$response->addHeader('X-Accel-Redirect', $filenameEncoded);
$response->writeHeaders();
self::terminate();
}
else
{
ini_set('zlib.output_compression', 'Off');
session_write_close();
$response->writeHeaders();
if ($specialchars)
if (is_resource($src))
{
// read local file
/** @var IO\File $file */
echo "<", "pre", ">";
if (is_resource($src))
$file->seek($curPos);
while (!feof($src) && ($curPos <= $size))
{
while (!feof($src))
$bufsize = 131072; //128K
if ($curPos + $bufsize > $size)
{
echo htmlspecialcharsbx(fread($src, 32768));
$bufsize = $size - $curPos + 1;
}
$file->close();
$curPos += $bufsize;
echo fread($src, $bufsize);
}
else
{
/** @var Web\HttpClient $src */
echo htmlspecialcharsbx($src->get($filenameEncoded));
}
echo "<", "/pre", ">";
$file->close();
}
else
{
if (is_resource($src))
{
/** @var IO\File $file */
$file->seek($cur_pos);
while (!feof($src) && ($cur_pos <= $size))
{
$bufsize = 131072; //128K
if ($cur_pos + $bufsize > $size)
{
$bufsize = $size - $cur_pos + 1;
}
$cur_pos += $bufsize;
echo fread($src, $bufsize);
}
$file->close();
}
else
{
$fp = fopen("php://output", "wb");
/** @var Web\HttpClient $src */
$src->setOutputStream($fp);
$src->get($filenameEncoded);
}
// download file by URI
$filenameEncoded = Uri::urnEncode($filename);
$fp = fopen("php://output", "wb");
/** @var Web\HttpClient $src */
$src->setOutputStream($fp);
$src->get($filenameEncoded);
}
flush();
self::terminate();
}
}
self::terminate();
return true;
}

View File

@@ -51,7 +51,14 @@ class CAllGroup
}
$fields = $arFields;
unset($fields["USER_ID"]);
unset($fields['~ID']);
unset($fields['USER_ID']);
if (isset($arFields['~ID']))
{
$fields['ID'] = $arFields['~ID'];
}
$result = GroupTable::add($fields);
$ID = $result->getId();

View File

@@ -518,37 +518,44 @@ class CHTTP
/**
* @deprecated Use \Bitrix\Main\Web\Uri::addParams().
*/
public static function urlAddParams($url, $add_params, $options = array())
public static function urlAddParams($url, $add_params, $options = [])
{
if(!empty($add_params))
if (!empty($add_params))
{
$params = array();
foreach($add_params as $name => $value)
$params = [];
foreach ($add_params as $name => $value)
{
if(($options["skip_empty"] ?? false) && (string)$value == '')
continue;
if(($options["encode"] ?? false))
$params[] = urlencode($name).'='.urlencode($value);
else
$params[] = $name.'='.$value;
}
if(!empty($params))
{
$p1 = mb_strpos($url, "?");
if($p1 === false)
$ch = "?";
else
$ch = "&";
$p2 = mb_strpos($url, "#");
if($p2===false)
if (is_array($value))
{
$url = $url.$ch.implode("&", $params);
// arrays are unsupported, use \Bitrix\Main\Web\Uri::addParams()
continue;
}
if (!empty($options["skip_empty"]) && (string)$value == '')
{
continue;
}
if (!empty($options["encode"]))
{
$params[] = urlencode($name) . '=' . urlencode($value);
}
else
{
$url = mb_substr($url, 0, $p2).$ch.implode("&", $params).mb_substr($url, $p2);
$params[] = $name . '=' . $value;
}
}
if (!empty($params))
{
$ch = (mb_strpos($url, "?") === false ? "?" : "&");
$p2 = mb_strpos($url, "#");
if ($p2 === false)
{
$url = $url . $ch . implode("&", $params);
}
else
{
$url = mb_substr($url, 0, $p2) . $ch . implode("&", $params) . mb_substr($url, $p2);
}
}
}

View File

@@ -130,84 +130,6 @@ class CUpdateSystem
return true;
}
/** Активирует лицензионный ключ **/
public static function ActivateLicenseKey($arFields, &$strError, $lang = false, $stableVersionsOnly = "Y")
{
$strError_tmp = "";
CUpdateSystem::AddMessage2Log("exec CUpdateSystem::ActivateLicenseKey");
$stableVersionsOnly = (($stableVersionsOnly == "N") ? "N" : "Y");
if ($lang===false)
$lang = LANGUAGE_ID;
$GLOBALS["DB"]->GetVersion();
$strVars = "LICENSE_KEY=".urlencode(md5(CUpdateSystem::GetLicenseKey())).
"&CLIENT_SITE=".urlencode($_SERVER["SERVER_NAME"]).
"&CANGZIP=".urlencode((CUpdateSystem::IsGzipInstalled()) ? "Y" : "N").
"&UTYPES=".urlencode("A").
"&COUNT_ONLY=".urlencode("N").
"&SUPD_STS=".urlencode(CUpdateSystem::GetFooPath("GetList")).
"&SUPD_DBS=".urlencode($GLOBALS["DB"]->type).
"&XE=".urlencode((isset($GLOBALS["DB"]->XE) && $GLOBALS["DB"]->XE) ? "Y" : "N").
"&SUPD_VER=".urlencode(UPDATE_SYSTEM_VERSION).
"&CLIENT_PHPVER=".urlencode(phpversion()).
"&stable=".urlencode($stableVersionsOnly).
"&lang=".urlencode($lang);
foreach ($arFields as $key => $value)
{
$strVars .= "&".$key."=".urlencode($value);
}
CUpdateSystem::AddMessage2Log(preg_replace("/LICENSE_KEY=[^&]*/i", "LICENSE_KEY=X", $strVars));
$stime = microtime(true);
$content = CUpdateSystem::getHTTPPage("bit_sysserver.php", $strVars, $strError_tmp);
CUpdateSystem::AddMessage2Log("TIME ActivateLicenseKey.getHTTPPage ".round(microtime(true)-$stime,3)." sec");
if ($content == '')
$strError_tmp .= "[UALK01] ".GetMessage("SUPP_AS_EMPTY_RESP").".<br>";
if ($strError_tmp == '')
{
$arRes = Array();
CUpdateSystem::ParseServerData($content, $arRes, $strError_tmp);
}
if ($strError_tmp == '')
{
if (isset($arRes["DATA"]["#"]["ERROR"])
&& is_array($arRes["DATA"]["#"]["ERROR"])
&& !empty($arRes["DATA"]["#"]["ERROR"]))
{
for ($i = 0, $n = count($arRes["DATA"]["#"]["ERROR"]); $i < $n; $i++)
{
if ($arRes["DATA"]["#"]["ERROR"][$i]["@"]["TYPE"] <> '')
$strError_tmp .= "[".$arRes["DATA"]["#"]["ERROR"][$i]["@"]["TYPE"]."] ";
$strError_tmp .= $arRes["DATA"]["#"]["ERROR"][$i]["#"].".<br>";
}
}
}
if ($strError_tmp == '')
{
CUpdateSystem::AddMessage2Log("License key activated successfully!", "CUALK");
}
if ($strError_tmp <> '')
{
CUpdateSystem::AddMessage2Log($strError_tmp, "CUALK");
$strError .= $strError_tmp;
return false;
}
else
return true;
}
// Регистрирует копию продукта, если можно
public static function RegisterVersion(&$strError, $lang = false, $stableVersionsOnly = "Y")
{

File diff suppressed because one or more lines are too long

View File

@@ -1720,6 +1720,7 @@ class CAllUser extends CDBResult
$result_message = true;
$user_id = 0;
$error = [];
$context = (new Authentication\Context())
->setMethod(Method::Password)
;
@@ -1777,7 +1778,7 @@ class CAllUser extends CDBResult
if ($user_id <= 0)
{
//internal authentication OR application password for external user
$user_id = static::LoginInternal($arParams, $result_message, $context);
$user_id = static::LoginInternal($arParams, $result_message, $context, $error);
if ($user_id <= 0)
{
@@ -1885,7 +1886,10 @@ class CAllUser extends CDBResult
if ($doAuthorize && $result_message !== true && (Option::get('main', 'event_log_login_fail', 'N') === 'Y'))
{
CEventLog::Log(CEventLog::SEVERITY_SECURITY, 'USER_LOGIN', 'main', $login, $result_message['MESSAGE']);
$auditType = $error['auditType'] ?? 'USER_LOGIN';
$info = $error['info'] ?? [];
$info['message'] = $result_message['MESSAGE'];
CEventLog::Log(CEventLog::SEVERITY_SECURITY, $auditType, 'main', $login, $info);
}
return $arParams["RESULT_MESSAGE"];
@@ -1896,9 +1900,10 @@ class CAllUser extends CDBResult
* @param array $arParams
* @param array|bool $result_message
* @param Authentication\Context|null $context
* @param array $error
* @return int User ID on success or 0 on failure. Additionally, $result_message will hold an error.
*/
public static function LoginInternal(&$arParams, &$result_message = true, $context = null)
public static function LoginInternal(&$arParams, &$result_message = true, $context = null, &$error = [])
{
global $DB, $APPLICATION;
@@ -1932,6 +1937,13 @@ class CAllUser extends CDBResult
$original = isset($arParams["PASSWORD_ORIGINAL"]) && $arParams["PASSWORD_ORIGINAL"] === 'Y';
$loginAttempts = intval($arUser["LOGIN_ATTEMPTS"]) + 1;
$error['info'] = [
'userId' => $arUser["ID"],
'active' => $arUser["ACTIVE"],
'blocked' => $arUser["BLOCKED"],
'loginAttempts' => $loginAttempts,
];
if ($arUser["BLOCKED"] != 'Y')
{
$policy = static::getPolicy($arUser["ID"]);
@@ -1944,6 +1956,9 @@ class CAllUser extends CDBResult
$APPLICATION->SetNeedCAPTHA(true);
if (!$APPLICATION->CaptchaCheckCode($_REQUEST["captcha_word"] ?? '', $_REQUEST["captcha_sid"] ?? ''))
{
$error['auditType'] = 'USER_LOGIN_INCORRECT_CAPTCHA';
$error['info']['policyLoginAttempts'] = $policyLoginAttempts;
$correctCaptcha = false;
}
}
@@ -2001,6 +2016,10 @@ class CAllUser extends CDBResult
}
}
}
else
{
$error['auditType'] = 'USER_LOGIN_BLOCKED';
}
if ($passwordCorrect)
{
@@ -2029,6 +2048,7 @@ class CAllUser extends CDBResult
{
//require to change the password right now
$passwordExpired = true;
$error['info']['passwordExpired'] = 'Y';
}
if (!$passwordExpired && $original && $policy->getPasswordCheckPolicy())
{
@@ -2037,6 +2057,7 @@ class CAllUser extends CDBResult
{
//require to change the password because it doesn't match the group policy
$passwordExpired = true;
$error['info']['passwordExpired'] = 'Policy';
}
}
if (!$passwordExpired)
@@ -2048,6 +2069,8 @@ class CAllUser extends CDBResult
if (UserPasswordTable::passwordExpired($arUser["ID"], $policyChangeDays))
{
$passwordExpired = true;
$error['info']['passwordExpired'] = 'Days';
$error['info']['passwordExpiredDays'] = $policyChangeDays;
}
}
}
@@ -2099,6 +2122,10 @@ class CAllUser extends CDBResult
$DB->Query("UPDATE b_user SET LOGIN_ATTEMPTS = " . $loginAttempts . ", TIMESTAMP_X = TIMESTAMP_X WHERE ID = " . intval($arUser["ID"]));
}
}
else
{
$error['auditType'] = 'USER_LOGIN_NOT_FOUND';
}
if ($user_id == 0)
{
@@ -4328,10 +4355,17 @@ class CAllUser extends CDBResult
return $groups;
}
public static function GetCount()
public static function GetCount($maxCount = 0)
{
global $DB;
$r = $DB->Query("SELECT COUNT('x') as C FROM b_user");
if ($maxCount > 0)
{
$r = $DB->Query("SELECT COUNT('x') as C FROM (SELECT ID from b_user limit " . intval($maxCount) . ") t");
}
else
{
$r = $DB->Query("SELECT COUNT('x') as C FROM b_user");
}
$r = $r->Fetch();
return intval($r["C"]);
}

View File

@@ -2,7 +2,7 @@
use Bitrix\Main\Application;
use Bitrix\Main\DB\SqlExpression;
use Bitrix\Main\Entity;
use Bitrix\Main\ORM\Fields;
use Bitrix\Main\Localization\Loc;
use Bitrix\Main\Text\HtmlFilter;
use Bitrix\Main\UI\FileInputUtility;
@@ -98,7 +98,7 @@ class CUserTypeManager
if ($arUserField['MULTIPLE'] == 'Y')
{
$sqlHelper = \Bitrix\Main\Application::getConnection()->getSqlHelper();
return $sqlHelper->getColumnTypeByField(new Entity\TextField('TMP'));
return $sqlHelper->getColumnTypeByField(new Fields\TextField('TMP'));
}
else
{
@@ -2478,7 +2478,7 @@ class CUserTypeManager
* @param null|string $fieldName
* @param array $fieldParameters
*
* @return Entity\DatetimeField|Entity\FloatField|Entity\IntegerField|Entity\StringField|mixed
* @return Fields\DatetimeField|Fields\FloatField|Fields\IntegerField|Fields\StringField|mixed
* @throws Bitrix\Main\ArgumentException
*/
public function getEntityField($arUserField, $fieldName = null, $fieldParameters = [])
@@ -2494,7 +2494,7 @@ class CUserTypeManager
}
elseif ($arUserField['USER_TYPE']['USER_TYPE_ID'] == 'date')
{
$field = new Entity\DateField($fieldName, $fieldParameters);
$field = new Fields\DateField($fieldName, $fieldParameters);
}
else
{
@@ -2503,22 +2503,22 @@ class CUserTypeManager
case 'int':
case 'enum':
case 'file':
$field = (new Entity\IntegerField($fieldName, $fieldParameters))
$field = (new Fields\IntegerField($fieldName, $fieldParameters))
->configureNullable()
;
break;
case 'double':
$field = (new Entity\FloatField($fieldName, $fieldParameters))
$field = (new Fields\FloatField($fieldName, $fieldParameters))
->configureNullable()
;
break;
case 'string':
$field = (new Entity\StringField($fieldName, $fieldParameters))
$field = (new Fields\StringField($fieldName, $fieldParameters))
->configureNullable()
;
break;
case 'datetime':
$field = (new Entity\DatetimeField($fieldName, $fieldParameters))
$field = (new Fields\DatetimeField($fieldName, $fieldParameters))
->configureNullable()
->configureUseTimezone(isset($arUserField['SETTINGS']['USE_TIMEZONE']) && $arUserField['SETTINGS']['USE_TIMEZONE'] == 'Y')
;
@@ -2542,12 +2542,12 @@ class CUserTypeManager
}
/**
* @param $arUserField
* @param Entity\ScalarField $entityField
* @param $arUserField
* @param Fields\ScalarField $entityField
*
* @return Entity\ReferenceField[]
* @return Fields\Relations\Reference[]
*/
public function getEntityReferences($arUserField, Entity\ScalarField $entityField)
public function getEntityReferences($arUserField, Fields\ScalarField $entityField)
{
if (is_callable([$arUserField['USER_TYPE']['CLASS_NAME'], 'getEntityReferences']))
{

View File

@@ -1,3 +1,3 @@
<?php
define("SM_VERSION","25.600.100");
define("SM_VERSION_DATE","2025-08-15 13:00:00"); // YYYY-MM-DD HH:MI:SS
define("SM_VERSION", "25.750.0");
define("SM_VERSION_DATE", "2025-09-09 10:49:18"); // YYYY-MM-DD HH:MI:SS