Exemple #1
1
 private static function getUserFromForum($userId)
 {
     if ($userId > 0 && !array_key_exists($userId, self::$users)) {
         self::$users[$userId] = \CForumUser::getListEx(array(), array("USER_ID" => $userId))->fetch();
         if (!self::$users[$userId]) {
             self::$users[$userId] = \CUser::getById($userId)->fetch();
             self::$users[$userId]["SHOW_NAME"] = \COption::getOptionString("forum", "USER_SHOW_NAME", "Y");
         }
     }
     return self::$users[$userId];
 }
Exemple #2
0
 public static function getDirStructure($bLogical, $site, $path)
 {
     global $USER;
     $arDirContent = array();
     if ($USER->CanDoFileOperation('fm_view_listing', array($site, $path))) {
         \Bitrix\Main\Loader::includeModule('fileman');
         $arDirs = array();
         $arFiles = array();
         \CFileMan::GetDirList(array($site, $path), $arDirs, $arFiles, array(), array("NAME" => "asc"), "DF", $bLogical, true);
         $arDirContent_t = array_merge($arDirs, $arFiles);
         for ($i = 0, $l = count($arDirContent_t); $i < $l; $i++) {
             $file = $arDirContent_t[$i];
             $arPath = array($site, $file['ABS_PATH']);
             if ($file["TYPE"] == "F" && !$USER->CanDoFileOperation('fm_view_file', $arPath) || $file["TYPE"] == "D" && !$USER->CanDoFileOperation('fm_view_listing', $arPath) || $file["TYPE"] == "F" && $file["NAME"] == ".section.php") {
                 continue;
             }
             $f = $file['TYPE'] == 'F' ? new \Bitrix\Main\IO\File($file['PATH'], $site) : new \Bitrix\Main\IO\Directory($file['PATH'], $site);
             $p = $f->getName();
             if ($f->isSystem() || $file['TYPE'] == 'F' && in_array($p, array("urlrewrite.php")) || $file['TYPE'] == 'D' && preg_match("/\\/(bitrix|" . \COption::getOptionString("main", "upload_dir", "upload") . ")\\//", "/" . $p . "/")) {
                 continue;
             }
             $arFileData = array('NAME' => $bLogical ? $file['LOGIC_NAME'] : $p, 'FILE' => $p, 'TYPE' => $file['TYPE'], 'DATA' => $file);
             if (strlen($arFileData['NAME']) <= 0) {
                 $arFileData['NAME'] = GetMessage('SEO_DIR_LOGICAL_NO_NAME');
             }
             $arDirContent[] = $arFileData;
         }
         unset($arDirContent_t);
     }
     return $arDirContent;
 }
Exemple #3
0
	function __construct($pCustomOptions = array(), $pChar = "")
	{
		if(isset($pCustomOptions["action"]))
		{
			$this->setAction($pCustomOptions["action"]);
		}
		else
		{
			$this->setAction(COption::getOptionString("security", "filter_action"));
		}

		if(isset($pCustomOptions["stop"]))
		{
			$this->setStop($pCustomOptions["stop"]);
		}
		else
		{
			$this->setStop(COption::getOptionString("security", "filter_stop"));
		}

		if(isset($pCustomOptions["log"]))
		{
			$this->setLog($pCustomOptions["log"]);
		}
		else
		{
			$this->setLog(COption::getOptionString("security", "filter_log"));
		}

		$this->auditors = array();
		$this->auditors["XSS"] = new CSecurityFilterXssAuditor($pChar);
		$this->auditors["SQL"] = new CSecurityFilterSqlAuditor($pChar);
		$this->auditors["PHP"] = new CSecurityFilterPathAuditor($pChar);
	}
Exemple #4
0
 /**
  * Get url to view entity of storage (ex. user profile, group profile, etc)
  * By default: folder list
  * @return string
  */
 public function getEntityUrl()
 {
     $groupPage = \COption::getOptionString("socialnetwork", "workgroups_page", false, SITE_ID);
     if (!$groupPage) {
         $groupPage = SITE_DIR . 'workgroups/';
     }
     return $groupPage . 'group/' . $this->entityId . '/';
 }
Exemple #5
0
 /**
  * Get url to view entity of storage (ex. user profile, group profile, etc)
  * By default: folder list
  * @return string
  */
 public function getEntityUrl()
 {
     $userPage = \COption::getOptionString("socialnetwork", "user_page", false, SITE_ID);
     if (!$userPage) {
         $userPage = SITE_DIR . 'company/personal/';
     }
     return $userPage . 'user/' . $this->entityId . '/';
 }
 public static function getOption($module_name, $name, $default_value)
 {
     if (class_exists('\\Bitrix\\Main\\Config\\Option')) {
         $result = \Bitrix\Main\Config\Option::get($module_name, $name, $default_value);
     } else {
         $result = \COption::getOptionString($module_name, $name, $default_value);
     }
     return $result;
 }
Exemple #7
0
 /**
  * Get name of entity (ex. user last name + first name, group name, etc)
  * By default: get title
  * @return string
  */
 public function getEntityUrl()
 {
     /** @noinspection PhpDynamicAsStaticMethodCallInspection */
     $userPage = \COption::getOptionString("socialnetwork", "user_page", false, CExtranet::getExtranetSiteID());
     if (!$userPage) {
         $userPage = '/extranet/contacts/personal//';
     }
     return $userPage . 'user/' . $this->entityId . '/';
 }
Exemple #8
0
 /**
  * Get url to view entity of storage (ex. user profile, group profile, etc)
  * By default: folder list
  * @return string
  */
 public function getEntityUrl()
 {
     if ($this->getUser()->isExtranetUser()) {
         $extranetUser = new ExtranetUser($this->entityId, $this->storage, $this->entityMiscData);
         return $extranetUser->getEntityUrl();
     }
     $userPage = \COption::getOptionString("socialnetwork", "user_page", false, SITE_ID);
     if (!$userPage) {
         $userPage = SITE_DIR . 'company/personal/';
     }
     return $userPage . 'user/' . $this->entityId . '/';
 }
Exemple #9
0
 public function __construct($customOptions = array(), $char = "")
 {
     if (isset($customOptions["stop"])) {
         $this->doBlock = $customOptions["stop"];
     } else {
         $this->doBlock = \COption::getOptionString("security", "filter_stop") === 'Y';
     }
     $this->requestFilter = new Filter\Request($customOptions);
     $this->serverFilter = new Filter\Server($customOptions);
     $this->context = \Bitrix\Main\Application::getInstance()->getContext();
     $this->splittingChar = $char;
 }
