示例#1
0
 /**
  * Returns script filename by URL
  *
  * @param string $site Site ID.
  * @param string $url URL.
  * @return string|null
  */
 public static function getRealPath($site, $url)
 {
     $docRoot = rtrim(\Bitrix\Main\SiteTable::getDocumentRoot($site), '/');
     $url = str_replace('\\', '/', $url);
     $url = \CHTTP::urnEncode($url);
     $uri = new Web\Uri($url);
     $path = \CHTTP::urnDecode($uri->getPath());
     if (substr($path, -1, 1) == '/') {
         $path .= 'index.php';
     }
     $file = new IO\File($docRoot . $path);
     if ($file->isExists()) {
         return substr($file->getPath(), strlen($docRoot));
     }
     if ($rewriteRules = AdminHelper::getRewriteRules($site)) {
         $pathQuery = \CHTTP::urnDecode($uri->getPathQuery());
         foreach ($rewriteRules as &$item) {
             if (preg_match($item['CONDITION'], $pathQuery)) {
                 $url = empty($item['PATH']) && !empty($item['RULE']) ? preg_replace($item['CONDITION'], $item['RULE'], $pathQuery) : $item['PATH'];
                 $url = \CHTTP::urnEncode($url);
                 $uri = new Web\Uri($url);
                 $path = \CHTTP::urnDecode($uri->getPath());
                 $file = new IO\File($docRoot . $path);
                 if ($file->isExists()) {
                     $pathTmp = str_replace('.', '', strtolower(ltrim($path, '/\\')));
                     $pathTmp7 = substr($pathTmp, 0, 7);
                     if ($pathTmp7 == 'upload/' || $pathTmp7 == 'bitrix/') {
                         continue;
                     }
                     if ($file->getExtension() != 'php') {
                         continue;
                     }
                     return substr($file->getPath(), strlen($docRoot));
                 }
             }
         }
     }
     return null;
 }
