本文整理汇总了PHP中CTempFile::GetDirectoryName方法的典型用法代码示例。如果您正苦于以下问题:PHP CTempFile::GetDirectoryName方法的具体用法?PHP CTempFile::GetDirectoryName怎么用?PHP CTempFile::GetDirectoryName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTempFile
的用法示例。
在下文中一共展示了CTempFile::GetDirectoryName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: receiveFiles
protected function receiveFiles()
{
$result = array();
$timeToKeepFiles = 24;
$tmpDir = \CTempFile::GetDirectoryName($timeToKeepFiles);
CheckDirPath($tmpDir);
$sftp = \Bitrix\Sale\TradingPlatform\Ebay\Helper::getSftp($this->siteId);
$sftp->connect();
/*
$orderFiles = $sftp->getFilesList($this->remotePath);
foreach($orderFiles as $file)
{
if($sftp->downloadFile($this->remotePath."/".$file, $tmpDir.$file))
{
$result[] = $tmpDir.$file;
Ebay::log(Logger::LOG_LEVEL_INFO, "EBAY_DATA_SOURCE_ORDERFILE_RECEIVED", $file, "File received successfully.", $this->siteId);
}
}
*/
$file = "orderLatest";
if ($sftp->downloadFile($this->orderLatest, $tmpDir . $file)) {
$result[] = $tmpDir . $file;
Ebay::log(Logger::LOG_LEVEL_INFO, "EBAY_DATA_SOURCE_ORDERFILE_RECEIVED", $file, "File received successfully.", $this->siteId);
}
return $result;
}
示例2: getFileContent
protected function getFileContent($feedData)
{
$result = "";
$timeToKeepFiles = 24;
$tmpDir = \CTempFile::GetDirectoryName($timeToKeepFiles);
CheckDirPath($tmpDir);
$sftp = \Bitrix\Sale\TradingPlatform\Ebay\Helper::getSftp($this->siteId);
$sftp->connect();
$remotePath = $this->createRemotePath($feedData);
$files = $sftp->getFilesList($remotePath);
foreach ($files as $file) {
if (!strstr($file, $feedData["FILENAME"])) {
continue;
}
if ($sftp->downloadFile($remotePath . "/" . $file, $tmpDir . $file)) {
$result = file_get_contents($tmpDir . $file);
Ebay::log(Logger::LOG_LEVEL_INFO, "EBAY_DATA_SOURCE_RESULTS_RECEIVED", $file, "File received successfully.", $this->siteId);
} else {
Ebay::log(Logger::LOG_LEVEL_ERROR, "EBAY_DATA_SOURCE_RESULTS_ERROR", $tmpDir . $file, "Can't receive file content.", $this->siteId);
}
}
return $result;
}
示例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;
}
示例4: GetMessage
break;
}
}
}
$res = '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . LANGUAGE_ID . '" lang="' . LANGUAGE_ID . '">
<body>
<script>alert("' . GetMessage("HK_EXP_FALSE") . '");
window.close();
</script>
</body></html>';
break;
case 'import':
if (!$_FILES['bx_hk_filename']['name'] || !$_FILES['bx_hk_filename']['size']) {
$res = '<script type="text/javascript">window.parent.BXHotKeys.OnImportResponse(0);</script>';
break;
}
$numImported = 0;
$tmpDir = CTempFile::GetDirectoryName();
CheckDirPath($tmpDir);
$name = $tmpDir . basename($_FILES['bx_hk_filename']['name']);
if (move_uploaded_file($_FILES['bx_hk_filename']['tmp_name'], $tmpDir . CHotKeys::$ExpImpFileName)) {
$numImported = $hkInstance->Import($tmpDir . CHotKeys::$ExpImpFileName, $uid);
}
$res = '<script type="text/javascript">window.parent.BXHotKeys.OnImportResponse("' . $numImported . '");</script>';
break;
}
echo $res;
}
require $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/epilog_admin_after.php";
示例5: __construct
/**
* @param $script - url for detail
*/
function __construct($params = array(), $doCheckPost = true)
{
global $APPLICATION;
$this->errorCode = array(
"BXU344" => GetMessage("UP_CID_IS_REQUIRED"),
"BXU344.1" => GetMessage("UP_PACKAGE_INDEX_IS_REQUIRED"),
"BXU345" => GetMessage("UP_BAD_SESSID"),
"BXU346" => GetMessage("UP_NOT_ENOUGH_PERMISSION"),
"BXU347" => GetMessage("UP_FILE_IS_LOST"),
"BXU348" => GetMessage("UP_FILE_IS_NOT_UPLOADED"));
$params = (is_array($params) ? $params : array());
$this->script = (array_key_exists("urlToUpload", $params) ? $params["urlToUpload"] : $APPLICATION->GetCurPageParam());
if (array_key_exists("copies", $params) && is_array($params["copies"]))
{
$copies = array();
foreach($params["copies"] as $key => $val)
{
if (is_array($val) && (array_key_exists("width", $val) || array_key_exists("height", $val)))
$copies[$key] = array("width" => $val["width"], "height" => $val["height"]);
}
if (!empty($copies))
$this->params["copies"] = $copies;
}
if (array_key_exists("uploadFileWidth", $params))
$this->params["uploadFileWidth"] = $params["uploadFileWidth"];
if (array_key_exists("uploadFileHeight", $params))
$this->params["uploadFileHeight"] = $params["uploadFileHeight"];
if (array_key_exists("uploadMaxFilesize", $params))
$this->params["uploadMaxFilesize"] = $params["uploadMaxFilesize"];
if (array_key_exists("events", $params) && is_array($params["events"]))
{
foreach($params["events"] as $key => $val)
{
AddEventHandler(self::EVENT_NAME, $key, $val);
}
}
if (array_key_exists("allowUpload", $params))
{
// ALLOW_UPLOAD = 'A'll files | 'I'mages | 'F'iles with selected extensions
// ALLOW_UPLOAD_EXT = comma-separated list of allowed file extensions (ALLOW_UPLOAD='F')
$this->params["allowUpload"] = (in_array($params["allowUpload"], array("A", "I", "F")) ? $params["allowUpload"] : "A");
if ($params["allowUpload"] == "F" && empty($params["allowUploadExt"]))
$this->params["allowUpload"] = "A";
$this->params["allowUploadExt"] = $params["allowUploadExt"];
}
if (array_key_exists("controlId", $params))
$this->controlId = $params["controlId"];
$this->params["controlId"] = $this->controlId;
$this->path = CTempFile::GetDirectoryName(
12,
array(
"bxu",
md5(serialize(array(
$this->controlId,
bitrix_sessid(),
CMain::GetServerUniqID()
))
)
)
);
if ($doCheckPost !== false && !$this->checkPost(($doCheckPost === true || $doCheckPost == "post")))
{
$this->showError();
}
return $this;
}
示例6: isset
$strError = '';
$arResult['STEP'] = isset($_POST['step']) ? intval($_POST['step']) : 1;
if ($_SERVER['REQUEST_METHOD'] == 'POST' && check_bitrix_sessid()) {
if (isset($_POST['next'])) {
if ($arResult['STEP'] == 1) {
if ($_FILES['IMPORT_FILE']['error'] > 0) {
ShowError(GetMessage('CRM_CSV_NF_ERROR'));
} else {
$error = CFile::CheckFile($_FILES['IMPORT_FILE'], 0, 0, 'csv,txt');
if ($error !== '') {
ShowError($error);
} else {
if (isset($_SESSION['CRM_IMPORT_FILE'])) {
unset($_SESSION['CRM_IMPORT_FILE']);
}
$sTmpFilePath = CTempFile::GetDirectoryName(12, 'crm');
CheckDirPath($sTmpFilePath);
$_SESSION['CRM_IMPORT_FILE_SKIP_EMPTY'] = isset($_POST['IMPORT_FILE_SKIP_EMPTY']) && $_POST['IMPORT_FILE_SKIP_EMPTY'] == 'Y' ? true : false;
$_SESSION['CRM_IMPORT_FILE_FIRST_HEADER'] = isset($_POST['IMPORT_FILE_FIRST_HEADER']) && $_POST['IMPORT_FILE_FIRST_HEADER'] == 'Y' ? true : false;
$_SESSION['CRM_IMPORT_FILE'] = $sTmpFilePath . md5($_FILES['IMPORT_FILE']['tmp_name']) . '.tmp';
$_SESSION['CRM_IMPORT_FILE_POS'] = 0;
move_uploaded_file($_FILES['IMPORT_FILE']['tmp_name'], $_SESSION['CRM_IMPORT_FILE']);
@chmod($_SESSION['CRM_IMPORT_FILE'], BX_FILE_PERMISSIONS);
if (isset($_POST['IMPORT_FILE_ENCODING'])) {
$fileEncoding = $_POST['IMPORT_FILE_ENCODING'];
if ($fileEncoding !== '' && $fileEncoding !== '_' && $fileEncoding !== strtolower(SITE_CHARSET)) {
$convertCharsetErrorMsg = '';
$fileHandle = fopen($_SESSION['CRM_IMPORT_FILE'], 'rb');
$fileContents = fread($fileHandle, filesize($_SESSION['CRM_IMPORT_FILE']));
fclose($fileHandle);
//HACK: Remove UTF-8 BOM
示例7: while
$db_res = CLanguage::GetList($b = "sort", $o = "asc");
while ($res = $db_res->Fetch()) {
$arLang[$res["LID"]] = $res;
$arLangTitle["reference_id"][] = $res["LID"];
$arLangTitle["reference"][] = htmlspecialcharsbx($res["NAME"]);
}
$bInitVars = false;
$bImportComplete = false;
$APPLICATION->SetTitle(GetMessage("SMILE_IMPORT_TITLE"));
$fileName = '';
if ($REQUEST_METHOD == "POST" && (strlen($save) > 0 || strlen($apply) > 0)) {
$fileName = 'import' . $USER->GetID() . time() . '.zip';
if (!check_bitrix_sessid()) {
$arError[] = array("id" => "bad_sessid", "text" => GetMessage("ERROR_BAD_SESSID"));
} elseif (!empty($_FILES["IMPORT"]["tmp_name"])) {
$sUploadDir = CTempFile::GetDirectoryName(1);
CheckDirPath($sUploadDir);
$res = CFile::CheckFile($_FILES["IMPORT"], 500000, false, 'zip');
if (strLen($res) > 0) {
$arError[] = array("id" => "IMPORT", "text" => $res);
} elseif (file_exists($sUploadDir . $fileName)) {
$arError[] = array("id" => "IMPORT", "text" => GetMessage("ERROR_EXISTS_FILE"));
} elseif (!@copy($_FILES["IMPORT"]["tmp_name"], $sUploadDir . $fileName)) {
$arError[] = array("id" => "IMPORT", "text" => GetMessage("ERROR_COPY_FILE"));
} else {
@chmod($sUploadDir . $fileName, BX_FILE_PERMISSIONS);
}
} elseif (empty($_FILES["IMPORT"]["tmp_name"])) {
$arError[] = array("id" => "IMPORT", "text" => GetMessage("ERROR_EXISTS_FILE"));
}
if (empty($arError)) {
示例8: Export
/**
* Exports current user's binded hot keys and using custom codes
* @return string exported file name
* */
public function Export()
{
$this->LoadToCache();
if (!is_array($this->arList) || empty($this->arList)) {
return false;
}
$arForExport = array();
$tmpDir = CTempFile::GetDirectoryName();
CheckDirPath($tmpDir);
$tmpExportFile = $tmpDir . self::$ExpImpFileName;
foreach ($this->arList as $arHK) {
$res = self::$codes->GetByID($arHK['CODE_ID']);
$arTmpCode = $res->Fetch();
if (!is_array($arTmpCode) || empty($arTmpCode)) {
continue;
}
$arTmpLink = array('KEYS_STRING' => $arHK['KEYS_STRING'], 'CLASS_NAME' => $arTmpCode['CLASS_NAME'], 'NAME' => $arTmpCode['NAME'], 'IS_CUSTOM' => $arTmpCode['IS_CUSTOM']);
if ($arTmpCode['IS_CUSTOM']) {
$arTmpLink['CODE'] = $arTmpCode['CODE'];
$arTmpLink['COMMENTS'] = $arTmpCode['COMMENTS'];
$arTmpLink['URL'] = $arTmpCode['URL'];
}
$arForExport[] = $arTmpLink;
}
$result = file_put_contents($tmpExportFile, serialize($arForExport));
if ($result === false) {
return false;
}
return $tmpExportFile;
}
示例9: trim
Input params
********************************************************************/
/***************** BASE ********************************************/
$arParams["IBLOCK_TYPE"] = trim($arParams["IBLOCK_TYPE"]);
$arParams["IBLOCK_ID"] = intVal($arParams["IBLOCK_ID"]);
$arParams["SECTION_ID"] = intVal($arParams["SECTION_ID"]);
$arParams["USER_ALIAS"] = trim($arParams["USER_ALIAS"]);
$arParams["BEHAVIOUR"] = $arParams["BEHAVIOUR"] == "USER" ? "USER" : "SIMPLE";
$arParams["PERMISSION_EXTERNAL"] = trim($arParams["PERMISSION"]);
$arParams["IMAGE_UPLOADER_ACTIVEX_CLSID"] = "718B3D1E-FF0C-4EE6-9F3B-0166A5D1C1B9";
$arParams["IMAGE_UPLOADER_ACTIVEX_CONTROL_VERSION"] = "6,0,20,0";
$arParams["IMAGE_UPLOADER_JAVAAPPLET_VERSION"] = "6.0.20.0";
$arParams["THUMBNAIL_ACTIVEX_CLSID"] = "58C8ACD5-D8A6-4AC8-9494-2E6CCF6DD2F8";
$arParams["THUMBNAIL_ACTIVEX_CONTROL_VERSION"] = "3,5,204,0";
$arParams["THUMBNAIL_JAVAAPPLET_VERSION"] = "1.1.81.0";
$arParams["PATH_TO_TMP"] = CTempFile::GetDirectoryName(12, "uploader");
/***************** URL *********************************************/
$URL_NAME_DEFAULT = array("index" => "", "gallery" => "PAGE_NAME=gallery&USER_ALIAS=#USER_ALIAS#", "section" => "PAGE_NAME=section" . ($arParams["BEHAVIOUR"] == "USER" ? "&USER_ALIAS=#USER_ALIAS#" : "") . "&SECTION_ID=#SECTION_ID#", "section_edit" => "PAGE_NAME=section_edit" . ($arParams["BEHAVIOUR"] == "USER" ? "&USER_ALIAS=#USER_ALIAS#" : "") . "&SECTION_ID=#SECTION_ID#");
foreach ($URL_NAME_DEFAULT as $URL => $URL_VALUE) {
$arParams[strToUpper($URL) . "_URL"] = trim($arParams[strToUpper($URL) . "_URL"]);
if (empty($arParams[strToUpper($URL) . "_URL"])) {
$arParams[strToUpper($URL) . "_URL"] = $APPLICATION->GetCurPage() . "?" . $URL_VALUE;
}
$arParams["~" . strToUpper($URL) . "_URL"] = $arParams[strToUpper($URL) . "_URL"];
$arParams[strToUpper($URL) . "_URL"] = htmlspecialcharsbx($arParams["~" . strToUpper($URL) . "_URL"]);
}
$arParams["SUCCESS_URL"] = CHTTP::urlDeleteParams(CComponentEngine::MakePathFromTemplate($arParams["~SECTION_URL"], array("USER_ALIAS" => $arParams["USER_ALIAS"], "SECTION_ID" => $arParams["SECTION_ID"])), array("sessid", "uploader_redirect"), true);
$arParams["REDIRECT_URL"] = $arParams["ACTION_URL"];
$arParams["REDIRECT_URL"] = CHTTP::urlDeleteParams($arParams["REDIRECT_URL"], array("clear_cache", "bitrix_include_areas", "bitrix_show_mode", "back_url_admin", "bx_photo_ajax", "change_view_mode_data", "sessid", "uploader_redirect"));
$arParams["REDIRECT_URL"] .= (strpos($arParams["REDIRECT_URL"], "?") === false ? "?" : "&") . "uploader_redirect=Y&sessid=" . bitrix_sessid();
$arParams["SIMPLE_FORM_URL"] = $APPLICATION->GetCurPageParam("view_mode=form&" . bitrix_sessid_get(), array("view_mode", "sessid", "uploader_redirect"));
示例10: OnPostForm
function OnPostForm()
{
$wizard =& $this->GetWizard();
if ($wizard->IsNextButtonClick() || $wizard->IsFinishButtonClick()) {
$locations_csv = $wizard->GetVar('locations_csv');
$load_zip = $wizard->GetVar('load_zip');
if (strlen($locations_csv) <= 0 && $load_zip != 'Y') {
$this->SetError(GetMessage('WSL_STEP2_GFILE_ERROR'), 'locations_csv');
}
if ($locations_csv == "locations.csv") {
if (!is_uploaded_file($_FILES["FILE_IMPORT_UPLOAD"]["tmp_name"]) || !file_exists($_FILES["FILE_IMPORT_UPLOAD"]["tmp_name"])) {
$this->SetError(GetMessage("NO_LOC_FILE"), 'locations_csv');
} else {
$fp = fopen($_FILES["FILE_IMPORT_UPLOAD"]["tmp_name"], 'r');
$contents = fread($fp, filesize($_FILES["FILE_IMPORT_UPLOAD"]["tmp_name"]));
fclose($fp);
$contents = $GLOBALS["APPLICATION"]->ConvertCharset($contents, 'windows-1251', LANG_CHARSET);
$sTmpFilePath = CTempFile::GetDirectoryName(12, 'sale');
CheckDirPath($sTmpFilePath);
$fp = fopen($sTmpFilePath . "locations.csv", 'w+');
fwrite($fp, $contents);
fclose($fp);
}
}
}
}
示例11: preg_replace
$filename = preg_replace("#^(/tmp/|upload/1c/webdata)#", "", $_GET["filename"]);
$filename = trim(str_replace("\\", "/", trim($filename)), "/");
$io = CBXVirtualIo::GetInstance();
$bBadFile = HasScriptExtension($filename) || IsFileUnsafe($filename) || !$io->ValidatePathString("/" . $filename);
if (!$bBadFile) {
$filename = trim(str_replace("\\", "/", trim($filename)), "/");
$FILE_NAME = rel2abs($DIR_NAME, "/" . $filename);
if (strlen($FILE_NAME) > 1 && $FILE_NAME === "/" . $filename) {
$ABS_FILE_NAME = $DIR_NAME . $FILE_NAME;
$WORK_DIR_NAME = substr($ABS_FILE_NAME, 0, strrpos($ABS_FILE_NAME, "/") + 1);
}
}
}
if ($_GET["mode"] == "init") {
if ($arParams["USE_TEMP_DIR"] === "Y") {
$DIR_NAME = CTempFile::GetDirectoryName(6, "1c_exchange");
} else {
$DIR_NAME = $_SERVER["DOCUMENT_ROOT"] . "/" . COption::GetOptionString("main", "upload_dir", "upload") . "/1c_exchange/";
DeleteDirFilesEx(substr($DIR_NAME, strlen($_SERVER["DOCUMENT_ROOT"])));
}
CheckDirPath($DIR_NAME);
if (!is_dir($DIR_NAME)) {
echo "failure\n" . GetMessage("CC_BSC1_ERROR_INIT");
} else {
$ht_name = $DIR_NAME . ".htaccess";
if (!file_exists($ht_name)) {
$fp = fopen($ht_name, "w");
if ($fp) {
fwrite($fp, "Deny from All");
fclose($fp);
@chmod($ht_name, BX_FILE_PERMISSIONS);
示例12: downloadFile
protected static function downloadFile($fileName, $storeAs, $skip404 = false, $storeTo = false)
{
if ($storeTo === false) {
$storeTo = \CTempFile::GetDirectoryName(5);
}
$storeTo .= $storeAs;
if (file_exists($storeTo)) {
if (!is_writable($storeTo)) {
throw new Main\SystemException('Cannot remove previous ' . $storeAs . ' file');
}
unlink($storeTo);
}
$query = 'http://' . self::DISTRIBUTOR_HOST . ':' . self::DISTRIBUTOR_PORT . self::REMOTE_PATH . $fileName;
$client = new HttpClient();
if (!$client->download($query, $storeTo)) {
$eFormatted = array();
foreach ($client->getError() as $code => $desc) {
$eFormatted[] = trim($desc . ' (' . $code . ')');
}
throw new Main\SystemException('File download failed: ' . implode(', ', $eFormatted) . ' (' . $query . ')');
}
$status = intval($client->getStatus());
if ($status != 200 && file_exists($storeTo)) {
unlink($storeTo);
}
$okay = $status == 200 || $status == 404 && $skip404;
// honestly we should check for all 2xx codes, but for now this is enough
if (!$okay) {
throw new Main\SystemException('File download failed: http error ' . $status . ' (' . $query . ')');
}
return filesize($storeTo);
}
示例13: 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']);
//.........这里部分代码省略.........
示例14: fillRequireData
private function fillRequireData($requestType)
{
$this->mode = $this->getPost("mode", $requestType);
$this->CID = $this->getPost("CID", $requestType);
$this->path = CTempFile::GetDirectoryName(
12,
array(
"bxu",
md5(serialize(array(
"CID" => $this->CID,
"sessid" => freetrix_sessid()))
)
)
);
if (in_array($this->mode, array("upload", "delete", "view")))
{
if (empty($this->CID))
$this->error = "BXU344";
else if (!check_freetrix_sessid())
$this->error = "BXU345";
else if (!CheckDirPath($this->path))
$this->error .= "BXU346";
else if ($this->getPost("packageIndex", $requestType))
{
$this->package = array(
"handler" => CBXVirtualIo::GetInstance()->GetFile($this->path.$this->getPost("packageIndex").".package"),
"id" => $this->getPost("packageIndex"),
"data" => array("filesCount" => intval($this->getPost("filesCount")), "files" => array())
);
if ($this->package["handler"]->IsExists())
$this->package["data"] = unserialize($this->package["handler"]->GetContents());
}
else if ($this->mode == "upload")
$this->error = "BXU344.1";
$this->uploading = array(
"handler" => CBXVirtualIo::GetInstance()->GetFile($this->path.".log"),
"data" => array());
if ($this->uploading["handler"]->IsExists())
$this->uploading["data"] = unserialize($this->uploading["handler"]->GetContents());
return true;
}
return false;
}
示例15: session_name
echo "success\n";
echo session_name() . "\n";
echo session_id() . "\n";
echo bitrix_sessid_get() . "\n";
}
} elseif (!check_bitrix_sessid()) {
echo "failure\n", GetMessage("CC_BCIH_ERROR_SOURCE_CHECK");
} elseif (!$USER->IsAuthorized()) {
echo "failure\n", GetMessage("CC_BCIH_ERROR_AUTHORIZE");
} elseif (!$bUSER_HAVE_ACCESS) {
echo "failure\n", GetMessage("CC_BCIH_PERMISSION_DENIED");
} elseif (!CModule::IncludeModule('highloadblock')) {
echo "failure\n", GetMessage("CC_BCIH_ERROR_MODULE");
} elseif ($_GET["mode"] == "init") {
if ($arParams["USE_TEMP_DIR"] === "Y") {
$DIR_NAME = CTempFile::GetDirectoryName(6, "1c_highloadblock");
} else {
//Cleanup previous import files
$directory = new \Bitrix\Main\IO\Directory($DIR_NAME);
if ($directory->isExists()) {
$directory->delete();
}
}
CheckDirPath($DIR_NAME);
if (!is_dir($DIR_NAME)) {
echo "failure\n", GetMessage("CC_BCIH_ERROR_INIT");
} else {
$_SESSION["BX_HL_IMPORT"] = array("zip" => $arParams["USE_ZIP"] && function_exists("zip_open"), "TEMP_DIR" => $arParams["USE_TEMP_DIR"] === "Y" ? $DIR_NAME : "", "NS" => array("XMLPOS" => "", "SESSID" => md5($_REQUEST["sessid"])));
echo "zip=" . ($_SESSION["BX_HL_IMPORT"]["zip"] ? "yes" : "no") . "\n";
echo "file_limit=" . $arParams["FILE_SIZE_LIMIT"];
}