Exemple #10
0
function prepareUserData($user)
{
    $user['DETAIL_URL'] = COption::getOptionString('intranet', 'search_user_url', '/user/#ID#/');
    $user['DETAIL_URL'] = str_replace(array('#ID#', '#USER_ID#'), array($user['ID'], $user['ID']), $user['DETAIL_URL']);
    $user['PHOTO_THUMB'] = '<img src="/bitrix/components/bitrix/main.user.link/templates/.default/images/nopic_30x30.gif" border="0" alt="" width="32" height="32">';
    if (intval($user['PERSONAL_PHOTO']) > 0) {
        $imageFile = CFile::getFileArray($user['PERSONAL_PHOTO']);
        if ($imageFile !== false) {
            $arFileTmp = CFile::resizeImageGet($imageFile, array('width' => 42, 'height' => 42), BX_RESIZE_IMAGE_EXACT, false);
            $user['PHOTO_THUMB'] = CFile::showImage($arFileTmp['src'], 32, 32);
        }
    }
    return $user;
}
Exemple #11
0
 protected function getCurrentLang()
 {
     $context = $this->getContext();
     $request = $context->getRequest();
     $defaultLang = $request["lang"];
     if ($defaultLang == '') {
         $defaultLang = \COption::getOptionString("main", "admin_lid");
     }
     if ($defaultLang != '') {
         $langDb = LanguageTable::getById($defaultLang);
         if ($language = $langDb->fetch()) {
             return $language;
         }
     }
     return null;
 }
 public function isSystem()
 {
     $isSystem = false;
     if (substr($this->path, 0, strlen($this->documentRoot)) === $this->documentRoot) {
         $relativePath = substr($this->path, strlen($this->documentRoot));
         $relativePath = ltrim($relativePath, "/");
         if (($pos = strpos($relativePath, "/")) !== false) {
             $s = substr($relativePath, 0, $pos);
         } else {
             $s = $relativePath;
         }
         $s = strtolower(rtrim($s, "."));
         $uploadDirName = \COption::getOptionString("main", "upload_dir", "upload");
         if (in_array($s, array("bitrix", $uploadDirName))) {
             $isSystem = true;
         }
     }
     return $isSystem;
 }
Exemple #13
0
 protected function prepareParams()
 {
     $this->arParams['STORAGE_ID'] = isset($this->arParams['DOCUMENT_ID']) ? intval(str_replace('STORAGE_', '', $this->arParams['DOCUMENT_ID'])) : $this->arParams['STORAGE_ID'];
     $this->arParams['SET_TITLE'] = $this->arParams['SET_TITLE'] == 'N' ? 'N' : 'Y';
     $this->arParams['NAME_TEMPLATE'] = empty($this->arParams['NAME_TEMPLATE']) ? COption::getOptionString('bizproc', 'name_template', CSite::getNameFormat(false), SITE_ID) : str_replace(array('#NOBR#', '#/NOBR#'), array('', ''), $this->arParams['NAME_TEMPLATE']);
     if (!isset($this->arParams['MODULE_ID'])) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('BPATT_NO_MODULE_ID'), self::ERROR_COULD_NOT_FIND_MODULE_ID)));
     }
     if (!isset($this->arParams['STORAGE_ID'])) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('BPATT_NO_DOCUMENT_TYPE'), self::ERROR_COULD_NOT_FIND_STORAGE_ID)));
     }
     if ($this->errorCollection->hasErrors()) {
         $error = array_shift($this->getErrors());
         throw new ArgumentException($error->getMessage());
     }
     $this->arParams['DOCUMENT_DATA'] = array('DISK' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocument::generateDocumentComplexType($this->arParams['STORAGE_ID'])), 'WEBDAV' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocumentCompatible::generateDocumentComplexType($this->arParams['STORAGE_ID'])));
     $this->arParams['DOCUMENT_TYPE'] = \Bitrix\Disk\BizProcDocument::generateDocumentType($this->arParams['STORAGE_ID']);
     return $this;
 }
Exemple #14
0
 /**
  * @param bool $pActive
  */
 private function initializeSyslogEngine($pActive = false)
 {
     if ($pActive) {
         $this->isSyslogEngineActive = true;
         if (self::isRunOnWin()) {
             $this->syslogFacility = LOG_USER;
         } else {
             $this->syslogFacility = COption::getOptionString("security", "security_event_syslog_facility");
         }
         $this->syslogPriority = COption::getOptionString("security", "security_event_syslog_priority");
         if (COption::getOptionString("security", "security_event_collect_user_info") == "Y") {
             $this->isUserInfoNeeded = true;
         } else {
             $this->isUserInfoNeeded = false;
         }
         openlog("Bitrix WAF", LOG_ODELAY, $this->syslogFacility);
     } else {
         $this->isSyslogEngineActive = false;
     }
 }
Exemple #15
0
 protected function processActionPerformActionBp()
 {
     if (!Loader::includeModule('bizproc')) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_LAC_MODULE_NOT_INSTALLED'))));
     }
     $this->checkRequiredPostParams(array('iblockTypeId', 'iblockId', 'sectionId', 'workflowId', 'elementId', 'action'));
     if ($this->request->getPost('iblockTypeId') == COption::getOptionString('lists', 'livefeed_iblock_type_id')) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_LAC_UNKNOWN_ERROR'))));
     }
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
     $this->iblockTypeId = $this->request->getPost('iblockTypeId');
     $this->iblockId = $this->request->getPost('iblockId');
     $this->sectionId = $this->request->getPost('sectionId');
     $workflowId = $this->request->getPost('workflowId');
     $elementId = $this->request->getPost('elementId');
     $action = $this->request->getPost('action');
     $this->documentStates = CBPDocument::getDocumentStates(BizProcDocument::generateDocumentComplexType($this->iblockTypeId, $this->iblockId), BizProcDocument::getDocumentComplexId($this->iblockTypeId, $elementId));
     if (isset($this->documentStates[$workflowId]['WORKFLOW_STATUS']) && $this->documentStates[$workflowId]['WORKFLOW_STATUS'] !== null) {
         $this->terminateWorkflow($workflowId, $elementId);
     }
     if ($action == 'delete') {
         if (CBPDocument::canUserOperateDocument(CBPCanUserOperateOperation::CreateWorkflow, $this->getUser(), BizProcDocument::getDocumentComplexId($this->iblockTypeId, $elementId), array("DocumentStates" => $this->documentStates))) {
             CBPTaskService::DeleteByWorkflow($workflowId);
             CBPTrackingService::DeleteByWorkflow($workflowId);
             CBPStateService::DeleteWorkflow($workflowId);
         } else {
             $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_LAC_ACCESS_DENIED'))));
         }
         if ($this->errorCollection->hasErrors()) {
             $this->sendJsonErrorResponse();
         }
     }
     $this->sendJsonSuccessResponse(array('message' => Loc::getMessage('LISTS_LAC_MESSAGE_SUCCESS')));
 }
Exemple #16
0
 private function initializeSyslogEngine()
 {
     $this->isSyslogEngineActive = true;
     if (self::isRunOnWin()) {
         $this->syslogFacility = LOG_USER;
     } else {
         $this->syslogFacility = COption::getOptionString("security", "security_event_syslog_facility");
     }
     $this->syslogPriority = COption::getOptionString("security", "security_event_syslog_priority");
     openlog("Bitrix WAF", LOG_ODELAY, $this->syslogFacility);
 }
