Example #1
0
 /**
  * Copies file from really tmp dir to repo
  * @param $file
  * @param $canvas
  * @param $res
  * @return Status|Error
  */
 protected function copyFile($file, $canvas, &$res)
 {
     if (is_array($res) && array_key_exists("url", $res)) {
         return new Status("uploaded");
     }
     $hash = $this->getHash($file);
     $io = \CBXVirtualIo::GetInstance();
     $directory = $io->getDirectory($this->path . $hash);
     $path = $this->path . $hash . "/" . $canvas;
     $status = new Error("BXU347.2");
     if (!$directory->create()) {
         $status = new Error("BXU347.1");
     } elseif (array_key_exists('tmp_url', $res)) {
         if ((!file_exists($path) || @unlink($path)) && $this->http->download($res["tmp_url"], $path) !== false) {
             $status = new Status("uploaded");
         }
     } elseif (array_key_exists('chunks', $res)) {
         $status = $this->copyChunks($path, $res['chunks'], $res['chunksInfo']);
     } elseif (!file_exists($res['tmp_name'])) {
         if ($canvas != "default" && !empty($file["files"]["default"]) && $res["width"] <= $file["files"]["default"]["width"] && $res["height"] <= $file["files"]["default"]["height"] && @copy($file["files"]["default"]["tmp_path"], $path) && is_file($path)) {
             @chmod($path, BX_FILE_PERMISSIONS);
             $res["tmp_name"] = $path;
             $status = new Status("uploaded");
         } else {
             $status = new Error("BXU347.2");
         }
     } elseif ((!file_exists($path) || @unlink($path)) && move_uploaded_file($res['tmp_name'], $path)) {
         $status = new Status("uploaded");
     }
     $res["name"] = $file["name"];
     if ($status->getStatus() == "uploaded") {
         $res["tmp_name"] = $path;
         $res["size"] = filesize($path);
         unset($res['chunks']);
         unset($res['chunksInfo']);
         if (empty($res["type"]) || $canvas != "default") {
             $res["type"] = array_key_exists("type", $file) ? $file["type"] : \CFile::GetContentType($path);
         }
         $res["url"] = $this->getUrl($file["hash"] . "_" . $canvas);
         $res["sizeFormatted"] = \CFile::FormatSize($res["size"]);
     }
     return $status;
 }
Example #2
0
 function ViewByUser($arFile, $arOptions = array())
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION;
     $fastDownload = COption::GetOptionString('main', 'bx_fast_download', 'N') == 'Y';
     $content_type = "";
     $specialchars = false;
     $force_download = false;
     $cache_time = 10800;
     $fromClouds = false;
     if (is_array($arOptions)) {
         if (array_key_exists("content_type", $arOptions)) {
             $content_type = $arOptions["content_type"];
         }
         if (array_key_exists("specialchars", $arOptions)) {
             $specialchars = $arOptions["specialchars"];
         }
         if (array_key_exists("force_download", $arOptions)) {
             $force_download = $arOptions["force_download"];
         }
         if (array_key_exists("cache_time", $arOptions)) {
             $cache_time = intval($arOptions["cache_time"]);
         }
     }
     if ($content_type == '') {
         if ($arFile["tmp_name"] != '') {
             $content_type = CFile::GetContentType($arFile["tmp_name"], true);
         } else {
             $content_type = "text/html; charset=" . LANG_CHARSET;
         }
     }
     if ($force_download) {
         $specialchars = false;
     }
     if ($cache_time < 0) {
         $cache_time = 0;
     }
     if (is_array($arFile)) {
         if (array_key_exists("SRC", $arFile)) {
             $filename = $arFile["SRC"];
         } elseif (array_key_exists("tmp_name", $arFile)) {
             $filename = "/" . ltrim(substr($arFile["tmp_name"], strlen($_SERVER["DOCUMENT_ROOT"])), "/");
         } else {
             $filename = CFile::GetFileSRC($arFile);
         }
     } else {
         if ($arFile = CFile::GetFileArray($arFile)) {
             $filename = $arFile["SRC"];
         } else {
             $filename = '';
         }
     }
     if ($filename == '') {
         return false;
     }
     if ($arFile["ORIGINAL_NAME"] != '') {
         $name = $arFile["ORIGINAL_NAME"];
     } elseif ($arFile["name"] != '') {
         $name = $arFile["name"];
     } else {
         $name = $arFile["FILE_NAME"];
     }
     if (array_key_exists("EXTENSION_SUFFIX", $arFile) && $arFile["EXTENSION_SUFFIX"] != '') {
         $name = substr($name, 0, -strlen($arFile["EXTENSION_SUFFIX"]));
     }
     // ie filename error fix
     $ua = strtolower($_SERVER["HTTP_USER_AGENT"]);
     if (strpos($ua, "opera") === false && strpos($ua, "msie") !== false) {
         if (SITE_CHARSET != "UTF-8") {
             $name = $APPLICATION->ConvertCharset($name, SITE_CHARSET, "UTF-8");
         }
         $name = str_replace(" ", "%20", $name);
         $name = urlencode($name);
         $name = str_replace(array("%2520", "%2F"), array("%20", "/"), $name);
     } else {
         $name = str_replace(array("\n", "\r"), '', $name);
     }
     $io = CBXVirtualIo::GetInstance();
     $src = null;
     if (substr($filename, 0, 1) == "/") {
         $src = fopen($io->GetPhysicalName($_SERVER["DOCUMENT_ROOT"] . $filename), "rb");
         if (!$src) {
             return false;
         }
     } else {
         if (!$fastDownload) {
             $src = new CHTTP();
             $src->follow_redirect = true;
         } elseif (intval($arFile['HANDLER_ID']) > 0) {
             $fromClouds = true;
         }
     }
     $APPLICATION->RestartBuffer();
     while (ob_end_clean()) {
     }
     $cur_pos = 0;
     $filesize = intval($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 = intval(substr($bytes, 0, $p));
             $size = intval(substr($bytes, $p + 1));
             if ($size <= 0) {
                 $size = $filesize - 1;
             }
             if ($cur_pos > $size) {
                 $cur_pos = 0;
                 $size = $filesize - 1;
             }
         }
     }
     if ($arFile["tmp_name"] != '') {
         $filetime = filemtime($io->GetPhysicalName($arFile["tmp_name"]));
     } else {
         $filetime = intval(MakeTimeStamp($arFile["TIMESTAMP_X"]));
     }
     if ($_SERVER["REQUEST_METHOD"] == "HEAD") {
         CHTTP::SetStatus("200 OK");
         header("Accept-Ranges: bytes");
         header("Content-Length: " . ($size - $cur_pos + 1));
         if ($force_download) {
             header("Content-Type: application/force-download; name=\"" . $name . "\"");
         } else {
             header("Content-type: " . $content_type);
         }
         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;
                 }
             }
         }
         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: application/force-download; name=\"" . $name . "\"");
             header("Content-Disposition: attachment; filename=\"" . $name . "\"");
             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=\"" . $name . "\"");
         }
         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 {
                 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));
                     }
                     fclose($src);
                 } else {
                     echo htmlspecialcharsbx($src->Get($filename));
                 }
                 echo "<", "/pre", ">";
             } else {
                 if (is_resource($src)) {
                     fseek($src, $cur_pos);
                     while (!feof($src) && $cur_pos <= $size) {
                         $bufsize = 131072;
                         //128K
                         if ($bufsize + $cur_pos > $size) {
                             $bufsize = $size - $cur_pos + 1;
                         }
                         $cur_pos += $bufsize;
                         echo fread($src, $bufsize);
                     }
                     fclose($src);
                 } else {
                     echo $src->Get($filename);
                 }
             }
         }
     }
     die;
 }