示例#2
0
}
if (!CHTTP::isPathTraversalUri($_SERVER["REQUEST_URI"])) {
    foreach ($arUrlRewrite as $val) {
        if (preg_match($val["CONDITION"], $requestUri)) {
            if (strlen($val["RULE"]) > 0) {
                $url = preg_replace($val["CONDITION"], (strlen($val["PATH"]) > 0 ? $val["PATH"] . "?" : "") . $val["RULE"], $requestUri);
            } else {
                $url = $val["PATH"];
            }
            if (($pos = strpos($url, "?")) !== false) {
                $params = substr($url, $pos + 1);
                parse_str($params, $vars);
                unset($vars["SEF_APPLICATION_CUR_PAGE_URL"]);
                $_GET += $vars;
                $_REQUEST += $vars;
                $_SERVER["QUERY_STRING"] = $QUERY_STRING = CHTTP::urnEncode($params);
                $url = substr($url, 0, $pos);
            }
            $url = _normalizePath($url);
            if (!$io->FileExists($_SERVER['DOCUMENT_ROOT'] . $url)) {
                continue;
            }
            if (!$io->ValidatePathString($url)) {
                continue;
            }
            $urlTmp = strtolower(ltrim($url, "/\\"));
            $urlTmp = str_replace(".", "", $urlTmp);
            $urlTmp7 = substr($urlTmp, 0, 7);
            if ($urlTmp7 == "upload/" || $urlTmp7 == "bitrix/" && substr($urlTmp, 0, 16) != "bitrix/services/" && substr($urlTmp, 0, 18) != "bitrix/groupdavphp") {
                continue;
            }
<?php

require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/mail/prolog.php";
$MOD_RIGHT = $APPLICATION->GetGroupRight("mail");
if ($MOD_RIGHT < "R") {
    $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
IncludeModuleLangFile(__FILE__);
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/mail/include.php";
$dbr = $DB->Query("SELECT * FROM b_mail_msg_attachment WHERE ID=" . intval($ID));
if ($dbr_arr = $dbr->Fetch()) {
    $utfName = CHTTP::urnEncode($dbr_arr['FILE_NAME'], 'UTF-8');
    $translitName = CUtil::translit($dbr_arr['FILE_NAME'], LANGUAGE_ID, array('max_len' => 1024, 'safe_chars' => '.', 'replace_space' => '-'));
    header("Content-Type: application/force-download; name=\"" . $translitName . "\"");
    header("Content-Transfer-Encoding: binary");
    header("Content-Length: " . $dbr_arr["FILE_SIZE"]);
    header("Content-Disposition: attachment; filename=\"" . $translitName . "\"; filename*=utf-8''" . $utfName);
    header("Expires: 0");
    header("Cache-Control: no-cache, must-revalidate");
    header("Pragma: no-cache");
    if ($dbr_arr['FILE_ID']) {
        if ($file = CFile::makeFileArray($dbr_arr['FILE_ID'])) {
            readfile($file['tmp_name']);
        }
    } else {
        echo $dbr_arr['FILE_DATA'];
    }
    die;
}
$APPLICATION->SetTitle(GetMessage("EDIT_MESSAGE_TITLE"));
示例#4
0
				$strTmpOff.= "<price>".$minPrice."</price>\n";
				$strTmpOff.= "<currencyId>".$minPriceCurrency."</currencyId>\n";

				$strTmpOff.= $strTmpOff_tmp;

				if (intval($arAcc["DETAIL_PICTURE"])>0 || intval($arAcc["PREVIEW_PICTURE"])>0)
				{
					$pictNo = intval($arAcc["DETAIL_PICTURE"]);
					if ($pictNo<=0) $pictNo = intval($arAcc["PREVIEW_PICTURE"]);

					$arPictInfo = CFile::GetFileArray($pictNo);
					if (is_array($arPictInfo))
					{
						if(substr($arPictInfo["SRC"], 0, 1) == "/")
							$strFile = "http://".$arAcc['SERVER_NAME'].CHTTP::urnEncode($arPictInfo["SRC"], 'utf-8');
						else
							$strFile = $arPictInfo["SRC"];
						$strTmpOff.="<picture>".$strFile."</picture>\n";
					}
				}

				$strTmpOff.= "<name>".yandex_text2xml($arAcc["~NAME"], true)."</name>\n";
				$strTmpOff.=
					"<description>".
					yandex_text2xml(TruncateText(
						($arAcc["PREVIEW_TEXT_TYPE"]=="html"?
						strip_tags(preg_replace_callback("'&[^;]*;'", "yandex_replace_special", $arAcc["~PREVIEW_TEXT"])) : preg_replace_callback("'&[^;]*;'", "yandex_replace_special", $arAcc["~PREVIEW_TEXT"])),
						255), true).
					"</description>\n";
				$strTmpOff.= "</offer>\n";
示例#5
0
$lAdmin->AddHeaders(array(array("id" => "DOMAIN", "content" => Loc::getMessage('SEO_DOMAIN'), "sort" => "DOMAIN", "default" => true), array("id" => "SITE", "content" => Loc::getMessage("SEO_SITE"), "default" => true), array("id" => "SITE_ACTIVE", "content" => Loc::getMessage('SEO_SITE_ACTIVE'), "sort" => "active", "default" => true), array("id" => "BINDED", "content" => Loc::getMessage("SEO_BINDED"), "default" => true), array("id" => "VERIFIED", "content" => Loc::getMessage("SEO_VERIFIED"), "default" => true)));
$bNeedAuth = !$engine->getAuthSettings();
try {
    $currentUser = $engine->getCurrentUser();
} catch (Exception $e) {
    $currentUser = null;
    $bNeedAuth = true;
}
$dbSites = new Bitrix\Main\DB\ArrayResult(\CSeoUtils::getDomainsList());
$rsData = new CAdminResult($dbSites, $sTableID);
while ($arSite = $dbSites->fetch(Converter::getHtmlConverter())) {
    $row =& $lAdmin->AddRow($arSite['DOMAIN'], $arSite);
    $siteDomainEnc = Converter::getHtmlConverter()->encode($arSite['DOMAIN']);
    $siteDomainEncView = Converter::getHtmlConverter()->encode(\CBXPunycode::ToUnicode($arSite['DOMAIN'], $e = null));
    $siteDirEnc = Converter::getHtmlConverter()->encode($arSite['SITE_DIR']);
    $row->AddViewField("DOMAIN", '<a href="http://' . Converter::getHtmlConverter()->encode($arSite['DOMAIN'] . CHTTP::urnEncode($arSite['SITE_DIR'])) . '">' . $siteDomainEncView . $siteDirEnc . '</a>');
    $row->AddViewField("SITE", '[<a href="site_edit.php?lang=' . LANGUAGE_ID . '&amp;LID=' . urlencode($arSite['LID']) . '">' . $arSite['LID'] . '</a>] ' . $arSite['SITE_NAME']);
    $row->AddCheckField("SITE_ACTIVE", false);
    $row->AddViewField("BINDED", '<span data-role="site-binded" data-domain="' . $siteDomainEnc . '" data-dir="' . $siteDirEnc . '">' . ($bNeedAuth ? Loc::getMessage('SEO_NEED_AUTH') : Loc::getMessage('SEO_LOADING')) . '</span>');
    $row->AddViewField("VERIFIED", '<span data-role="site-verified" data-domain="' . $siteDomainEnc . '" data-dir="' . $siteDirEnc . '">' . ($bNeedAuth ? Loc::getMessage('SEO_NEED_AUTH') : Loc::getMessage('SEO_LOADING')) . '</span>');
}
$lAdmin->CheckListMode();
$APPLICATION->SetTitle(Loc::getMessage("SEO_GOOGLE_TITLE"));
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
if ($strError != '') {
    CAdminMessage::ShowMessage($strError);
}
?>
<div id="ajax_status"></div>
<script type="text/javascript">
window.lastSeoResult = null;
示例#6
0
        $dbGroups = CSocNetUserToGroup::GetList(array("GROUP_NAME" => "ASC"), $arGroupFilterMy, false, false, array('ID', 'GROUP_ID', 'GROUP_NAME', 'GROUP_SITE_ID'));
        while ($arGroups = $dbGroups->GetNext()) {
            $arGroupIDCurrentSite[] = $arGroups['GROUP_ID'];
            if (in_array($arGroups['GROUP_ID'], $extGroupID)) {
                continue;
            }
            $arSGGroup[] = array($arGroups["GROUP_NAME"], str_replace("#group_id#", $arGroups["GROUP_ID"], $strGroupSubjectLinkTemplate), array(), array("counter_id" => "SG" . $arGroups["GROUP_ID"]), "");
        }
        foreach ($arExtSGGroupTmp as $groupID => $arGroupItem) {
            if (in_array($groupID, $arGroupIDCurrentSite)) {
                $arExtSGGroup[] = $arGroupItem;
            }
        }
    }
    $CACHE_MANAGER->RegisterTag('sonet_group');
    $CACHE_MANAGER->RegisterTag('USER_CARD_' . intval($USER_ID / TAGGED_user_card_size));
    $CACHE_MANAGER->RegisterTag('sonet_user2group_U' . $USER_ID);
    $CACHE_MANAGER->EndTagCache();
    $arResult["GROUP_MENU"] = $arSGGroup;
    $arResult["EXTRANET_MENU"] = $arExtSGGroup;
    if ($obCache->StartDataCache()) {
        $obCache->EndDataCache($arResult);
        unset($arSGGroup, $arExtSGGroup);
    }
}
if ($arResult["USER"]["AVATAR"]) {
    $file = CHTTP::urnEncode($arResult["USER"]["AVATAR"]["src"], "UTF-8");
    \Bitrix\Main\Data\AppCacheManifest::getInstance()->addFile($file);
}
unset($obCache);
$this->IncludeComponentTemplate();
示例#7
0
         $arAcc['~DETAIL_PAGE_URL'] = str_replace(' ', '%20', $arAcc['~DETAIL_PAGE_URL']);
     }
     $strTmpOff .= "<offer id=\"" . $arAcc["ID"] . "\"" . $str_AVAILABLE . ">\n";
     $strTmpOff .= "<url>" . $usedProtocol . $arAcc['SERVER_NAME'] . htmlspecialcharsbx($arAcc["~DETAIL_PAGE_URL"]) . (strstr($arAcc['DETAIL_PAGE_URL'], '?') === false ? '?' : '&amp;') . "r1=<?echo \$strReferer1; ?>&amp;r2=<?echo \$strReferer2; ?></url>\n";
     $strTmpOff .= "<price>" . $minPrice . "</price>\n";
     $strTmpOff .= "<currencyId>" . $minPriceCurrency . "</currencyId>\n";
     $strTmpOff .= $strTmpOff_tmp;
     if (intval($arAcc["DETAIL_PICTURE"]) > 0 || intval($arAcc["PREVIEW_PICTURE"]) > 0) {
         $pictNo = intval($arAcc["DETAIL_PICTURE"]);
         if ($pictNo <= 0) {
             $pictNo = intval($arAcc["PREVIEW_PICTURE"]);
         }
         $arPictInfo = CFile::GetFileArray($pictNo);
         if (is_array($arPictInfo)) {
             if (substr($arPictInfo["SRC"], 0, 1) == "/") {
                 $strFile = $usedProtocol . $arAcc['SERVER_NAME'] . CHTTP::urnEncode($arPictInfo["SRC"], 'utf-8');
             } else {
                 $strFile = $arPictInfo["SRC"];
             }
             $strTmpOff .= "<picture>" . $strFile . "</picture>\n";
         }
     }
     $strTmpOff .= "<name>" . yandex_text2xml($arAcc["~NAME"], true) . "</name>\n";
     $strTmpOff .= "<description>" . yandex_text2xml(TruncateText($arAcc["PREVIEW_TEXT_TYPE"] == "html" ? strip_tags(preg_replace_callback("'&[^;]*;'", "yandex_replace_special", $arAcc["~PREVIEW_TEXT"])) : preg_replace_callback("'&[^;]*;'", "yandex_replace_special", $arAcc["~PREVIEW_TEXT"]), 255), true) . "</description>\n";
     $strTmpOff .= "</offer>\n";
     if (100 <= $cnt) {
         $cnt = 0;
         CCatalogDiscount::ClearDiscountCache(array('PRODUCT' => true, 'SECTIONS' => true, 'PROPERTIES' => true));
     }
 }
 if ($boolNeedRootSection) {
示例#8
0
function yandex_get_value($arOffer, $param, $PROPERTY, &$arProperties, &$arUserTypeFormat)
{
	global $iblockServerName;

	$strProperty = '';
	$bParam = (strncmp($param, 'PARAM_', 6) == 0);
	if (isset($arProperties[$PROPERTY]) && !empty($arProperties[$PROPERTY]))
	{
		$PROPERTY_CODE = $arProperties[$PROPERTY]['CODE'];
		$arProperty = (
			isset($arOffer['PROPERTIES'][$PROPERTY_CODE])
			? $arOffer['PROPERTIES'][$PROPERTY_CODE]
			: $arOffer['PROPERTIES'][$PROPERTY]
		);

		$value = '';
		$description = '';
		switch ($arProperties[$PROPERTY]['PROPERTY_TYPE'])
		{
			case 'USER_TYPE':
				if ($arProperty['MULTIPLE'] == 'Y')
				{
					if (!empty($arProperty['~VALUE']))
					{
						$arValues = array();
						foreach($arProperty["~VALUE"] as $oneValue)
						{
							$isArray = is_array($oneValue);
							if (
								($isArray && !empty($oneValue))
								|| (!$isArray && $oneValue != '')
							)
							{
								$arValues[] = call_user_func_array($arUserTypeFormat[$PROPERTY],
									array(
										$arProperty,
										array("VALUE" => $oneValue),
										array('MODE' => 'SIMPLE_TEXT'),
									)
								);
							}
						}
						$value = implode(', ', $arValues);
					}
				}
				else
				{
					$isArray = is_array($arProperty['~VALUE']);
					if (
						($isArray && !empty($arProperty['~VALUE']))
						|| (!$isArray && $arProperty['~VALUE'] != '')
					)
					{
						$value = call_user_func_array($arUserTypeFormat[$PROPERTY],
							array(
								$arProperty,
								array("VALUE" => $arProperty["~VALUE"]),
								array('MODE' => 'SIMPLE_TEXT'),
							)
						);
					}
				}
				break;
			case 'E':
				if (!empty($arProperty['VALUE']))
				{
					$arCheckValue = array();
					if (!is_array($arProperty['VALUE']))
					{
						$arProperty['VALUE'] = (int)$arProperty['VALUE'];
						if (0 < $arProperty['VALUE'])
							$arCheckValue[] = $arProperty['VALUE'];
					}
					else
					{
						foreach ($arProperty['VALUE'] as &$intValue)
						{
							$intValue = (int)$intValue;
							if (0 < $intValue)
								$arCheckValue[] = $intValue;
						}
						if (isset($intValue))
							unset($intValue);
					}
					if (!empty($arCheckValue))
					{
						$dbRes = CIBlockElement::GetList(array(), array('IBLOCK_ID' => $arProperties[$PROPERTY]['LINK_IBLOCK_ID'], 'ID' => $arCheckValue), false, false, array('NAME'));
						while ($arRes = $dbRes->Fetch())
						{
							$value .= ($value ? ', ' : '').$arRes['NAME'];
						}
					}
				}
				break;
			case 'G':
				if (!empty($arProperty['VALUE']))
				{
					$arCheckValue = array();
					if (!is_array($arProperty['VALUE']))
					{
						$arProperty['VALUE'] = (int)$arProperty['VALUE'];
						if (0 < $arProperty['VALUE'])
							$arCheckValue[] = $arProperty['VALUE'];
					}
					else
					{
						foreach ($arProperty['VALUE'] as &$intValue)
						{
							$intValue = (int)$intValue;
							if (0 < $intValue)
								$arCheckValue[] = $intValue;
						}
						if (isset($intValue))
							unset($intValue);
					}
					if (!empty($arCheckValue))
					{
						$dbRes = CIBlockSection::GetList(array(), array('IBLOCK_ID' => $arProperty['LINK_IBLOCK_ID'], 'ID' => $arCheckValue), false, array('NAME'));
						while ($arRes = $dbRes->Fetch())
						{
							$value .= ($value ? ', ' : '').$arRes['NAME'];
						}
					}
				}
				break;
			case 'L':
				if (!empty($arProperty['VALUE']))
				{
					if (is_array($arProperty['VALUE']))
						$value .= implode(', ', $arProperty['VALUE']);
					else
						$value .= $arProperty['VALUE'];
				}
				break;
			case 'F':
				if (!empty($arProperty['VALUE']))
				{
					if (is_array($arProperty['VALUE']))
					{
						foreach ($arProperty['VALUE'] as &$intValue)
						{
							$intValue = (int)$intValue;
							if ($intValue > 0)
							{
								if ($ar_file = CFile::GetFileArray($intValue))
								{
									if(substr($ar_file["SRC"], 0, 1) == "/")
										$strFile = "http://".$iblockServerName.CHTTP::urnEncode($ar_file['SRC'], 'utf-8');
									else
										$strFile = $ar_file["SRC"];
									$value .= ($value ? ', ' : '').$strFile;
								}
							}
						}
						if (isset($intValue))
							unset($intValue);
					}
					else
					{
						$arProperty['VALUE'] = (int)$arProperty['VALUE'];
						if ($arProperty['VALUE'] > 0)
						{
							if ($ar_file = CFile::GetFileArray($arProperty['VALUE']))
							{
								if(substr($ar_file["SRC"], 0, 1) == "/")
									$strFile = "http://".$iblockServerName.CHTTP::urnEncode($ar_file['SRC'], 'utf-8');
								else
									$strFile = $ar_file["SRC"];
								$value = $strFile;
							}
						}
					}
				}
				break;
			default:
				if ($bParam && $arProperty['WITH_DESCRIPTION'] == 'Y')
				{
					$description = $arProperty['DESCRIPTION'];
					$value = $arProperty['VALUE'];
				}
				else
				{
					$value = is_array($arProperty['VALUE']) ? implode(', ', $arProperty['VALUE']) : $arProperty['VALUE'];
				}
		}

		// !!!! check multiple properties and properties like CML2_ATTRIBUTES

		if ($bParam)
		{
			if (is_array($description))
			{
				foreach ($value as $key => $val)
				{
					$strProperty .= $strProperty ? "\n" : "";
					$strProperty .= '<param name="'.yandex_text2xml($description[$key], true).'">'.yandex_text2xml($val, true).'</param>';
				}
			}
			else
			{
				$strProperty .= '<param name="'.yandex_text2xml($arProperties[$PROPERTY]['NAME'], true).'">'.yandex_text2xml($value, true).'</param>';
			}
		}
		else
		{
			$param_h = yandex_text2xml($param, true);
			$strProperty .= '<'.$param_h.'>'.yandex_text2xml($value, true).'</'.$param_h.'>';
		}
	}

	return $strProperty;
}
示例#9
0
文件: file.php 项目: nycmic/bittest
 static function ViewByUser($arFile, $arOptions = array())
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION;
     $fastDownload = COption::GetOptionString('main', 'bx_fast_download', 'N') == 'Y';
     $attachment_name = "";
     $content_type = "";
     $specialchars = false;
     $force_download = false;
     $cache_time = 10800;
     $fromClouds = false;
     if (is_array($arOptions)) {
         if (isset($arOptions["content_type"])) {
             $content_type = $arOptions["content_type"];
         }
         if (isset($arOptions["specialchars"])) {
             $specialchars = $arOptions["specialchars"];
         }
         if (isset($arOptions["force_download"])) {
             $force_download = $arOptions["force_download"];
         }
         if (isset($arOptions["cache_time"])) {
             $cache_time = intval($arOptions["cache_time"]);
         }
         if (isset($arOptions["attachment_name"])) {
             $attachment_name = $arOptions["attachment_name"];
         }
     }
     if ($cache_time < 0) {
         $cache_time = 0;
     }
     if (is_array($arFile)) {
         if (isset($arFile["SRC"])) {
             $filename = $arFile["SRC"];
         } elseif (isset($arFile["tmp_name"])) {
             $filename = "/" . ltrim(substr($arFile["tmp_name"], strlen($_SERVER["DOCUMENT_ROOT"])), "/");
         } else {
             $filename = static::GetFileSRC($arFile);
         }
     } else {
         if ($arFile = static::GetFileArray($arFile)) {
             $filename = $arFile["SRC"];
         } else {
             $filename = '';
         }
     }
     if ($filename == '') {
         return false;
     }
     if ($content_type == '' && isset($arFile["CONTENT_TYPE"])) {
         $content_type = $arFile["CONTENT_TYPE"];
     }
     //we produce resized jpg for original bmp
     if ($content_type == '' || $content_type == "image/bmp") {
         if (isset($arFile["tmp_name"])) {
             $content_type = static::GetContentType($arFile["tmp_name"], true);
         } else {
             $content_type = static::GetContentType($_SERVER["DOCUMENT_ROOT"] . $filename);
         }
     }
     if ($arFile["ORIGINAL_NAME"] != '') {
         $name = $arFile["ORIGINAL_NAME"];
     } elseif ($arFile["name"] != '') {
         $name = $arFile["name"];
     } else {
         $name = $arFile["FILE_NAME"];
     }
     if (isset($arFile["EXTENSION_SUFFIX"]) && $arFile["EXTENSION_SUFFIX"] != '') {
         $name = substr($name, 0, -strlen($arFile["EXTENSION_SUFFIX"]));
     }
     $name = str_replace(array("\n", "\r"), '', $name);
     if ($attachment_name) {
         $attachment_name = str_replace(array("\n", "\r"), '', $attachment_name);
     } else {
         $attachment_name = $name;
     }
     if (!$force_download) {
         if (!static::IsImage($name, $content_type) || $arFile["HEIGHT"] <= 0 || $arFile["WIDTH"] <= 0) {
             //only valid images can be downloaded inline
             $force_download = true;
         }
     }
     $content_type = static::NormalizeContentType($content_type);
     if ($force_download) {
         $specialchars = false;
     }
     $src = null;
     $file = new IO\File($_SERVER["DOCUMENT_ROOT"] . $filename);
     if (substr($filename, 0, 1) == "/") {
         try {
             $src = $file->open(IO\FileStreamOpenMode::READ);
         } catch (IO\IoException $e) {
             return false;
         }
     } else {
         if (!$fastDownload) {
             $src = new \Bitrix\Main\Web\HttpClient();
         } elseif (intval($arFile['HANDLER_ID']) > 0) {
             $fromClouds = true;
         }
     }
     $APPLICATION->RestartBuffer();
     while (ob_end_clean()) {
     }
     $cur_pos = 0;
     $filesize = $arFile["FILE_SIZE"] > 0 ? $arFile["FILE_SIZE"] : $arFile["size"];
     $size = $filesize - 1;
     $p = strpos($_SERVER["HTTP_RANGE"], "=");
     if (intval($p) > 0) {
         $bytes = substr($_SERVER["HTTP_RANGE"], $p + 1);
         $p = strpos($bytes, "-");
         if ($p !== false) {
             $cur_pos = floatval(substr($bytes, 0, $p));
             $size = floatval(substr($bytes, $p + 1));
             if ($size <= 0) {
                 $size = $filesize - 1;
             }
             if ($cur_pos > $size) {
                 $cur_pos = 0;
                 $size = $filesize - 1;
             }
         }
     }
     if ($arFile["tmp_name"] != '') {
         $tmpFile = new IO\File($arFile["tmp_name"]);
         $filetime = $tmpFile->getModificationTime();
     } else {
         $filetime = intval(MakeTimeStamp($arFile["TIMESTAMP_X"]));
     }
     if ($_SERVER["REQUEST_METHOD"] == "HEAD") {
         CHTTP::SetStatus("200 OK");
         header("Accept-Ranges: bytes");
         header("Content-Type: " . $content_type);
         header("Content-Length: " . ($size - $cur_pos + 1));
         if ($filetime > 0) {
             header("Last-Modified: " . date("r", $filetime));
         }
     } else {
         $lastModified = '';
         if ($cache_time > 0) {
             //Handle ETag
             $ETag = md5($filename . $filesize . $filetime);
             if (array_key_exists("HTTP_IF_NONE_MATCH", $_SERVER) && $_SERVER['HTTP_IF_NONE_MATCH'] === $ETag) {
                 CHTTP::SetStatus("304 Not Modified");
                 header("Cache-Control: private, max-age=" . $cache_time . ", pre-check=" . $cache_time);
                 die;
             }
             header("ETag: " . $ETag);
             //Handle Last Modified
             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) {
                     CHTTP::SetStatus("304 Not Modified");
                     header("Cache-Control: private, max-age=" . $cache_time . ", pre-check=" . $cache_time);
                     die;
                 }
             }
         }
         $utfName = CHTTP::urnEncode($attachment_name, "UTF-8");
         $translitName = CUtil::translit($attachment_name, LANGUAGE_ID, array("max_len" => 1024, "safe_chars" => ".", "replace_space" => '-'));
         if ($force_download) {
             //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');
             }
             if ($cur_pos > 0) {
                 CHTTP::SetStatus("206 Partial Content");
             } else {
                 CHTTP::SetStatus("200 OK");
             }
             header("Content-Type: " . $content_type);
             header("Content-Disposition: attachment; filename=\"" . $translitName . "\"; filename*=utf-8''" . $utfName);
             header("Content-Transfer-Encoding: binary");
             header("Content-Length: " . ($size - $cur_pos + 1));
             if (is_resource($src)) {
                 header("Accept-Ranges: bytes");
                 header("Content-Range: bytes " . $cur_pos . "-" . $size . "/" . $filesize);
             }
         } else {
             header("Content-Type: " . $content_type);
             header("Content-Disposition: inline; filename=\"" . $translitName . "\"; filename*=utf-8''" . $utfName);
         }
         if ($cache_time > 0) {
             header("Cache-Control: private, max-age=" . $cache_time . ", pre-check=" . $cache_time);
             if ($filetime > 0) {
                 header('Last-Modified: ' . $lastModified);
             }
         } else {
             header("Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0");
         }
         header("Expires: 0");
         header("Pragma: public");
         // Download from front-end
         if ($fastDownload) {
             if ($fromClouds) {
                 $filename = preg_replace('~^(http[s]?)(\\://)~i', '\\1.', $filename);
                 $cloudUploadPath = COption::GetOptionString('main', 'bx_cloud_upload', '/upload/bx_cloud_upload/');
                 header('X-Accel-Redirect: ' . $cloudUploadPath . $filename);
             } else {
                 $filename = $APPLICATION->ConvertCharset($filename, SITE_CHARSET, "UTF-8");
                 header('X-Accel-Redirect: ' . $filename);
             }
         } else {
             session_write_close();
             if ($specialchars) {
                 echo "<", "pre", ">";
                 if (is_resource($src)) {
                     while (!feof($src)) {
                         echo htmlspecialcharsbx(fread($src, 32768));
                     }
                     $file->close();
                 } else {
                     echo htmlspecialcharsbx($src->get($filename));
                 }
                 echo "<", "/pre", ">";
             } else {
                 if (is_resource($src)) {
                     $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");
                     $src->setOutputStream($fp);
                     $src->get($filename);
                 }
             }
         }
     }
     CMain::FinalActions();
     die;
 }