Exemple #17
0
	public static function AddMessage($arFields)
	{
		global $DB;

		if (COption::getOptionString('mail', 'disable_log', 'N') == 'Y')
			return;

		$arFields["~DATE_INSERT"] = $DB->GetNowFunction();
		if(array_key_exists('MESSAGE', $arFields))
			$arFields['MESSAGE'] = strval(substr($arFields['MESSAGE'], 0, 255));
		else
			$arFields['MESSAGE'] = '';

		return $DB->Add("b_mail_log", $arFields);
	}
Exemple #18
0
 protected function getWebDavSettings()
 {
     if ($this->webdavSettings !== null) {
         return $this->webdavSettings;
     }
     if (!CModule::IncludeModule('webdav')) {
         throw new RestException('Could not load webdav module.');
     }
     $opt = COption::getOptionString('webdav', 'user_files', null);
     if ($opt == null) {
         throw new RestException('Could not find webdav settings.');
     }
     $user = CCrmSecurityHelper::GetCurrentUser();
     $opt = unserialize($opt);
     $iblockID = intval($opt[CSite::GetDefSite()]['id']);
     $userSectionID = CWebDavIblock::getRootSectionIdForUser($iblockID, $user->GetID());
     if (!is_numeric($userSectionID) || $userSectionID <= 0) {
         throw new RestException('Could not find webdav section for user ' . $user->GetLastName() . '.');
     }
     return $this->webdavSettings = array('IBLOCK_ID' => $iblockID, 'IBLOCK_SECTION_ID' => intval($userSectionID));
 }
Exemple #19
0
 /**
  * @param string $workflowId
  * @param string $iblockType
  * @param int $elementId
  * @param int $iblockId
  * @param string $action Action stop or delete
  * @return string error
  */
 public static function completeWorkflow($workflowId, $iblockType, $elementId, $iblockId, $action)
 {
     if (!Loader::includeModule('bizproc')) {
         return Loc::getMessage('LISTS_MODULE_BIZPROC_NOT_INSTALLED');
     }
     global $USER;
     $userId = $USER->getID();
     $documentType = BizprocDocument::generateDocumentComplexType($iblockType, $iblockId);
     $documentId = BizprocDocument::getDocumentComplexId($iblockType, $elementId);
     $documentStates = CBPDocument::getDocumentStates($documentType, $documentId);
     $permission = CBPDocument::canUserOperateDocument($action == 'stop' ? CBPCanUserOperateOperation::StartWorkflow : CBPCanUserOperateOperation::CreateWorkflow, $userId, $documentId, array("DocumentStates" => $documentStates));
     if (!$permission) {
         return Loc::getMessage('LISTS_ACCESS_DENIED');
     }
     $stringError = '';
     if ($action == 'stop') {
         $errors = array();
         CBPDocument::terminateWorkflow($workflowId, $documentId, $errors);
         if (!empty($errors)) {
             $stringError = '';
             foreach ($errors as $error) {
                 $stringError .= $error['message'];
             }
             $listError[] = array('id' => 'stopBizproc', 'text' => $stringError);
         }
     } else {
         $errors = array();
         if (isset($documentStates[$workflowId]['WORKFLOW_STATUS']) && $documentStates[$workflowId]['WORKFLOW_STATUS'] !== null) {
             CBPDocument::terminateWorkflow($workflowId, $documentId, $errors);
         }
         if (!empty($errors)) {
             $stringError = '';
             foreach ($errors as $error) {
                 $stringError .= $error['message'];
             }
             $listError[] = array('id' => 'stopBizproc', 'text' => $stringError);
         } else {
             CBPTaskService::deleteByWorkflow($workflowId);
             CBPTrackingService::deleteByWorkflow($workflowId);
             CBPStateService::deleteWorkflow($workflowId);
         }
     }
     if (empty($listError) && Loader::includeModule('socialnetwork') && $iblockType == COption::getOptionString("lists", "livefeed_iblock_type_id")) {
         $sourceId = CBPStateService::getWorkflowIntegerId($workflowId);
         $resultQuery = CSocNetLog::getList(array(), array('EVENT_ID' => 'lists_new_element', 'SOURCE_ID' => $sourceId), false, false, array('ID'));
         while ($log = $resultQuery->fetch()) {
             CSocNetLog::delete($log['ID']);
         }
     }
     if (!empty($listError)) {
         $errorObject = new CAdminException($listError);
         $stringError = $errorObject->getString();
     }
     return $stringError;
 }
define('STOP_STATISTICS', true);
define('NO_AGENT_CHECK', true);
define('DisableEventsCheck', true);
define('BX_SECURITY_SHOW_MESSAGE', true);
define("PUBLIC_AJAX_MODE", true);
define("NOT_CHECK_PERMISSIONS", true);
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/iblock/admin_tools.php";
IncludeModuleLangFile(__FILE__);
header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
if (!CModule::includeModule("iblock") || !CModule::includeModule('fileman')) {
    die;
}
CUtil::jSPostUnescape();
if (check_bitrix_sessid()) {
    if ($_POST['GET_INPUT'] == 'Y') {
        $APPLICATION->RestartBuffer();
        if ($_POST['PROPERTY_ID'] == "DETAIL" || $_POST['PROPERTY_ID'] == "ANNOUNCE") {
            echo CFileInput::show('PROP[' . $_POST['PROPERTY_ID'] . '][' . $_POST['ROW_ID'] . ']', array(), array("IMAGE" => "Y", "PATH" => "Y", "FILE_SIZE" => "Y", "DIMENSIONS" => "Y", "IMAGE_POPUP" => "Y", "MAX_SIZE" => array("W" => COption::getOptionString("iblock", "detail_image_size"), "H" => COption::getOptionString("iblock", "detail_image_size"))), array('upload' => true, 'medialib' => true, 'file_dialog' => true, 'cloud' => true, 'del' => true, 'description' => $property_fields["WITH_DESCRIPTION"] == "Y"));
        }
        $properties = CIBlockProperty::getList(array("sort" => "asc", "name" => "asc"), array("ACTIVE" => "Y", "ID" => $_POST["PROPERTY_ID"], "CHECK_PERMISSIONS" => "N"));
        if ($prop_fields = $properties->Fetch()) {
            $prop_fields["VALUE"] = array();
            $prop_fields["~VALUE"] = array();
            _ShowPropertyField('PROP[' . $prop_fields["ID"] . '][' . $_POST['ROW_ID'] . ']', $prop_fields, $prop_fields["VALUE"], false, false, 50000, 'iblock_generator_form');
        }
        exit;
    }
}
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";
 private static function checkPath($path)
 {
     static $searchMasksCache = false;
     if (is_array($searchMasksCache)) {
         $arExc = $searchMasksCache["exc"];
         $arInc = $searchMasksCache["inc"];
     } else {
         $arExc = array();
         $arInc = array();
         $inc = \COption::getOptionString("main", "urlrewrite_include_mask", "*.php");
         $inc = str_replace("'", "\\'", str_replace("*", ".*?", str_replace("?", ".", str_replace(".", "\\.", str_replace("\\", "/", $inc)))));
         $arIncTmp = explode(";", $inc);
         foreach ($arIncTmp as $preg_mask) {
             if (strlen(trim($preg_mask)) > 0) {
                 $arInc[] = "'^" . trim($preg_mask) . "\$'";
             }
         }
         $exc = \COption::getOptionString("main", "urlrewrite_exclude_mask", "/bitrix/*;");
         $exc = str_replace("'", "\\'", str_replace("*", ".*?", str_replace("?", ".", str_replace(".", "\\.", str_replace("\\", "/", $exc)))));
         $arExcTmp = explode(";", $exc);
         foreach ($arExcTmp as $preg_mask) {
             if (strlen(trim($preg_mask)) > 0) {
                 $arExc[] = "'^" . trim($preg_mask) . "\$'";
             }
         }
         $searchMasksCache = array("exc" => $arExc, "inc" => $arInc);
     }
     $file = \Bitrix\Main\IO\Path::getName($path);
     if (substr($file, 0, 1) === ".") {
         return 0;
     }
     foreach ($arExc as $preg_mask) {
         if (preg_match($preg_mask, $path)) {
             return false;
         }
     }
     foreach ($arInc as $preg_mask) {
         if (preg_match($preg_mask, $path)) {
             return true;
         }
     }
     return false;
 }
