当前位置: 首页>>代码示例>>PHP>>正文


PHP CFile::GetContentType方法代码示例

本文整理汇总了PHP中CFile::GetContentType方法的典型用法代码示例。如果您正苦于以下问题:PHP CFile::GetContentType方法的具体用法?PHP CFile::GetContentType怎么用?PHP CFile::GetContentType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CFile的用法示例。


在下文中一共展示了CFile::GetContentType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: copyFile

 /**
  * 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;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:50,代码来源:uploader.php

示例2: ViewByUser

 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) {
//.........这里部分代码省略.........
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:101,代码来源:file.php

示例3: getLdapValueByBitrixFieldName

 /**
  * 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;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:66,代码来源:ldap.php

示例4: MakeFileArray


//.........这里部分代码省略.........
     $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;
 }
开发者ID:nycmic,项目名称:bittest,代码行数:101,代码来源:file.php

示例5: put_commit

 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())) {
//.........这里部分代码省略.........
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:iblock.php

示例6: GetUserFields

 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']);
//.........这里部分代码省略.........
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:101,代码来源:ldap.php

示例7: copyFile

	/**
	 * 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"];
//.........这里部分代码省略.........
开发者ID:ASDAFF,项目名称:open_bx,代码行数:101,代码来源:uploader.php

示例8: _processFileCallback

 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;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:68,代码来源:wiki_parser.php


注:本文中的CFile::GetContentType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。