Example #3
0
     break;
 }
 $bytes = 0;
 $fileSize = $f->GetFileSize();
 if ($fileSize > $obBucket->GetService()->GetMinUploadPartSize()) {
     $obUpload = new CCloudStorageUpload($filePath);
     if (!$obUpload->isStarted()) {
         if ($obBucket->FileExists($filePath)) {
             $message = new CAdminMessage(GetMessage("CLO_STORAGE_FILE_UPLOAD_ERROR"), new CApplicationException(GetMessage("CLO_STORAGE_FILE_EXISTS_ERROR")));
             break;
         }
         $tempFile = CTempFile::GetDirectoryName(6, "clouds_upload") . $f->GetName();
         $tempFileX = $io->GetPhysicalName($tempFile);
         CheckDirPath($tempFileX);
         if (copy($_FILES["upload"]["tmp_name"], $tempFileX)) {
             if ($obUpload->Start($obBucket->ID, $fileSize, CFile::GetContentType($tempFile), $tempFile)) {
                 $moveResult = CCloudStorage::FILE_PARTLY_UPLOADED;
             } else {
                 $strError = GetMessage("CLO_STORAGE_FILE_UNKNOWN_ERROR", array("#CODE#" => "e01"));
             }
         } else {
             $strError = GetMessage("CLO_STORAGE_FILE_UNKNOWN_ERROR", array("#CODE#" => "e04"));
         }
     } else {
         $pos = $obUpload->getPos();
         if ($pos > $fileSize) {
             if ($obUpload->Finish()) {
                 $bytes = $fileSize;
                 $obBucket->IncFileCounter($fileSize);
                 @unlink($io->GetPhysicalName($f->GetPathWithName()));
                 $moveResult = CCloudStorage::FILE_MOVED;
Example #4
0
 /**
  * Returns value of ldap user field mapped to bitrix field.
  * @param string $fieldName Name of user field in Bitrix system.
  * @param array $arLdapUser User params received from ldap.
  * @return mixed.
  */
 function getLdapValueByBitrixFieldName($fieldName, $arLdapUser)
 {
     global $USER_FIELD_MANAGER;
     if (!isset($this->arFields["FIELD_MAP"][$fieldName])) {
         return false;
     }
     $attr = $this->arFields["FIELD_MAP"][$fieldName];
     $arRes = $USER_FIELD_MANAGER->GetUserFields("USER", 0, LANGUAGE_ID);
     $result = false;
     if (is_array($arRes[$fieldName])) {
         if ($arRes[$fieldName]["MULTIPLE"] == "Y") {
             if (is_array($arLdapUser[strtolower($attr)])) {
                 $result = array_values($arLdapUser[strtolower($attr)]);
             } else {
                 $result = array($arLdapUser[strtolower($attr)]);
             }
         } else {
             if (!empty($arLdapUser[strtolower($attr)])) {
                 $result = $arLdapUser[strtolower($attr)];
             } else {
                 if (!empty($arRes[$fieldName]['SETTINGS']['DEFAULT_VALUE'])) {
                     if (is_array($arRes[$fieldName]['SETTINGS']['DEFAULT_VALUE'])) {
                         if (!empty($arRes[$fieldName]['SETTINGS']['DEFAULT_VALUE']['VALUE'])) {
                             $result = $arRes[$fieldName]['SETTINGS']['DEFAULT_VALUE']['VALUE'];
                         }
                     } else {
                         $result = $arRes[$fieldName]['SETTINGS']['DEFAULT_VALUE'];
                     }
                 }
             }
         }
     } elseif (preg_match("/(.*)&([0-9]+)/", $attr, $arMatch)) {
         if (intval($arLdapUser[strtolower($arMatch[1])]) & intval($arMatch[2])) {
             $result = "N";
         } else {
             $result = "Y";
         }
     } elseif ($fieldName == "PERSONAL_PHOTO") {
         if ($arLdapUser[strtolower($attr)] == "") {
             return false;
         }
         $fExt = CLdapUtil::GetImgTypeBySignature($arLdapUser[strtolower($attr)][0]);
         if (!$fExt) {
             return false;
         }
         $tmpDir = CTempFile::GetDirectoryName();
         CheckDirPath($tmpDir);
         $fname = "ad_" . rand() . "." . $fExt;
         if (!file_put_contents($tmpDir . $fname, $arLdapUser[strtolower($attr)][0])) {
             return false;
         }
         $result = array("name" => $fname, "type" => CFile::GetContentType($tmpDir . $fname), "tmp_name" => $tmpDir . $fname);
     } else {
         $result = $arLdapUser[strtolower($attr)];
     }
     if (is_null($result)) {
         $result = false;
     }
     return $result;
 }
Example #5
0
 /**
  * Returns an array describing file as if it was $_FILES element.
  *
  * @param string|int $path May contain ID of the file, absolute path, relative path or an url.
  * @param string|bool $mimetype Forces type field of the array
  * @param bool $skipInternal Excludes using ID as $path
  * @param string $external_id
  * @return array|bool|null
  */
 public static function MakeFileArray($path, $mimetype = false, $skipInternal = false, $external_id = "")
 {
     $io = CBXVirtualIo::GetInstance();
     $arFile = array();
     if (intval($path) > 0) {
         if ($skipInternal) {
             return false;
         }
         $res = CFile::GetByID($path);
         if ($ar = $res->Fetch()) {
             $bExternalStorage = false;
             foreach (GetModuleEvents("main", "OnMakeFileArray", true) as $arEvent) {
                 if (ExecuteModuleEventEx($arEvent, array($ar, &$arFile))) {
                     $bExternalStorage = true;
                     break;
                 }
             }
             if (!$bExternalStorage) {
                 $arFile["name"] = strlen($ar['ORIGINAL_NAME']) > 0 ? $ar['ORIGINAL_NAME'] : $ar['FILE_NAME'];
                 $arFile["size"] = $ar['FILE_SIZE'];
                 $arFile["type"] = $ar['CONTENT_TYPE'];
                 $arFile["description"] = $ar['DESCRIPTION'];
                 $arFile["tmp_name"] = $io->GetPhysicalName(preg_replace("#[\\\\\\/]+#", "/", $_SERVER['DOCUMENT_ROOT'] . '/' . COption::GetOptionString('main', 'upload_dir', 'upload') . '/' . $ar['SUBDIR'] . '/' . $ar['FILE_NAME']));
             }
             if (!isset($arFile["external_id"])) {
                 $arFile["external_id"] = $external_id != "" ? $external_id : $ar["EXTERNAL_ID"];
             }
             return $arFile;
         }
     }
     $path = preg_replace("#(?<!:)[\\\\\\/]+#", "/", $path);
     if (strlen($path) == 0 || $path == "/") {
         return NULL;
     }
     if (preg_match("#^php://filter#i", $path)) {
         return NULL;
     }
     if (preg_match("#^(http[s]?)://#", $path)) {
         $temp_path = '';
         $bExternalStorage = false;
         foreach (GetModuleEvents("main", "OnMakeFileArray", true) as $arEvent) {
             if (ExecuteModuleEventEx($arEvent, array($path, &$temp_path))) {
                 $bExternalStorage = true;
                 break;
             }
         }
         if (!$bExternalStorage) {
             $urlComponents = parse_url($path);
             if ($urlComponents && strlen($urlComponents["path"]) > 0) {
                 $temp_path = CFile::GetTempName('', bx_basename($urlComponents["path"]));
             } else {
                 $temp_path = CFile::GetTempName('', bx_basename($path));
             }
             $ob = new CHTTP();
             $ob->follow_redirect = true;
             if ($ob->Download($path, $temp_path)) {
                 $arFile = CFile::MakeFileArray($temp_path);
             }
         } elseif ($temp_path) {
             $arFile = CFile::MakeFileArray($temp_path);
         }
     } elseif (preg_match("#^(ftp[s]?|php)://#", $path)) {
         if ($fp = fopen($path, "rb")) {
             $content = "";
             while (!feof($fp)) {
                 $content .= fgets($fp, 4096);
             }
             if (strlen($content) > 0) {
                 $temp_path = CFile::GetTempName('', bx_basename($path));
                 if (RewriteFile($temp_path, $content)) {
                     $arFile = CFile::MakeFileArray($temp_path);
                 }
             }
             fclose($fp);
         }
     } else {
         if (!file_exists($path)) {
             if (file_exists($_SERVER["DOCUMENT_ROOT"] . $path)) {
                 $path = $_SERVER["DOCUMENT_ROOT"] . $path;
             } else {
                 return NULL;
             }
         }
         if (is_dir($path)) {
             return NULL;
         }
         $arFile["name"] = $io->GetLogicalName(bx_basename($path));
         $arFile["size"] = filesize($path);
         $arFile["tmp_name"] = $path;
         $arFile["type"] = $mimetype;
         if (strlen($arFile["type"]) <= 0) {
             $arFile["type"] = CFile::GetContentType($path, true);
         }
     }
     if (strlen($arFile["type"]) <= 0) {
         $arFile["type"] = "unknown";
     }
     if (!isset($arFile["external_id"]) && $external_id != "") {
         $arFile["external_id"] = $external_id;
     }
     return $arFile;
 }
Example #6
0
 function put_commit(&$options)
 {
     if (!empty($options["IBLOCK_SECTION_ID"])) {
         $sectionData = $this->getSectionDataForLinkAnalyze($options["IBLOCK_SECTION_ID"], $this->getObject(array('section_id' => $options["IBLOCK_SECTION_ID"])));
         //simple detect link
         list($contextType, $contextEntityId) = $this->getContextData();
         $isSymlink = !$this->_symlinkMode && CWebDavSymlinkHelper::isLink($contextType, $contextEntityId, $sectionData);
         if ($isSymlink) {
             $symlinkSectionData = CWebDavSymlinkHelper::getLinkData($contextType, $contextEntityId, $sectionData);
             if ($symlinkSectionData) {
                 $linkWebdav = new self($symlinkSectionData[self::UF_LINK_IBLOCK_ID], $this->base_url . $this->_path, array_merge($this->_originalParams, array('ROOT_SECTION_ID' => $symlinkSectionData[self::UF_LINK_SECTION_ID], 'symlinkMode' => true, 'symlinkSectionData' => $symlinkSectionData, 'symlinkRealRootSectionData' => $this->arRootSection)));
                 $options = array_merge($options, array('IBLOCK_ID' => $symlinkSectionData[self::UF_LINK_IBLOCK_ID], 'IBLOCK_SECTION_ID' => $sectionData['ID']));
                 return $linkWebdav->put_commit($options);
             }
         }
     }
     $ID = intVal($options["ELEMENT_ID"]);
     $arError = array();
     $arFile = array("name" => $options["FILE_NAME"], "size" => $options["content_length"], "tmp_name" => $options["TMP_FILE"], "type" => "", "error" => 0);
     if (!empty($options['HEIGHT'])) {
         $arFile['HEIGHT'] = $options['HEIGHT'];
     }
     if (!empty($options['WIDTH'])) {
         $arFile['WIDTH'] = $options['WIDTH'];
     }
     if (is_set($options, "arFile")) {
         $arFile = $options["arFile"];
     }
     if (isset($arFile['tmp_name']) && is_file($arFile['tmp_name'])) {
         if (intval($arFile["size"]) <= 0) {
             $arFile["size"] = filesize($arFile["tmp_name"]);
         }
         if ($arFile['type'] == '' && $arFile["size"] > 0) {
             $arFile["type"] = CFile::GetContentType($arFile['tmp_name'], true);
         }
         if ($arFile['type'] == '' || $arFile['type'] == 'application/zip') {
             $arFile['type'] = $this->get_mime_type($arFile['name']);
         }
     }
     if (isset($arFile['tmp_name']) && strlen($arFile["type"]) <= 0) {
         $arFile["type"] = $this->get_mime_type($options["FILE_NAME"]);
     }
     $bDropped = isset($options['dropped']) ? $options['dropped'] : false;
     @set_time_limit(1000);
     if (is_set($options, "~path") && $_SESSION["WEBDAV_DATA"]["PUT_MAC_OS"] == $options["~path"]) {
         //			"For Mac OS";
         if ($options["new"]) {
             $arr = array("ACTIVE" => "N", "IBLOCK_ID" => $this->IBLOCK_ID, "IBLOCK_SECTION_ID" => $options["IBLOCK_SECTION_ID"], "NAME" => $options["FILE_NAME"], "MODIFIED_BY" => $GLOBALS["USER"]->GetID(), "PROPERTY_VALUES" => array($this->file_prop => $arFile, "WEBDAV_SIZE" => $arFile['size']));
             if ($arFile["size"] <= 0) {
                 unset($arr["PROPERTY_VALUES"]);
             }
             $ID = $this->_ib_elm_add($arr, false, false, false);
             if (!$ID) {
                 return false;
             } else {
                 $this->arParams["changed_element_id"] = $ID;
             }
         } else {
             $arr = array("MODIFIED_BY" => $GLOBALS["USER"]->GetID(), "PROPERTY_VALUES" => array($this->file_prop => $arFile, "WEBDAV_SIZE" => $arFile['size']));
             $res = $this->_ib_elm_update($options["ELEMENT_ID"], $arr, false);
             if (!$res) {
                 return false;
             }
         }
     } elseif (is_set($options, "~path") && $this->workflow && !$options["set_now"] && $_SESSION["WEBDAV_DATA"]["PUT_EMPTY"] == $options["~path"]) {
         $arr = array("MODIFIED_BY" => $GLOBALS["USER"]->GetID(), "PROPERTY_VALUES" => array($this->file_prop => $arFile, "WEBDAV_SIZE" => $arFile['size']));
         $res = $this->_ib_elm_update($options["ELEMENT_ID"], $arr, $this->workflow == 'workflow');
         if (!$res) {
             return false;
         }
         //if ($this->workflow == 'bizproc_limited' || $this->workflow == 'bizproc')
         //{
         /**
          * Update history comments
          */
         //$documentId = array($this->wfParams['DOCUMENT_TYPE'][0], $this->wfParams['DOCUMENT_TYPE'][1], $options["ELEMENT_ID"]);
         //$history = new CBPHistoryService();
         //$db_res = $history->GetHistoryList(
         //array("ID" => "DESC"),
         //array("DOCUMENT_ID" => $documentId),
         //false,
         //false,
         //array("ID", "DOCUMENT", "NAME")
         //);
         //if ($db_res && $arr = $db_res->Fetch())
         //{
         //$fullpath = $_SERVER["DOCUMENT_ROOT"].$arr["DOCUMENT"]["PROPERTIES"][$this->file_prop]["VALUE"];
         //if (!file_exists($fullpath) || filesize($fullpath) <= 0)
         //CBPHistoryService::Delete($arr["ID"], $documentId);
         //CBPDocument::AddDocumentToHistory($documentId, $arr["NAME"], $GLOBALS["USER"]->GetID());
         //}
         //}
         $_SESSION["WEBDAV_DATA"] = array();
         WDPackCookie();
     } else {
         if ($this->workflow == "workflow" && $this->permission < "W") {
             $fw_status_id = is_set($options, "WF_STATUS_ID") ? $options["WF_STATUS_ID"] : false;
             $arStatusesPermission = array();
             $db_res = CWorkflowStatus::GetDropDownList("N", "desc");
             while ($db_res && ($res = $db_res->Fetch())) {
                 $perm = CIBlockElement::WF_GetStatusPermission($res["REFERENCE_ID"]);
                 if ($perm < 1) {
                     continue;
                 }
                 $arStatusesPermission[intVal($res["REFERENCE_ID"])] = $perm;
                 if ($fw_status_id === false && $perm >= 2 || $fw_status_id == $res["REFERENCE_ID"]) {
                     $fw_status_id = $res["REFERENCE_ID"];
                     break;
                 }
             }
             if (empty($arStatusesPermission)) {
                 $this->LAST_ERROR = GetMessage("WD_FILE_ERROR_EMPTY_STATUSES");
                 return false;
             } elseif ($options["WF_STATUS_ID"] == $fw_status_id && !array_key_exists($fw_status_id, $arStatusesPermission)) {
                 $res = array_flip($arStatusesPermission);
                 $fw_status_id = isset($res[2]) ? $res[2] : reset($res);
             }
             $options["WF_STATUS_ID"] = $fw_status_id;
         } elseif ($this->workflow == 'bizproc' && !$bDropped) {
             $arDocumentStates = array();
             if (is_set($options, "arDocumentStates")) {
                 $arDocumentStates = $options["arDocumentStates"];
             } elseif (is_set($this->wfParams, "arDocumentStates")) {
                 $arDocumentStates = $this->wfParams["arDocumentStates"];
             } else {
                 $arDocumentStates = CBPDocument::GetDocumentStates($this->wfParams['DOCUMENT_TYPE'], $options["ELEMENT_ID"] > 0 ? array($this->wfParams['DOCUMENT_TYPE'][0], $this->wfParams['DOCUMENT_TYPE'][1], $options["ELEMENT_ID"]) : null);
             }
             foreach ($arDocumentStates as $key => $arDocumentState) {
                 if (strlen($arDocumentState["ID"]) <= 0 && is_array($arDocumentState["TEMPLATE_PARAMETERS"])) {
                     $templateId = $arDocumentState["TEMPLATE_ID"];
                     foreach ($arDocumentState["TEMPLATE_PARAMETERS"] as $key => $arWorkflowParameters) {
                         $_REQUEST["bizproc" . $templateId . "_" . $key] = array_key_exists("bizproc" . $templateId . "_" . $key, $_REQUEST) ? $_REQUEST["bizproc" . $templateId . "_" . $key] : $arWorkflowParameters["Default_printable"];
                     }
                 }
             }
             $arBizProcParametersValues = $arErrors = array();
             if (!CIBlockDocumentWebdav::StartWorkflowsParametersValidate($this->wfParams["DOCUMENT_TYPE"], $arDocumentStates, $arBizProcParametersValues, $arErrors)) {
                 $e = new CAdminException($arErrors);
                 $this->LAST_ERROR = $e->GetString();
                 return false;
             }
         }
         /**
          * Add or update or clone elements
          */
         if ($options["clone"]) {
             $arr = array("CREATED_BY" => $GLOBALS["USER"]->GetID(), "MODIFIED_BY" => $GLOBALS["USER"]->GetID(), "PROPERTY_VALUES" => array($this->file_prop => $arFile, "WEBDAV_SIZE" => $arFile['size'], static::PROPERTY_VERSION => 1));
             foreach (array("NAME", "TAGS", "PREVIEW_TEXT", "PREVIEW_TEXT_TYPE", "ACTIVE", "WF_COMMENTS", "WF_STATUS_ID") as $key) {
                 if (is_set($options, $key)) {
                     $arr[$key] = $options[$key];
                 }
             }
             if ($arFile["size"] <= 0) {
                 unset($arr["PROPERTY_VALUES"]);
             }
             $options["ELEMENT_ID"] = $ID = call_user_func_array(array($this->wfParams['DOCUMENT_TYPE'][1], "CloneElement"), array($options["PARENT_ELEMENT_ID"], $arr));
             CIBlockElement::SetPropertyValues($options["ELEMENT_ID"], $this->IBLOCK_ID, array(0), "FORUM_MESSAGE_CNT");
             CIBlockElement::SetPropertyValues($options["ELEMENT_ID"], $this->IBLOCK_ID, array(0), "FORUM_TOPIC_ID");
         } elseif ($options["new"]) {
             $arr = array("ACTIVE" => "Y", "IBLOCK_ID" => $this->IBLOCK_ID, "IBLOCK_SECTION_ID" => $options["IBLOCK_SECTION_ID"], "NAME" => $options["FILE_NAME"], "TAGS" => $options["TAGS"], "MODIFIED_BY" => $GLOBALS["USER"]->GetID(), "PREVIEW_TEXT_TYPE" => "html", "PREVIEW_TEXT" => $options["PREVIEW_TEXT"], "WF_COMMENTS" => !empty($options["WF_COMMENTS"]) ? $options["WF_COMMENTS"] : GetMessage("WD_FILE_IS_CREATED"), "PROPERTY_VALUES" => array($this->file_prop => $arFile, "WEBDAV_SIZE" => $arFile['size'], static::PROPERTY_VERSION => 1));
             if (isset($options['USER_FIELDS'])) {
                 $arr["USER_FIELDS"] = $options['USER_FIELDS'];
             }
             if ($this->workflow == 'workflow' && isset($options["WF_STATUS_ID"])) {
                 $arr["WF_STATUS_ID"] = $options["WF_STATUS_ID"];
             } else {
                 $arr["WF_STATUS_ID"] = 1;
             }
             if ($this->workflow == 'bizproc') {
                 $arr["BP_PUBLISHED"] = $this->wfParams["AUTO_PUBLISH"] == "Y" || $bDropped ? "Y" : "N";
             }
             $options["ELEMENT_ID"] = $ID = $this->_ib_elm_add($arr, ($_SERVER['REQUEST_METHOD'] != "LOCK" || $this->workflow != "workflow") && $this->workflow != false, $arFile['size'] > 0, false);
             if (!$ID) {
                 return false;
             } else {
                 $this->arParams["changed_element_id"] = $ID;
             }
         } else {
             $arUpdateType = array();
             $arr = array("MODIFIED_BY" => $GLOBALS["USER"]->GetID(), "WF_COMMENTS" => GetMessage("WD_FILE_IS_MODIFIED"));
             if (isset($options['USER_FIELDS'])) {
                 $arr["USER_FIELDS"] = $options['USER_FIELDS'];
             }
             if (!empty($arFile)) {
                 $arr["PROPERTY_VALUES"] = array($this->file_prop => $arFile, "WEBDAV_SIZE" => $arFile['size']);
                 $arUpdateType[] = 'FILE';
             }
             $element = $this->GetObject(array('element_id' => $options["ELEMENT_ID"]));
             foreach (array("NAME", "TAGS", "PREVIEW_TEXT", "ACTIVE", "IBLOCK_SECTION_ID", "WF_COMMENTS", "WF_STATUS_ID") as $key) {
                 if (is_set($options, $key)) {
                     $arr[$key] = $options[$key];
                     if (isset($element['element_array'][$key]) && $element['element_array'][$key] != $options[$key]) {
                         $arUpdateType[] = $key;
                     }
                 }
             }
             //if ($arFile["size"] <= 0)
             //unset($arr["PROPERTY_VALUES"]);
             if (is_set($arr, "PREVIEW_TEXT")) {
                 $arr["PREVIEW_TEXT_TYPE"] = 'html';
             }
             if (is_set($arr, "IBLOCK_SECTION_ID")) {
                 $arr["IBLOCK_SECTION_ID"] = intval($arr["IBLOCK_SECTION_ID"]);
                 if ($this->arRootSection && $arr["IBLOCK_SECTION_ID"] <= 0) {
                     $arr["IBLOCK_SECTION_ID"] = $this->arRootSection["ID"];
                 }
             }
             if ($_SERVER['REQUEST_METHOD'] != "LOCK" && !$options["clone"] && ($this->workflow == 'bizproc_limited' || $this->workflow == 'bizproc')) {
                 if (empty($arr["PROPERTY_VALUES"])) {
                     $arr["PROPERTY_VALUES"] = array();
                 }
                 if (empty($element['element_array']['PROPERTY_' . static::PROPERTY_VERSION . '_VALUE'])) {
                     //+1 - version from HEAD
                     $countAlreadyInHistory = (int) $this->countHistoryDocumentByFileId($options["ELEMENT_ID"]) + 1;
                 } else {
                     $countAlreadyInHistory = $element['element_array']['PROPERTY_' . static::PROPERTY_VERSION . '_VALUE'];
                 }
                 $arr["PROPERTY_VALUES"][static::PROPERTY_VERSION] = $countAlreadyInHistory + 1;
                 $options['THROUGH_VERSION'] = $arr["PROPERTY_VALUES"][static::PROPERTY_VERSION];
                 $this->AddDocumentToHistory($ID, $options['FILE_NAME']);
             }
             $res = $this->_ib_elm_update($options["ELEMENT_ID"], $arr, $this->workflow == "workflow");
             if (!$res) {
                 return false;
             }
             $ID = $options["ELEMENT_ID"];
             $this->_onEvent('Update', $ID, 'FILE', array('UPDATE_TYPE' => $arUpdateType));
             if ($this->workflow == 'bizproc' && is_set($arr, "IBLOCK_SECTION_ID")) {
                 $db_res2 = CIBlockElement::GetList(array(), array("WF_PARENT_ELEMENT_ID" => $options["ELEMENT_ID"], "SHOW_HISTORY" => "Y"), false, false, array("ID"));
                 if ($db_res2 && ($res2 = $db_res2->Fetch())) {
                     do {
                         $ar = array("IBLOCK_SECTION_ID" => $arr["IBLOCK_SECTION_ID"]);
                         $res = $this->_ib_elm_update($res2["ID"], $ar, false);
                     } while ($res2 = $db_res2->Fetch());
                 }
             }
         }
         $documentId = $this->wfParams["DOCUMENT_TYPE"];
         $documentId[2] = $ID;
         if ($this->workflow == 'bizproc' && !$bDropped) {
             if (!CIBlockDocumentWebdav::StartWorkflowsExecuting($documentId, $arDocumentStates, $arBizProcParametersValues, $options["arUserGroups"], $arErrors)) {
                 $e = new CAdminException($arErrors);
                 $this->LAST_ERROR = $e->GetString();
             }
         }
     }
     $this->CACHE['CWebDavIblock::GetObject'] = array();
     return true;
 }
Example #7
0
 function GetUserFields($arLdapUser, &$departmentCache = FALSE)
 {
     global $APPLICATION;
     $arFields = array('DN' => $arLdapUser['dn'], 'LOGIN' => $arLdapUser[strtolower($this->arFields['~USER_ID_ATTR'])], 'EXTERNAL_AUTH_ID' => 'LDAP#' . $this->arFields['ID'], 'LDAP_GROUPS' => $arLdapUser[strtolower($this->arFields['~USER_GROUP_ATTR'])]);
     // list of user field definitions
     $arRes = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("USER", 0, LANGUAGE_ID);
     // for each field, do the conversion
     foreach ($this->arFields["FIELD_MAP"] as $userField => $attr) {
         if (is_array($arRes[$userField])) {
             //"USER_TYPE_ID"
             if ($arRes[$userField]["MULTIPLE"] == "Y") {
                 if (is_array($arLdapUser[strtolower($attr)])) {
                     $arFields[$userField] = array_values($arLdapUser[strtolower($attr)]);
                 } else {
                     $arFields[$userField] = array($arLdapUser[strtolower($attr)]);
                 }
             } else {
                 if (!empty($arLdapUser[strtolower($attr)])) {
                     $arFields[$userField] = $arLdapUser[strtolower($attr)];
                 } else {
                     if (!empty($arRes[$userField]['SETTINGS']['DEFAULT_VALUE'])) {
                         if (is_array($arRes[$userField]['SETTINGS']['DEFAULT_VALUE'])) {
                             if (!empty($arRes[$userField]['SETTINGS']['DEFAULT_VALUE']['VALUE'])) {
                                 $arFields[$userField] = $arRes[$userField]['SETTINGS']['DEFAULT_VALUE']['VALUE'];
                             }
                         } else {
                             $arFields[$userField] = $arRes[$userField]['SETTINGS']['DEFAULT_VALUE'];
                         }
                     }
                 }
             }
         } elseif (preg_match("/(.*)&([0-9]+)/", $attr, $arMatch)) {
             if (intval($arLdapUser[strtolower($arMatch[1])]) & intval($arMatch[2])) {
                 $arFields[$userField] = "N";
             } else {
                 $arFields[$userField] = "Y";
             }
         } elseif ($userField == "PERSONAL_PHOTO") {
             $arFields["PERSONAL_PHOTO"] = "";
             if ($arLdapUser[strtolower($attr)] == "") {
                 continue;
             }
             $fExt = CLdapUtil::GetImgTypeBySignature($arLdapUser[strtolower($attr)][0]);
             if (!$fExt) {
                 continue;
             }
             $tmpDir = CTempFile::GetDirectoryName();
             CheckDirPath($tmpDir);
             $fname = "ad_" . rand() . "." . $fExt;
             if (!file_put_contents($tmpDir . $fname, $arLdapUser[strtolower($attr)][0])) {
                 continue;
             }
             $arFields["PERSONAL_PHOTO"] = array("name" => $fname, "type" => CFile::GetContentType($tmpDir . $fname), "tmp_name" => $tmpDir . $fname);
         } else {
             $arFields[$userField] = $arLdapUser[strtolower($attr)];
         }
         if (is_null($arFields[$userField])) {
             $arFields[$userField] = false;
         }
     }
     $APPLICATION->ResetException();
     $db_events = GetModuleEvents("ldap", "OnLdapUserFields");
     while ($arEvent = $db_events->Fetch()) {
         $arParams = array(array(&$arFields, $arLdapUser));
         if (ExecuteModuleEventEx($arEvent, $arParams) === false) {
             if (!($err = $APPLICATION->GetException())) {
                 $APPLICATION->ThrowException("Unknown error");
             }
             return false;
         }
         $arFields = $arParams[0][0];
     }
     // set a department field, if needed
     if (empty($arFields['UF_DEPARTMENT']) && isModuleInstalled('intranet') && $this->arFields['IMPORT_STRUCT'] && $this->arFields['IMPORT_STRUCT'] == 'Y') {
         //$arLdapUser[$this->arFields['USER_DN_ATTR']]
         $username = $arLdapUser[$this->arFields['USER_ID_ATTR']];
         if ($arDepartment = $this->GetDepartmentIdForADUser($arLdapUser[$this->arFields['USER_DEPARTMENT_ATTR']], $arLdapUser[$this->arFields['USER_MANAGER_ATTR']], $username, $departmentCache)) {
             // fill in cache. it is done outside the function because it has many exit points
             if ($departmentCache) {
                 $departmentCache[$username] = $arDepartment;
             }
             // this is not final assignment
             // $arFields['UF_DEPARTMENT'] sould contain array of department ids
             // but somehow we have to return an information whether this user is a department head
             // so we'll save this data here temporarily
             $arFields['UF_DEPARTMENT'] = $arDepartment;
         } else {
             $arFields['UF_DEPARTMENT'] = array();
         }
         // at this point $arFields['UF_DEPARTMENT'] should be set to some value, even an empty array is ok
     }
     if (!is_array($arFields['LDAP_GROUPS'])) {
         $arFields['LDAP_GROUPS'] = !empty($arFields['LDAP_GROUPS']) ? array($arFields['LDAP_GROUPS']) : array();
     }
     $primarygroupid_name_attr = 'primarygroupid';
     $primarygrouptoken_name_attr = 'primarygrouptoken';
     if ($this->arFields['USER_GROUP_ACCESSORY'] == 'Y') {
         $primarygroupid_name_attr = strtolower($this->arFields['GROUP_ID_ATTR']);
         $primarygrouptoken_name_attr = strtolower($this->arFields['USER_GROUP_ATTR']);
         $userIdAttr = strtolower($this->arFields['USER_ID_ATTR']);
         $groupMemberAttr = strtolower($this->arFields['GROUP_MEMBERS_ATTR']);
     }
     $arAllGroups = $this->GetGroupListArray();
     if (!is_array($arAllGroups) || count($arAllGroups) <= 0) {
         return $arFields;
     }
     $arGroup = reset($arAllGroups);
     do {
         if (in_array($arGroup['ID'], $arFields['LDAP_GROUPS'])) {
             continue;
         }
         if (is_set($arLdapUser, $primarygroupid_name_attr) && $arGroup[$primarygrouptoken_name_attr] == $arLdapUser[$primarygroupid_name_attr] || $this->arFields['USER_GROUP_ACCESSORY'] == 'Y' && is_set($arGroup, $groupMemberAttr) && (is_array($arGroup[$groupMemberAttr]) && in_array($arLdapUser[$userIdAttr], $arGroup[$groupMemberAttr]) || $arLdapUser[$userIdAttr] == $arGroup[$groupMemberAttr])) {
             $arFields['LDAP_GROUPS'][] = $arGroup['ID'];
             if ($this->arFields['USER_GROUP_ACCESSORY'] == 'N') {
                 break;
             }
         }
     } while ($arGroup = next($arAllGroups));
     return $arFields;
 }
Example #8
0
	/**
	 * Copies file from really tmp dir to repo
	 * @param $file
	 * @param $canvas
	 * @param $res
	 * @return string
	 */
	private function copyFile($file, $canvas, &$res)
	{
		$hash = $this->getHash($file);
		$io = CBXVirtualIo::GetInstance();
		$directory = $io->GetDirectory($this->path.$hash);
		$path = $this->path.$hash."/".$canvas;
		$error = "";
		if (!$directory->Create())
			$error = "BXU001";
		elseif ($res["error"] > 0 || !array_key_exists('chunks', $res) && !file_exists($res['tmp_name']))
		{
			$error = "BXU347";
			if ($canvas != "default" && !empty($file["files"]["default"]) &&
				$res["width"] <= $file["files"]["default"]["width"] && $res["height"] <= $file["files"]["default"]["height"])
			{
				@copy($file["files"]["default"]["tmp_path"], $path);
				if (is_file($path))
				{
					@chmod($path, FX_FILE_PERMISSIONS);
					$res["tmp_name"] = $path;
				}
				else
				{
					$error = "BXU348";
					$this->log($file["id"], $res["~name"], array("status" => "error", "note" => $error));
				}
			}
			else
			{
				$error = "BXU347";
				$this->log($file["id"], $res["~name"], array("status" => "error", "note" => $error));
			}
		}
		elseif (!empty($res['chunks']))
		{
			if ($res["packages"] <= count($res["chunks"])) // TODO glue pieces
			{
				$buff = 4096;
				$fdst = fopen($path, 'a');
				foreach($res["chunks"] as $key => $chunk)
				{
					$fsrc = fopen($chunk['tmp_name'], 'r');
					while(($data = fread($fsrc, $buff)) !== '')
					{
						fwrite($fdst, $data);
					}
					fclose($fsrc);
					$this->log($file["id"], $chunk["~name"], array("status" => "uploaded"));
					unlink($chunk['tmp_name']);
				}
				fclose($fdst);
				@chmod($path, FX_FILE_PERMISSIONS);
				unset($res["chunks"]);
				$res["tmp_name"] = $path;
				$res["type"] = (array_key_exists("type", $file) ? $file["type"] : CFile::GetContentType($path));
				$res["size"] = filesize($path);
			}
			else
			{
				foreach($res['chunks'] as $package => $chunk)
				{
					$tmp_name = $path.".".$package;
					if (file_exists($tmp_name) && filesize($tmp_name) == filesize($chunk["tmp_name"]) || move_uploaded_file($chunk["tmp_name"], $tmp_name))
					{
						$res['chunks'][$package]["tmp_name"] = $tmp_name;
						$this->log($file["id"], $chunk["~name"], array("status" => "uploaded"));
					}
					else
					{
						$error = "BXU348";
						$this->log($file["id"], $chunk["~name"], array("status" => "error", "note" => $error));
					}
				}
			}
		}
		elseif (file_exists($res['tmp_name']) && file_exists($path) && filesize($res['tmp_name']) == filesize($path) ||
			move_uploaded_file($res['tmp_name'], $path))
		{
			$res["tmp_name"] = $path;
			$res["size"] = filesize($path);
			if (empty($res["type"]))
				$res["type"] = (array_key_exists("type", $file) ? $file["type"] : CFile::GetContentType($path));
			$this->log($file["id"], $res["~name"], array("status" => "uploaded"));
		}
		else
		{
			$error = "BXU348";
			$this->log($file["id"], $res["~name"], array("status" => "error", "note" => $error));
		}
		$res["name"] = $file["name"];

		if ($canvas != "default" && array_key_exists("type", $file))
			$res["type"] = $file["type"];
		return $error;
	}
 function _processFileCallback($matches)
 {
     static $sImageAlign = '';
     $bLink = false;
     if ($matches[1] == ':') {
         $bLink = true;
     }
     // if the internal file then get it
     $sFile = $sFileName = $sPath = trim($matches[3]);
     $bOur = false;
     if (is_numeric($sFile) && in_array($sFile, $this->arFile)) {
         $arFile = CFile::GetFileArray($sFile);
         if ($arFile != false) {
             $bOur = true;
             $sPath = $arFile['SRC'];
             $sFileName = $arFile['ORIGINAL_NAME'];
         }
     } else {
         if (isset($this->arVersionFile[strtolower($sFile)])) {
             $sPath = $this->arVersionFile[strtolower($sFile)];
             $sFileName = $sFile;
         } else {
             if (!empty($this->arFile)) {
                 $arFilter = array('@ID' => implode(',', $this->arFile));
                 $rsFile = CFile::GetList(array(), $arFilter);
                 while ($arFile = $rsFile->Fetch()) {
                     if ($arFile['ORIGINAL_NAME'] == $sFile) {
                         $bOur = true;
                         $sFile = $arFile['ID'];
                         $sPath = CFile::GetFileSRC($arFile);
                         $sFileName = $arFile['ORIGINAL_NAME'];
                         break;
                     }
                 }
             }
         }
     }
     // if the image is processed as a picture
     $sName = bx_basename($sPath);
     if (CFile::IsImage($sName)) {
         if ($bOur) {
             $tmpName = $_SERVER["DOCUMENT_ROOT"] . $sPath;
             $imageFile = array("name" => $sFileName, "tmp_name" => CBXVirtualIoFileSystem::ConvertCharset($tmpName), "type" => CFile::GetContentType($tmpName));
             $checkRes = CFile::CheckImageFile($imageFile);
             if ($checkRes != null) {
                 return $checkRes;
             }
             if ($bLink) {
                 $sReturn = '<a href="' . htmlspecialcharsbx($sPath) . '" title="' . ($s = htmlspecialcharsbx($sFileName)) . '">' . $s . '</a>';
             } else {
                 $sReturn = CFile::ShowImage($sFile, COption::GetOptionString('wiki', 'image_max_width', 600), COption::GetOptionString('wiki', 'image_max_height', 600), 'border="0" align="' . $sImageAlign . '"');
             }
         } else {
             if ($bLink) {
                 $sReturn = '<a href="' . htmlspecialcharsbx($sPath) . '" title="' . ($s = htmlspecialcharsbx($sName)) . '">' . $s . '</a>';
             } else {
                 $sReturn = '<img src="' . htmlspecialcharsbx($sPath) . '" alt="' . htmlspecialcharsbx($sFileName) . '"/>';
             }
         }
     } else {
         if (strpos($sPath, 'http://') === 0) {
             $sReturn = ' [ <a href="' . htmlspecialcharsbx($sFile) . '" title="' . GetMessage('FILE_FILE_DOWNLOAD') . '">' . GetMessage('FILE_DOWNLOAD') . '</a> ] ';
         } else {
             $sReturn = '[' . GetMessage('FILE_NAME') . ':' . htmlspecialcharsbx(is_numeric($sFile) || empty($sFileName) ? $sFile : $sFileName) . ']';
         }
     }
     return $sReturn;
 }