Exemple #22
0
if (\Bitrix\Main\Loader::includeModule('mail')) {
    echo \Bitrix\Mail\Message::getQuoteStartMarker(true);
}
$protocol = \Bitrix\Main\Config\Option::get("main", "mail_link_protocol", 'https', $arParams["SITE_ID"]);
$serverName = $protocol . "://" . $arParams["SERVER_NAME"];
?>
<table cellpadding="0" cellspacing="0" border="0" align="center" bgcolor="#337e96" style="border-collapse: collapse;mso-table-lspace: 0pt;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;background-color: #337e96;border: none;height: 100%;width: 100%;">
	<tr>
		<td style="min-width: 15px;border-collapse: collapse;border-spacing: 0;padding: 0;"></td>
		<td align="left" valign="middle" style="border-collapse: collapse;border-spacing: 0;padding:0;background: url('<?php 
echo $serverName;
?>
/bitrix/templates/mail_user/images/top-cloud.png') no-repeat center 36px;">
			<div style="padding: 41px 0 24px;max-width: 732px;margin: 0 auto;"><?php 
$str24 = '<span style="color: #c2d1d6;">24</span>';
$companyName = IsModuleInstalled('bitrix24') ? COption::getOptionString('bitrix24', 'site_title', '') : COption::getOptionString('main', 'site_name', '');
if (empty($companyName)) {
    $companyName = $arParams["SITE_NAME"];
}
$companyName .= IsModuleInstalled('bitrix24') ? COption::GetOptionString("bitrix24", "logo24show", "Y") == "Y" ? $str24 : '' : $str24;
?>
<h1 style="color: #ffffff;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size: 35px;font-weight: bold;margin: 0;padding: 0;"><?php 
echo $companyName;
?>
</h1>
			</div>
		</td>
		<td style="min-width: 15px;border-collapse: collapse;border-spacing: 0;padding: 0;"></td>
	</tr>
	<tr>
		<td style="min-width: 15px;border-collapse: collapse;border-spacing: 0;padding: 0;"></td>
 protected function migrateVersion()
 {
     if (!$this->runWorkWithBizproc) {
         return;
     }
     if ($this->isStepFinished(__METHOD__)) {
         return;
     }
     $uploadDir = COption::getOptionString("main", "upload_dir", "upload");
     $isCloud = CModule::IncludeModule("clouds");
     $useGZipCompressionOption = \Bitrix\Main\Config\Option::get("bizproc", "use_gzip_compression", "");
     $isBitrix24 = IsModuleInstalled('bitrix24');
     $bucket = null;
     if ($isBitrix24 && $isCloud) {
         $bucket = new CCloudStorageBucket(1);
         $bucket->init();
     }
     if ($useGZipCompressionOption === "Y") {
         $this->useGZipCompression = true;
     } elseif ($useGZipCompressionOption === "N") {
         $this->useGZipCompression = false;
     } else {
         $this->useGZipCompression = function_exists("gzcompress") && ($GLOBALS["DB"]->type != "ORACLE" || !defined('BX_UTF'));
     }
     $sqlHelper = $this->connection->getSqlHelper();
     $lastId = $this->getStorageId();
     $versionQuery = $this->connection->query("\n\t\t\tSELECT\n\t\t\t\tobj.*,\n\t\t\t\th.ID VERSION_ID,\n\t\t\t\th.NAME VERSION_NAME,\n\t\t\t\th.DOCUMENT VERSION_DOC,\n\t\t\t\th.USER_ID VERSION_USER_ID,\n\t\t\t\th.MODIFIED VERSION_MODIFIED\n\t\t\tFROM b_disk_object obj\n\t\t\t\tINNER JOIN b_bp_history h ON h.DOCUMENT_ID = obj.WEBDAV_ELEMENT_ID AND h.MODULE_ID = 'webdav'\n\n\t\t\tWHERE obj.TYPE = 3 AND h.ID > {$lastId} ORDER BY h.ID\n\t\t");
     while ($version = $versionQuery->fetch()) {
         $this->abortIfNeeded();
         if (strlen($version['VERSION_DOC']) > 0) {
             if ($this->useGZipCompression) {
                 $version['VERSION_DOC'] = gzuncompress($version['VERSION_DOC']);
             }
             $version['VERSION_DOC'] = unserialize($version['VERSION_DOC']);
             if (!is_array($version['VERSION_DOC'])) {
                 $version['VERSION_DOC'] = array();
             }
         } else {
             $version['VERSION_DOC'] = array();
         }
         if (empty($version['VERSION_DOC']) || empty($version['VERSION_DOC']['PROPERTIES']['WEBDAV_VERSION']['VALUE']) || empty($version['VERSION_DOC']['PROPERTIES']['FILE']['VALUE'])) {
             $this->storeStorageId($version['VERSION_ID']);
             continue;
         }
         $version['VERSION_NAME'] = $sqlHelper->forSql($version['VERSION_NAME']);
         $version['VERSION_MODIFIED'] = $sqlHelper->getCharToDateFunction($version['VERSION_MODIFIED']->format("Y-m-d H:i:s"));
         $version['UPDATE_TIME'] = $sqlHelper->getCharToDateFunction($version['UPDATE_TIME']->format("Y-m-d H:i:s"));
         $fullPath = $version['VERSION_DOC']['PROPERTIES']['FILE']['VALUE'];
         $handlerId = '';
         $filename = bx_basename($fullPath);
         if (substr($fullPath, 0, 4) == "http") {
             if (!$isCloud) {
                 $this->storeStorageId($version['VERSION_ID']);
                 continue;
             }
             if (!$isBitrix24) {
                 $bucket = CCloudStorage::findBucketByFile($fullPath);
                 if (!$bucket) {
                     $this->storeStorageId($version['VERSION_ID']);
                     continue;
                 }
             }
             $handlerId = $bucket->ID;
             $subDir = trim(substr(getDirPath($fullPath), strlen($bucket->getFileSRC('/'))), '/');
             $contentType = \Bitrix\Disk\TypeFile::getMimeTypeByFilename($filename);
         } else {
             $subDir = trim(substr(getDirPath($fullPath), strlen('/' . $uploadDir)), '/');
             $contentType = CFile::getContentType($_SERVER["DOCUMENT_ROOT"] . $fullPath);
             $contentType = \Bitrix\Disk\TypeFile::normalizeMimeType($contentType, $filename);
         }
         $webdavSize = $version['VERSION_DOC']['PROPERTIES']['WEBDAV_SIZE']['VALUE'];
         if (empty($webdavSize)) {
             $webdavSize = 0;
         }
         $fileId = CFile::doInsert(array('HEIGHT' => 0, 'WIDTH' => 0, 'FILE_SIZE' => $webdavSize, 'CONTENT_TYPE' => $contentType, 'SUBDIR' => $subDir, 'FILE_NAME' => $filename, 'MODULE_ID' => Driver::INTERNAL_MODULE_ID, 'ORIGINAL_NAME' => $filename, 'DESCRIPTION' => '', 'HANDLER_ID' => $handlerId, 'EXTERNAL_ID' => md5(mt_rand())));
         if (!$fileId) {
             $this->storeStorageId($version['VERSION_ID']);
             continue;
         }
         $this->connection->queryExecute("\n\t\t\t\tINSERT INTO b_disk_version (OBJECT_ID, FILE_ID, " . $this->sqlHelper->quote('SIZE') . ", NAME, CREATE_TIME, CREATED_BY, MISC_DATA, OBJECT_CREATE_TIME, OBJECT_CREATED_BY, OBJECT_UPDATE_TIME, OBJECT_UPDATED_BY, GLOBAL_CONTENT_VERSION, BP_VERSION_ID)\n\t\t\t\tVALUES ({$version['ID']}, {$fileId}, {$webdavSize}, '{$version['VERSION_NAME']}', {$version['VERSION_MODIFIED']},  {$version['VERSION_USER_ID']}, null, {$version['VERSION_MODIFIED']}, {$version['CREATED_BY']}, {$version['UPDATE_TIME']}, {$version['UPDATED_BY']}, {$version['VERSION_DOC']['PROPERTIES']['WEBDAV_VERSION']['VALUE']}, {$version['VERSION_ID']})\n\t\t\t");
         $this->storeStorageId($version['VERSION_ID']);
     }
     $this->abortIfNeeded();
     $this->storeStorageId(0);
     $this->setStepFinished(__METHOD__);
 }