示例#10
0
    private static function DisplayFile($arFile = array(), $ind = 0)
    {
        $hintId = self::$jsId . '_file_disp_' . $ind;
        $bNotFound = $arFile['FILE_NOT_FOUND'];
        // Hint
        $hint = '';
        if (!$bNotFound) {
            $sImagePath = isset($arFile["PATH"]) ? $arFile["PATH"] : $arFile["SRC"];
            $descName = isset($arFile['DESC_NAME']) ? $arFile['DESC_NAME'] : self::$descInputName;
            if ($arFile['FORMATED_SIZE'] != '') {
                $hint .= '<span class="adm-input-file-hint-row">' . GetMessage('ADM_FILE_INFO_SIZE') . ':&nbsp;&nbsp;' . $arFile['FORMATED_SIZE'] . '</span>';
            }
            if ($arFile['IS_IMAGE']) {
                $hint .= '<span class="adm-input-file-hint-row">' . GetMessage('ADM_FILE_INFO_DIM') . ':&nbsp;&nbsp;' . $arFile['WIDTH'] . 'x' . $arFile['HEIGHT'] . '</span>';
            }
            if ($sImagePath != '') {
                $hint .= '<span class="adm-input-file-hint-row">' . GetMessage('ADM_FILE_INFO_LINK') . ':&nbsp;&nbsp;<a href="' . CHTTP::urnEncode($sImagePath, "UTF-8") . '">' . $sImagePath . '</a></span>';
            }
            if (!self::$bShowDescInput && $arFile['DESCRIPTION'] != "") {
                $hint .= '<span class="adm-input-file-hint-row">' . GetMessage('ADM_FILE_DESCRIPTION') . ':&nbsp;&nbsp;' . htmlspecialcharsbx($arFile['DESCRIPTION']) . '</span>';
            }
        }
        ?>
<span class="adm-input-file-exist-cont" id="<?php 
        echo self::$jsId;
        ?>
_file_cont_<?php 
        echo $ind;
        ?>
">
		<div class="adm-input-file-ex-wrap<?php 
        if (self::$bMultiple) {
            echo ' adm-input-cont-bordered';
        }
        ?>
">
		<?php 
        if ($bNotFound) {
            ?>
			<span id="<?php 
            echo self::$jsId . '_file_404_' . $ind;
            ?>
" class="adm-input-file-not-found">
			<?php 
            echo GetMessage('ADM_FILE_NOT_FOUND');
            ?>
			</span>
			<?php 
        } elseif ($arFile['IS_IMAGE']) {
            $file = CFile::ResizeImageGet($arFile['ID'], array('width' => self::$maxPreviewWidth, 'height' => self::$maxPreviewHeight), BX_RESIZE_IMAGE_PROPORTIONAL, true);
            ?>
			<span id="<?php 
            echo $hintId;
            ?>
" class="adm-input-file-preview" style="<?php 
            if (self::$minPreviewWidth > 0) {
                echo 'min-width: ' . self::$minPreviewWidth . 'px;';
            }
            ?>
 <?php 
            if (self::$minPreviewHeight > 0) {
                echo 'min-height:' . self::$minPreviewHeight . 'px;';
            }
            ?>
">
				<?php 
            echo CFile::Show2Images($file['src'], $arFile['SRC'], self::$maxPreviewWidth, self::$maxPreviewHeight);
            ?>
				<div id="<?php 
            echo self::$jsId . '_file_del_lbl_' . $ind;
            ?>
" class="adm-input-file-del-lbl"><?php 
            echo GetMessage('ADM_FILE_DELETED_TITLE');
            ?>
</div>
			</span>
			<?php 
        } else {
            $val = !empty($arFile['FILE_NAME']) ? $arFile['FILE_NAME'] : $sImagePath;
            ?>
			<a id="<?php 
            echo $hintId;
            ?>
" href="<?php 
            echo htmlspecialcharsbx($arFile['SRC']);
            ?>
" class="adm-input-file-name"><?php 
            echo htmlspecialcharsbx($val);
            ?>
</a>
			<?php 
        }
        if ($hint != '') {
            ?>
		<script type="text/javascript">
			new top.BX.CHint({
				parent: top.BX("<?php 
            echo $hintId;
            ?>
"),
				show_timeout: 10,
				hide_timeout: 200,
				dx: 2,
				preventHide: true,
				min_width: 250,
				hint: '<?php 
            echo CUtil::JSEscape($hint);
            ?>
'
			});
		</script>
			<?php 
        }
        if (!self::$bViewMode) {
            self::ShowOpenerMenuHtml(self::$jsId . '_menu_' . $ind, $ind);
        }
        if (!$bNotFound && self::$bShowDescInput) {
            ?>
			<div id="<?php 
            echo self::$jsId . '_file_desc_' . $ind;
            ?>
" class="adm-input-file-desc-inp-cont" <?php 
            if ($arFile['DESCRIPTION'] == "") {
                echo 'style="display: none;"';
            }
            ?>
>
				<input name="<?php 
            echo $descName;
            ?>
" class="adm-input" type="text" value="<?php 
            echo htmlspecialcharsbx($arFile['DESCRIPTION']);
            ?>
" size="<?php 
            echo self::$inputSize;
            ?>
" placeholder="<?php 
            echo GetMessage("ADM_FILE_DESC");
            ?>
" <?php 
            if (self::$bViewMode) {
                echo ' disabled="disabled"';
            }
            ?>
>
			</div>
			<?php 
        }
        ?>
		</div>
		</span>
		<?php 
    }
示例#11
0
function getDataForXml()
{
    CModule::IncludeModule("iblock");
    CModule::IncludeModule('catalog');
    $filter["ACTIVE"] = "Y";
    $filter["ACTIVE_DATE"] = "Y";
    $filter["IBLOCK_ID"] = 2;//goodies
    $rsItems = CIBlockElement::GetList(array(), $filter, false, false, array());
    $strOfferGoogle = '';
    while ($obItem = $rsItems->GetNextElement()) {
        $arItem = $obItem->GetFields();
        if (CModule::IncludeModule("catalog") && CCatalog::GetByID($arItem['IBLOCK_ID'])) {
            $arItem = $obItem->GetFields();
            $productId = $arItem['ID'];
            $rsPrices = CPrice::GetByID($productId);
            $arItem['PROPERTIES'] = $obItem->GetProperties();
            $strFile = '';
            $arItem["DETAIL_PICTURE"] = (int)$arItem["DETAIL_PICTURE"];
            $arItem["PREVIEW_PICTURE"] = (int)$arItem["PREVIEW_PICTURE"];
            if ($arItem["DETAIL_PICTURE"] > 0 || $arItem["PREVIEW_PICTURE"] > 0) {
                $pictNo = ($arItem["DETAIL_PICTURE"] > 0 ? $arItem["DETAIL_PICTURE"] : $arItem["PREVIEW_PICTURE"]);

                if ($ar_file = CFile::GetFileArray($pictNo)) {
                    if (substr($ar_file["SRC"], 0, 1) == "/")
                        $strFile = "http://" . $_SERVER['SERVER_NAME'] . CHTTP::urnEncode($ar_file['SRC'], 'utf-8');
                    else
                        $strFile = $ar_file["SRC"];
                }
            }
            $arItem['google_PICT'] = $strFile;

            if (!empty($arItem["DETAIL_TEXT"]))
                $arItem['google_DESCR'] = google_text2xml(strip_tags(stristr($arItem["DETAIL_TEXT"], '.', true)));
            else
                $arItem['google_DESCR'] = google_text2xml(strip_tags($arItem["NAME"]));

            $strOfferGoogle .= "<item>\n";
            $strOfferGoogle .= "<title>";
            $strOfferGoogle .= $arItem['NAME'];
            $strOfferGoogle .= "</title>\n";
            $strOfferGoogle .= "<link>";
            $strOfferGoogle .= "http://".$_SERVER['SERVER_NAME'].$arItem['DETAIL_PAGE_URL'];
            $strOfferGoogle .= "</link>\n";
            $strOfferGoogle .= "<description>";
            $strOfferGoogle .= $arItem['google_DESCR'];
            $strOfferGoogle .= "</description>\n";
            $strOfferGoogle .= "<g:image_link>";
            $strOfferGoogle .= $strFile;
            $strOfferGoogle .= "</g:image_link>\n";
            $strOfferGoogle .= "<g:price>";
            $strOfferGoogle .= $rsPrices['PRICE'];
            $strOfferGoogle .= "</g:price>\n";
            $strOfferGoogle .= "<g:condition>";
            $strOfferGoogle .= "новый";
            $strOfferGoogle .= "</g:condition>\n";
            $strOfferGoogle .= "<g:id>";
            $strOfferGoogle .= $arItem['CODE'];
            $strOfferGoogle .= "</g:id>\n";
            $strOfferGoogle .= "</item>\n";
            //etc etc
        }
        else
        {
            continue;
        }
    }
    writeData($strOfferGoogle);
}
示例#12
0
function WDUFUserFieldView(&$arParams, &$arResult)
{
    static $DROPPED = null;
    static $OLD_DROPPED = null;
    if (!(CModule::IncludeModule('iblock') && CModule::IncludeModule('webdav'))) {
        return false;
    }
    if ($DROPPED === null) {
        $DROPPED = CWebDavIblock::getDroppedMetaData();
        $DROPPED = $DROPPED['name'];
        $OLD_DROPPED = CWebDavIblock::getOldDroppedMetaData();
        $OLD_DROPPED = $OLD_DROPPED['name'];
    }
    global $APPLICATION, $USER_FIELD_MANAGER, $USER;
    static $arIBlock = array();
    $result = array();
    $arIBlockCacheID = array();
    $arValue = array();
    $isHistoryDocInComment = false;
    //from historical comment
    $versionHistoryDocInComment = $throughVersionComment = 0;
    $EVId = is_array($arParams["arUserField"]) && $arParams["arUserField"]["ENTITY_VALUE_ID"] > 0 ? intval($arParams["arUserField"]["ENTITY_VALUE_ID"]) : 0;
    $arResult['VALUE'] = is_array($arResult['VALUE']) ? $arResult['VALUE'] : array();
    if ($arParams['arUserField']['USER_TYPE_ID'] == 'webdav_element_history') {
        $isHistoryDocInComment = true;
        //not multiple UF
        if (!empty($arResult['VALUE'][0]['id'])) {
            $arValue[] = (int) $arResult['VALUE'][0]['id'];
            $versionHistoryDocInComment = (int) $arResult['VALUE'][0]['v'];
            $throughVersionComment = empty($arResult['VALUE'][1]['t_vers']) ? 0 : (int) $arResult['VALUE'][1]['t_vers'];
        }
        $cacheID = md5(serialize($arResult['VALUE']));
    } else {
        foreach ($arResult['VALUE'] as $val) {
            $val = intval($val);
            if ($val > 0) {
                $arValue[] = $val;
            }
        }
        $cacheID = $EVId > 0 ? $EVId : md5(serialize($arValue));
    }
    if (!empty($arParams["arUserField"]) && !empty($arParams["arUserField"]['ID'])) {
        $cacheID = (string) $cacheID;
        $cacheID = $arParams["arUserField"]['ID'] . '_' . $cacheID;
    }
    if (sizeof($arValue) > 0) {
        // cache
        $obCache = new CPHPCache();
        $cachePath = SITE_ID . "/webdav/inline";
        if ($obCache->InitCache(30 * 86400, $cacheID, $cachePath)) {
            $vars = $obCache->GetVars();
            $result = $vars["RESULT"];
        }
        if (empty($result) && $obCache->StartDataCache()) {
            $ElementID = $arValue;
            if ($EVId > 0) {
                $ElementID = $USER_FIELD_MANAGER->GetUserFieldValue($arParams["arUserField"]["ENTITY_ID"], $arParams["arUserField"]["FIELD_NAME"], $EVId);
                $ElementID = empty($ElementID) ? $arValue : $ElementID;
                if ($isHistoryDocInComment) {
                    $ElementID = $ElementID[0]['id'];
                }
            }
            // check file exists
            $ibe = new CIBlockElement();
            $dbWDFile = $ibe->GetList(array(), array('ID' => $ElementID), false, false, array('ID', 'NAME', 'IBLOCK_SECTION_ID', 'IBLOCK_ID', 'IBLOCK_CODE', 'PROPERTY_' . CWebDavIblock::PROPERTY_VERSION, 'PROPERTY_WEBDAV_SIZE', 'PROPERTY_FILE', 'CREATED_BY', 'CREATED_USER_NAME', 'CREATED_BY_FORMATTED'));
            if ($dbWDFile) {
                $dbWDFile->SetNameTemplate($arParams['NAME_TEMPLATE']);
                while ($arWDFile = $dbWDFile->Fetch()) {
                    $id = intval($arWDFile['ID']);
                    $arNavChain = array();
                    if (!isset($arIBlock[$arWDFile['IBLOCK_ID']])) {
                        $dbWDIBlock = CIBlock::GetList(array(), array('ID' => $arWDFile['IBLOCK_ID'], 'CHECK_PERMISSIONS' => 'N'));
                        if ($dbWDIBlock && ($arWDIBlock = $dbWDIBlock->Fetch())) {
                            $arIBlock[$arWDFile['IBLOCK_ID']] = $arWDIBlock;
                        }
                    }
                    if (isset($arIBlock[$arWDFile['IBLOCK_ID']])) {
                        $arWDIBlock = $arIBlock[$arWDFile['IBLOCK_ID']];
                        $arIBlockCacheID[] = $arWDFile['IBLOCK_ID'];
                        $arNavChain = WDUGetNavChainSections($arWDFile['IBLOCK_ID'], $arWDFile['IBLOCK_SECTION_ID']);
                        if ($arNavChain === false) {
                            continue;
                            // not show items from trash
                        }
                        // get path to document
                        $detailPath = CWebDavIblock::LibOptions('lib_paths', true, $arWDFile['IBLOCK_ID']);
                        $detailPath = !!$detailPath ? $detailPath : $arWDIBlock['DETAIL_PAGE_URL'];
                        $arPaths = WDUFGetPathOptions($detailPath, $arWDFile['IBLOCK_ID'], reset($arNavChain), $arWDFile);
                        $isSocnet = $arPaths["entity"] != "lib";
                        $arWDFile['VIEW'] = $arPaths["path"];
                        $arWDFile['HISTORY'] = CHTTP::urlAddParams($arPaths['view'], array('webdavForm' . $arWDFile['IBLOCK_ID'] . '_active_tab' => 'tab_history'));
                        $arWDFile['EDIT'] = $arPaths["edit"];
                        $arWDFile['DELETE_DROPPED'] = $arPaths["delete_dropped"];
                        $arWDFile['PATH'] = $arPaths["history_get"];
                        // 'breadcrumb'
                        $arSectionsChain = array();
                        //to link on element
                        $userIBlockID = CWebDavIblock::LibOptions('user_files', false, SITE_ID);
                        $groupIBlockID = CWebDavIblock::LibOptions('group_files', false, SITE_ID);
                        $arUrlSectionsChain = array();
                        $i = 0;
                        foreach ($arNavChain as $res) {
                            $name = $res["NAME"];
                            if ($i == 0 && !!$res["SOCNET_GROUP_ID"] && CModule::IncludeModule('socialnetwork') && strlen(GetMessage('SONET_GROUP_PREFIX')) > 0) {
                                if ($name == GetMessage('SONET_GROUP_PREFIX')) {
                                    $arGroup = CSocNetGroup::GetByID($res["SOCNET_GROUP_ID"]);
                                    $name = GetMessage("SONET_GROUP_PREFIX") . $arGroup['NAME'];
                                }
                            }
                            //drop prefix storage name (1st level in section tree) if user or groups file. If shared docs - don't
                            if ($i != 0 || !$isSocnet) {
                                $arUrlSectionsChain[] = $name;
                            }
                            if ($name != $DROPPED) {
                                $arSectionsChain[] = $name;
                                $i++;
                            }
                            if ($name == $DROPPED || $name == $OLD_DROPPED) {
                                //disable local edit if file id .Dropped
                                $arWDFile['IN_PERSONAL_LIB'] = false;
                            }
                        }
                        if ($arSectionsChain[$i] == $DROPPED) {
                            $arWDFile['NAVCHAIN'] = GetMessage('WDUF_ATTACHED_TO_MESSAGE');
                        } else {
                            if ($userIBlockID && $groupIBlockID) {
                                if ($arWDFile['IBLOCK_ID'] != $userIBlockID['id'] && $arWDFile['IBLOCK_ID'] != $groupIBlockID['id']) {
                                    $name = CIBlock::GetArrayByID($arWDFile['IBLOCK_ID'], 'NAME');
                                    array_unshift($arSectionsChain, $name);
                                }
                            }
                            $arWDFile['NAVCHAIN'] = implode("/", $arSectionsChain);
                        }
                        $arUrlSectionsChain[] = $arWDFile["NAME"];
                        $arWDFile['VIEW'] .= implode('/', $arUrlSectionsChain);
                        //non urnencoded
                        $arWDFile['RELATIVE_PATH'] = $arWDFile['VIEW'];
                        $arWDFile['VIEW'] = CHTTP::urnEncode($arWDFile['VIEW']);
                        // extension
                        $name = $arWDFile['NAME'];
                        $ext = '';
                        $dotpos = strrpos($name, ".");
                        if ($dotpos !== false && $dotpos + 1 < strlen($name)) {
                            $ext = substr($name, $dotpos + 1);
                        }
                        if (strlen($ext) < 3 || strlen($ext) > 5) {
                            $ext = '';
                        }
                        $arWDFile['EXTENSION'] = $ext;
                        // size
                        $arWDFile['SIZE'] = 0;
                        if ($arWDFile['PROPERTY_WEBDAV_SIZE_VALUE']) {
                            $arWDFile['SIZE'] = CFile::FormatSize(intval($arWDFile['PROPERTY_WEBDAV_SIZE_VALUE']), 0);
                        }
                        // file
                        $arWDFile['FILE'] = array();
                        if ($arWDFile['PROPERTY_FILE_VALUE']) {
                            $arWDFile['FILE'] = CFile::GetFileArray($arWDFile['PROPERTY_FILE_VALUE']);
                        }
                        if ($isHistoryDocInComment) {
                            $arWDFile['PATH'] = $arWDFile['PATH'] . "?toWDController=1&ncc=1&downloadHistory=1&id={$arWDFile['ID']}&v={$versionHistoryDocInComment}&f={$arWDFile['FILE']['ID']}";
                            $arWDFile['THROUGH_VERSION'] = empty($throughVersionComment) ? -1 : $throughVersionComment;
                        } else {
                            $arWDFile['THROUGH_VERSION'] = (int) $arWDFile['PROPERTY_' . CWebDavIblock::PROPERTY_VERSION . '_VALUE'];
                        }
                        if (strlen($arWDFile['PATH']) > 0) {
                            $arWDFile['PATH'] = CHTTP::urnEncode($arWDFile['PATH']);
                            $result[$id] = $arWDFile;
                        }
                    }
                }
            }
            global $CACHE_MANAGER;
            $CACHE_MANAGER->StartTagCache($cachePath);
            foreach ($arIBlockCacheID as $ibID) {
                $CACHE_MANAGER->RegisterTag("iblock_id_" . $ibID);
            }
            $CACHE_MANAGER->EndTagCache();
            $obCache->EndDataCache(array("RESULT" => $result));
        }
        // not cached
        // check file access rights
        static $op = 'element_read';
        foreach ($result as $id => $arWDFile) {
            if (!in_array($id, $arValue)) {
                unset($result[$id]);
                continue;
            } else {
                if (!isset($arIBlock[$arWDFile['IBLOCK_ID']])) {
                    continue;
                }
            }
            $arWDIBlock = $arIBlock[$arWDFile['IBLOCK_ID']];
            if ($arWDIBlock['RIGHTS_MODE'] == 'E') {
                $ibRights = CWebDavIblock::_get_ib_rights_object('ELEMENT', $id, $arWDIBlock['ID']);
                if (!$ibRights->UserHasRightTo($arWDIBlock['ID'], $id, $op)) {
                    unset($result[$id]);
                    continue;
                }
            } else {
                if (CIBlock::GetPermission($arWDIBlock['ID']) < 'R') {
                    unset($result[$id]);
                    continue;
                }
            }
        }
    }
    //output
    $arResult['FILES'] = $result;
}