Exemple #24
0
 protected static function getSiteName()
 {
     return COption::getOptionString('main', 'site_name', '');
 }
        if (CModule::IncludeModule("sale") && CModule::IncludeModule("catalog")) {
            if (Add2BasketByProductID($_REQUEST['id'])) {
                $message = GetMessage("INBASKET");
            }
        }
        echo $message;
        require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/epilog_after.php";
        die;
    }
}
$save_param = new CPHPCache();
if ($_REQUEST["is_ajax_call"] === "y") {
    $lifetime = 60 * 60 * 24;
} else {
    $lifetime = $arParams['CACHE_TIME'] ? intval($arParams['CACHE_TIME']) : 60 * 60 * 24;
    if ($this->arParams["CACHE_TYPE"] == "N" || $this->arParams["CACHE_TYPE"] == "A" && COption::getOptionString("main", "component_cache_on", "Y") == "N") {
        CPHPCache::Clean("cache_wf_prms" . SITE_ID, "/");
    } elseif ($save_param->InitCache($lifetime, "cache_wf_prms" . SITE_ID, "/")) {
        $vars = $save_param->GetVars();
        if ($arParams != $vars["arParams"]) {
            CPHPCache::Clean("cache_wf_prms" . SITE_ID, "/");
        }
    }
}
if ($save_param->InitCache($lifetime, "cache_wf_prms" . SITE_ID, "/")) {
    $vars = $save_param->GetVars();
    $arParams = $vars["arParams"];
} else {
    if ($_REQUEST["is_ajax_call"] === "y") {
        die("cache");
    }
Exemple #26
0
 /**
  * Function starts the caching block of the component execution.
  *
  * @param int|bool $cacheTime
  * @param mixed $additionalCacheID
  * @param string|bool $cachePath
  * @return string
  *
  */
 public final function startResultCache($cacheTime = false, $additionalCacheID = false, $cachePath = false)
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION, $CACHE_MANAGER;
     if (!$this->__bInited) {
         return null;
     }
     if ($this->arParams["CACHE_TYPE"] == "N" || $this->arParams["CACHE_TYPE"] == "A" && COption::getOptionString("main", "component_cache_on", "Y") == "N") {
         return true;
     }
     if ($cacheTime === false) {
         $cacheTime = intval($this->arParams["CACHE_TIME"]);
     }
     $this->__cacheID = $this->getCacheID($additionalCacheID);
     $this->__cachePath = $cachePath;
     if ($this->__cachePath === false) {
         $this->__cachePath = $CACHE_MANAGER->getCompCachePath($this->__relativePath);
     }
     $this->__cache = \Bitrix\Main\Data\Cache::createInstance();
     if ($this->__cache->startDataCache($cacheTime, $this->__cacheID, $this->__cachePath)) {
         $this->__NavNum = $GLOBALS["NavNum"];
         if (defined("BX_COMP_MANAGED_CACHE") && $this->__cache->isStarted()) {
             $CACHE_MANAGER->startTagCache($this->__cachePath);
         }
         return true;
     } else {
         $arCache = $this->__cache->GetVars();
         $this->arResult = $arCache["arResult"];
         if (array_key_exists("templateCachedData", $arCache)) {
             $templateCachedData =& $arCache["templateCachedData"];
             if ($templateCachedData && is_array($templateCachedData)) {
                 if (array_key_exists("additionalCSS", $templateCachedData) && strlen($templateCachedData["additionalCSS"]) > 0) {
                     $APPLICATION->SetAdditionalCSS($templateCachedData["additionalCSS"]);
                     if ($this->__parent) {
                         $this->__parent->addChildCSS($templateCachedData["additionalCSS"]);
                     }
                 }
                 if (array_key_exists("additionalJS", $templateCachedData) && strlen($templateCachedData["additionalJS"]) > 0) {
                     $APPLICATION->AddHeadScript($templateCachedData["additionalJS"]);
                     if ($this->__parent) {
                         $this->__parent->addChildJS($templateCachedData["additionalJS"]);
                     }
                 }
                 if (array_key_exists("frames", $templateCachedData) && is_array($templateCachedData["frames"])) {
                     foreach ($templateCachedData["frames"] as $frameState) {
                         \Bitrix\Main\Page\FrameHelper::applyCachedData($frameState);
                     }
                 }
                 if (array_key_exists("frameMode", $templateCachedData) && $templateCachedData["frameMode"] === false) {
                     $context = isset($templateCachedData["frameModeCtx"]) ? "(from component cache) " . $templateCachedData["frameModeCtx"] : $this->__name . " - a cached template set frameMode=false";
                     \Bitrix\Main\Data\StaticHtmlCache::applyComponentFrameMode($context);
                 }
                 if (isset($templateCachedData["externalCss"])) {
                     foreach ($templateCachedData["externalCss"] as $cssPath) {
                         $APPLICATION->SetAdditionalCSS($cssPath);
                         //Check if parent component exists and plug css it to it's "collection"
                         if ($this->__parent) {
                             $this->__parent->addChildCSS($cssPath);
                         }
                     }
                 }
                 if (isset($templateCachedData["externalJs"])) {
                     foreach ($templateCachedData["externalJs"] as $jsPath) {
                         $APPLICATION->AddHeadScript($jsPath);
                         //Check if parent component exists and plug js it to it's "collection"
                         if ($this->__parent) {
                             $this->__parent->addChildJS($jsPath);
                         }
                     }
                 }
             }
             if ($templateCachedData["__editButtons"]) {
                 foreach ($templateCachedData["__editButtons"] as $button) {
                     if ($button[0] == 'AddEditAction') {
                         $this->addEditAction($button[1], $button[2], $button[3], $button[4]);
                     } else {
                         $this->addDeleteAction($button[1], $button[2], $button[3], $button[4]);
                     }
                 }
             }
             if ($templateCachedData["__view"]) {
                 foreach ($templateCachedData["__view"] as $view_id => $target) {
                     foreach ($target as $view_content) {
                         $APPLICATION->addViewContent($view_id, $view_content[0], $view_content[1]);
                     }
                 }
             }
             if (array_key_exists("__NavNum", $templateCachedData)) {
                 $GLOBALS["NavNum"] += $templateCachedData["__NavNum"];
             }
             if (array_key_exists("__children_css", $templateCachedData)) {
                 foreach ($templateCachedData["__children_css"] as $css_url) {
                     $APPLICATION->setAdditionalCSS($css_url);
                 }
             }
             if (array_key_exists("__children_js", $templateCachedData)) {
                 foreach ($templateCachedData["__children_js"] as $js_url) {
                     $APPLICATION->addHeadScript($js_url);
                 }
             }
             if (array_key_exists("__children_epilogs", $templateCachedData)) {
                 foreach ($templateCachedData["__children_epilogs"] as $component_epilog) {
                     $this->includeComponentEpilog($component_epilog);
                 }
             }
             if (array_key_exists("component_epilog", $templateCachedData)) {
                 $this->includeComponentEpilog($templateCachedData["component_epilog"]);
             }
         }
         return false;
     }
 }
Exemple #27
0
 public function GetFieldInputValue($documentType, $fieldType, $fieldName, $request, &$errors)
 {
     $iblockId = intval(substr($documentType, strlen("iblock_")));
     if ($iblockId <= 0) {
         throw new CBPArgumentOutOfRangeException("documentType", $documentType);
     }
     $result = array();
     if ($fieldType["Type"] == "user") {
         $value = $request[$fieldName["Field"]];
         if (strlen($value) > 0) {
             $result = CBPHelper::usersStringToArray($value, array("lists", get_called_class(), $documentType), $errors);
             if (count($errors) > 0) {
                 foreach ($errors as $e) {
                     $errors[] = $e;
                 }
             }
         } else {
             $result = null;
         }
     } elseif (array_key_exists($fieldName["Field"], $request) || array_key_exists($fieldName["Field"] . "_text", $request)) {
         $valueArray = array();
         if (array_key_exists($fieldName["Field"], $request)) {
             $valueArray = $request[$fieldName["Field"]];
             if (!is_array($valueArray) || is_array($valueArray) && CBPHelper::isAssociativeArray($valueArray)) {
                 $valueArray = array($valueArray);
             }
         }
         if (array_key_exists($fieldName["Field"] . "_text", $request)) {
             $valueArray[] = $request[$fieldName["Field"] . "_text"];
         }
         foreach ($valueArray as $value) {
             if (is_array($value) || !is_array($value) && !\CBPDocument::IsExpression(trim($value))) {
                 if ($fieldType["Type"] == "int") {
                     if (strlen($value) > 0) {
                         $value = str_replace(" ", "", $value);
                         if ($value . "|" == intval($value) . "|") {
                             $value = intval($value);
                         } else {
                             $value = null;
                             $errors[] = array("code" => "ErrorValue", "message" => GetMessage("LISTS_BIZPROC_INVALID_INT"), "parameter" => $fieldName["Field"]);
                         }
                     } else {
                         $value = null;
                     }
                 } elseif ($fieldType["Type"] == "double") {
                     if (strlen($value) > 0) {
                         $value = str_replace(" ", "", str_replace(",", ".", $value));
                         if (is_numeric($value)) {
                             $value = doubleval($value);
                         } else {
                             $value = null;
                             $errors[] = array("code" => "ErrorValue", "message" => GetMessage("LISTS_BIZPROC_INVALID_INT"), "parameter" => $fieldName["Field"]);
                         }
                     } else {
                         $value = null;
                     }
                 } elseif ($fieldType["Type"] == "select") {
                     if (!is_array($fieldType["Options"]) || count($fieldType["Options"]) <= 0 || strlen($value) <= 0) {
                         $value = null;
                     } else {
                         $ar = array_values($fieldType["Options"]);
                         if (is_array($ar[0])) {
                             $b = false;
                             foreach ($ar as $a) {
                                 if ($a[0] == $value) {
                                     $b = true;
                                     break;
                                 }
                             }
                             if (!$b) {
                                 $value = null;
                                 $errors[] = array("code" => "ErrorValue", "message" => GetMessage("LISTS_BIZPROC_INVALID_SELECT"), "parameter" => $fieldName["Field"]);
                             }
                         } else {
                             if (!array_key_exists($value, $fieldType["Options"])) {
                                 $value = null;
                                 $errors[] = array("code" => "ErrorValue", "message" => GetMessage("LISTS_BIZPROC_INVALID_SELECT"), "parameter" => $fieldName["Field"]);
                             }
                         }
                     }
                 } elseif ($fieldType["Type"] == "bool") {
                     if ($value !== "Y" && $value !== "N") {
                         if ($value === true) {
                             $value = "Y";
                         } elseif ($value === false) {
                             $value = "N";
                         } elseif (strlen($value) > 0) {
                             $value = strtolower($value);
                             if (in_array($value, array("y", "yes", "true", "1"))) {
                                 $value = "Y";
                             } elseif (in_array($value, array("n", "no", "false", "0"))) {
                                 $value = "N";
                             } else {
                                 $value = null;
                                 $errors[] = array("code" => "ErrorValue", "message" => GetMessage("BPCGWTL_INVALID45"), "parameter" => $fieldName["Field"]);
                             }
                         } else {
                             $value = null;
                         }
                     }
                 } elseif ($fieldType["Type"] == "file") {
                     if (is_array($value) && array_key_exists("name", $value) && strlen($value["name"]) > 0) {
                         if (!array_key_exists("MODULE_ID", $value) || strlen($value["MODULE_ID"]) <= 0) {
                             $value["MODULE_ID"] = "bizproc";
                         }
                         $value = CFile::saveFile($value, "bizproc_wf", true, true);
                         if (!$value) {
                             $value = null;
                             $errors[] = array("code" => "ErrorValue", "message" => GetMessage("BPCGWTL_INVALID915"), "parameter" => $fieldName["Field"]);
                         }
                     } else {
                         $value = null;
                     }
                 } elseif ($fieldType["Type"] == "date") {
                     if (strlen($value) > 0) {
                         if (!CheckDateTime($value, FORMAT_DATE)) {
                             $value = null;
                             $errors[] = array("code" => "ErrorValue", "message" => GetMessage("LISTS_BIZPROC_INVALID_DATE"), "parameter" => $fieldName["Field"]);
                         }
                     } else {
                         $value = null;
                     }
                 } elseif ($fieldType["Type"] == "datetime") {
                     if (strlen($value) > 0) {
                         $valueTemporary = array();
                         $valueTemporary["VALUE"] = $value;
                         $result = CIBlockPropertyDateTime::checkFields('', $valueTemporary);
                         if (!empty($result)) {
                             $message = '';
                             foreach ($result as $error) {
                                 $message .= $error;
                             }
                             $value = null;
                             $errors[] = array("code" => "ErrorValue", "message" => $message, "parameter" => $fieldName["Field"]);
                         }
                     } else {
                         $value = null;
                     }
                 } elseif (strpos($fieldType["Type"], ":") !== false && $fieldType["Type"] != "S:HTML") {
                     $customType = CIBlockProperty::getUserType(substr($fieldType["Type"], 2));
                     if (array_key_exists("GetLength", $customType)) {
                         if (call_user_func_array($customType["GetLength"], array(array("LINK_IBLOCK_ID" => $fieldType["Options"]), array("VALUE" => $value))) <= 0) {
                             $value = null;
                         }
                     }
                     if ($value != null && array_key_exists("CheckFields", $customType)) {
                         $errorsTemporary = call_user_func_array($customType["CheckFields"], array(array("LINK_IBLOCK_ID" => $fieldType["Options"]), array("VALUE" => $value)));
                         if (count($errorsTemporary) > 0) {
                             $value = null;
                             foreach ($errorsTemporary as $e) {
                                 $errors[] = array("code" => "ErrorValue", "message" => $e, "parameter" => $fieldName["Field"]);
                             }
                         }
                     } elseif (!array_key_exists("GetLength", $customType) && $value === '') {
                         $value = null;
                     }
                     if ($value !== null && $fieldType["Type"] == "S:employee" && COption::getOptionString("bizproc", "employee_compatible_mode", "N") != "Y") {
                         $value = "user_" . $value;
                     }
                 } else {
                     if (!is_array($value) && strlen($value) <= 0) {
                         $value = null;
                     }
                 }
             }
             if ($value !== null) {
                 $result[] = $value;
             }
         }
     }
     if (!$fieldType["Multiple"]) {
         if (is_array($result) && count($result) > 0) {
             $result = $result[0];
         } else {
             $result = null;
         }
     }
     return $result;
 }
 protected function initSession()
 {
     if ($domain = $GLOBALS["APPLICATION"]->getCookieDomain()) {
         ini_set("session.cookie_domain", $domain);
     }
     if (\COption::getOptionString("security", "session", "N") === "Y" && \CModule::includeModule("security")) {
         \CSecuritySession::init();
     }
     //diagnostic for spaces in init.php etc.
     //message is shown in the admin section
     $GLOBALS["aHeadersInfo"] = array();
     if (headers_sent($hs_file, $hs_line)) {
         $GLOBALS["aHeadersInfo"] = array("file" => $hs_file, "line" => $hs_line);
     }
     session_start();
 }
Exemple #29
0
	/**
	* Function starts the caching block of the component execution.
	*
	* @param int $cacheTime
	* @param mixed $additionalCacheID
	* @param string $cachePath
	* @return string
	*
	*/
	final public function startResultCache($cacheTime = false, $additionalCacheID = false, $cachePath = false)
	{
		global $APPLICATION, $CACHE_MANAGER;
		if (!$this->__bInited)
			return null;

		if ($this->arParams["CACHE_TYPE"] == "N" || ($this->arParams["CACHE_TYPE"] == "A" && COption::getOptionString("main", "component_cache_on", "Y") == "N"))
			return True;

		if ($cacheTime === false)
			$cacheTime = intval($this->arParams["CACHE_TIME"]);

		$this->__cacheID = $this->getCacheID($additionalCacheID);
		$this->__cachePath = $cachePath;
		if ($this->__cachePath === false)
			$this->__cachePath = $CACHE_MANAGER->getCompCachePath($this->__relativePath);

		$this->__cache = new CPHPCache;
		if ($this->__cache->startDataCache($cacheTime, $this->__cacheID, $this->__cachePath))
		{
			$this->__NavNum = $GLOBALS["NavNum"];
			if (defined("BX_COMP_MANAGED_CACHE"))
				$CACHE_MANAGER->startTagCache($this->__cachePath);

			return true;
		}
		else
		{
			$arCache = $this->__cache->GetVars();
			$this->arResult = $arCache["arResult"];
			if (array_key_exists("templateCachedData", $arCache))
			{
				$templateCachedData = & $arCache["templateCachedData"];
				CBitrixComponentTemplate::applyCachedData($templateCachedData);
				if ($templateCachedData["__editButtons"])
				{
					foreach ($templateCachedData["__editButtons"] as $button)
					{
						if ($button[0] == 'AddEditAction')
							$this->addEditAction($button[1], $button[2], $button[3], $button[4]);
						else
							$this->addDeleteAction($button[1], $button[2], $button[3], $button[4]);
					}
				}

				if ($templateCachedData["__view"])
					foreach ($templateCachedData["__view"] as $view_id => $target)
						foreach ($target as $view_content)
							$GLOBALS["APPLICATION"]->addViewContent($view_id, $view_content[0], $view_content[1]);

				if (array_key_exists("__NavNum", $templateCachedData))
					$GLOBALS["NavNum"]+= $templateCachedData["__NavNum"];

				if (array_key_exists("__children_css", $templateCachedData))
				{
					foreach ($templateCachedData["__children_css"] as $css_url)
						$APPLICATION->setAdditionalCSS($css_url);
				}

				if (array_key_exists("__children_epilogs", $templateCachedData))
				{
					foreach ($templateCachedData["__children_epilogs"] as $component_epilog)
						$this->includeComponentEpilog($component_epilog);
				}

				if (array_key_exists("component_epilog", $templateCachedData))
				{
					$this->includeComponentEpilog($templateCachedData["component_epilog"]);
				}
			}
			return false;
		}
	}
 public static function authenticateUser()
 {
     /** @var $context \Bitrix\Main\HttpContext */
     //$context = \Bitrix\Main\Application::getInstance()->getContext();
     //$currentUser = $context->getUser();
     //if ($currentUser->isAuthenticated())
     //	$currentUser->getLastName();
     //\Bitrix\Main\Security\Authentication::copyToSession($currentUser);
     // раскомментировать когда уберем из CurrentUser вызовы USER
     $GLOBALS["USER"] = new \CUser();
     // define("BX_STARTED", true); // нужен для инфоблоков чтобы понять - определен ли сайт???
     if (!defined("NOT_CHECK_PERMISSIONS") || NOT_CHECK_PERMISSIONS !== true) {
         $bLogout = strtolower($_REQUEST["logout"]) == "yes";
         if ($bLogout && $GLOBALS["USER"]->isAuthorized()) {
             // этот редирект нужно убирать
             $GLOBALS["USER"]->logout();
             LocalRedirect($GLOBALS["APPLICATION"]->getCurPageParam('', array('logout')));
         }
         // authorize by cookie
         $cookie_prefix = \COption::getOptionString('main', 'cookie_name', 'BITRIX_SM');
         $cookie_login = $_COOKIE[$cookie_prefix . '_LOGIN'];
         $cookie_md5pass = $_COOKIE[$cookie_prefix . '_UIDH'];
         if (\COption::getOptionString("main", "store_password", "Y") == "Y" && strlen($cookie_login) > 0 && strlen($cookie_md5pass) > 0 && !$GLOBALS["USER"]->isAuthorized() && !$bLogout && $_SESSION["SESS_PWD_HASH_TESTED"] != md5($cookie_login . "|" . $cookie_md5pass)) {
             $GLOBALS["USER"]->loginByHash($cookie_login, $cookie_md5pass);
             $_SESSION["SESS_PWD_HASH_TESTED"] = md5($cookie_login . "|" . $cookie_md5pass);
         }
         $arAuthResult = false;
         //http basic and digest authorization
         if (($httpAuth = $GLOBALS["USER"]->loginByHttpAuth()) !== null) {
             $arAuthResult = $httpAuth;
             $GLOBALS["APPLICATION"]->setAuthResult($arAuthResult);
         }
         //Authorize user from authorization html form
         if ($_REQUEST["AUTH_FORM"] != '') {
             $bRsaError = false;
             if (\COption::getOptionString('main', 'use_encrypted_auth', 'N') == 'Y') {
                 //possible encrypted user password
                 $sec = new \CRsaSecurity();
                 if ($arKeys = $sec->loadKeys()) {
                     $sec->setKeys($arKeys);
                     $errno = $sec->acceptFromForm(array('USER_PASSWORD', 'USER_CONFIRM_PASSWORD'));
                     if ($errno == \CRsaSecurity::ERROR_SESS_CHECK) {
                         $arAuthResult = array("MESSAGE" => GetMessage("main_include_decode_pass_sess"), "TYPE" => "ERROR");
                     } elseif ($errno < 0) {
                         $arAuthResult = array("MESSAGE" => GetMessage("main_include_decode_pass_err", array("#ERRCODE#" => $errno)), "TYPE" => "ERROR");
                     }
                     if ($errno < 0) {
                         $bRsaError = true;
                     }
                 }
             }
             if ($bRsaError == false) {
                 if (!defined("ADMIN_SECTION") || ADMIN_SECTION !== true) {
                     $USER_LID = LANG;
                 } else {
                     $USER_LID = false;
                 }
                 if ($_REQUEST["TYPE"] == "AUTH") {
                     $arAuthResult = $GLOBALS["USER"]->login($_REQUEST["USER_LOGIN"], $_REQUEST["USER_PASSWORD"], $_REQUEST["USER_REMEMBER"]);
                     if ($arAuthResult === true && defined('ADMIN_SECTION') && ADMIN_SECTION === true) {
                         $_SESSION['BX_ADMIN_LOAD_AUTH'] = true;
                         echo '<script type="text/javascript">window.onload=function(){top.BX.AUTHAGENT.setAuthResult(false);};</script>';
                         die;
                     }
                 } elseif ($_REQUEST["TYPE"] == "SEND_PWD") {
                     $arAuthResult = $GLOBALS["USER"]->sendPassword($_REQUEST["USER_LOGIN"], $_REQUEST["USER_EMAIL"], $USER_LID);
                 } elseif ($_SERVER['REQUEST_METHOD'] == 'POST' && $_REQUEST["TYPE"] == "CHANGE_PWD") {
                     $arAuthResult = $GLOBALS["USER"]->changePassword($_REQUEST["USER_LOGIN"], $_REQUEST["USER_CHECKWORD"], $_REQUEST["USER_PASSWORD"], $_REQUEST["USER_CONFIRM_PASSWORD"], $USER_LID);
                 } elseif (\COption::getOptionString("main", "new_user_registration", "N") == "Y" && $_SERVER['REQUEST_METHOD'] == 'POST' && $_REQUEST["TYPE"] == "REGISTRATION" && (!defined("ADMIN_SECTION") || ADMIN_SECTION !== true)) {
                     $arAuthResult = $GLOBALS["USER"]->register($_REQUEST["USER_LOGIN"], $_REQUEST["USER_NAME"], $_REQUEST["USER_LAST_NAME"], $_REQUEST["USER_PASSWORD"], $_REQUEST["USER_CONFIRM_PASSWORD"], $_REQUEST["USER_EMAIL"], $USER_LID, $_REQUEST["captcha_word"], $_REQUEST["captcha_sid"]);
                 }
             }
             $GLOBALS["APPLICATION"]->setAuthResult($arAuthResult);
         } elseif (!$GLOBALS["USER"]->isAuthorized()) {
             //Authorize by unique URL
             $GLOBALS["USER"]->loginHitByHash();
         }
     }
 }