本文整理汇总了PHP中CTempFile类的典型用法代码示例。如果您正苦于以下问题:PHP CTempFile类的具体用法?PHP CTempFile怎么用?PHP CTempFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CTempFile类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:Satariall,项目名称:izurit,代码行数:27,代码来源:order.php
示例2: getFileInfo
/**
* @return string
*/
public function getFileInfo()
{
$fileInfo = null;
if ($this->encoding === 'B' || $this->encoding === 'BASE64') {
$type = $this->type !== '' ? strtolower($this->type) : 'jpg';
if ($type === '' || !in_array($type, explode(',', \CFile::GetImageExtensions()), true)) {
$type = 'jpg';
}
$filePath = \CTempFile::GetFileName(uniqid('vcard_img') . '.' . $type);
CheckDirPath($filePath);
//Removing of line folding
$encodedData = preg_replace("/\\\\n/i", "\n", $this->value);
if (file_put_contents($filePath, base64_decode($encodedData)) !== false) {
$fileInfo = \CFile::MakeFileArray($filePath, "image/{$type}");
}
} elseif ($this->valueType === 'URI' && \CCrmUrlUtil::HasScheme($this->value) && \CCrmUrlUtil::IsSecureUrl($this->value)) {
$fileInfo = \CFile::MakeFileArray($this->value);
}
return is_array($fileInfo) && strlen(\CFile::CheckImageFile($fileInfo)) === 0 ? $fileInfo : null;
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:23,代码来源:vcardfile.php
示例3: processActionCommit
protected function processActionCommit()
{
if (!$this->checkPermission()) {
$this->sendJsonResponse(array('status' => self::STATUS_DENIED));
}
if (!isset($_FILES['file'])) {
$this->sendJsonResponse(array('status' => self::STATUS_DENIED, 'message' => 'Upload file'));
}
$downloadedFile = $_FILES['file'];
$webdav = $this->getWebdav();
if (empty($webdav->arParams['element_array']['ID'])) {
$this->sendJsonResponse(array('status' => self::STATUS_NOT_FOUND));
}
$filename = CTempFile::GetFileName(uniqid('_wd'));
$nameToSavedFile = $webdav->arParams['element_name'];
CheckDirPath($filename);
if (($downloadedFile['error'] = intval($downloadedFile['error'])) > 0) {
if ($downloadedFile['error'] < 3) {
$this->sendJsonResponse(array('status' => self::STATUS_ERROR, 'message' => "Upload error: {$downloadedFile['error']}"));
} else {
$this->sendJsonResponse(array('status' => self::STATUS_ERROR, 'message' => "Upload error: {$downloadedFile['error']}"));
}
}
if (!is_uploaded_file($downloadedFile['tmp_name'])) {
$this->sendJsonResponse(array('status' => self::STATUS_ERROR, 'message' => "Upload error"));
}
if (!move_uploaded_file($downloadedFile['tmp_name'], $filename)) {
$this->sendJsonResponse(array('status' => self::STATUS_ERROR, 'message' => "Bad move after upload"));
}
$options = array('new' => false, 'FILE_NAME' => $nameToSavedFile, 'ELEMENT_ID' => $webdav->arParams['element_array']['ID'], 'arUserGroups' => $webdav->USER['GROUPS'], 'TMP_FILE' => $filename);
$this->getDb()->startTransaction();
if (!$this->getWebDav()->put_commit($options)) {
$this->getDb()->rollback();
$this->sendJsonResponse(array('status' => self::STATUS_ERROR, 'message' => 'Error in commit.', 'description' => $webdav->LAST_ERROR));
}
$this->getDb()->commit();
$this->sendJsonResponse(array('status' => self::STATUS_SUCCESS));
}
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:38,代码来源:class.php
示例4: 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;
}
开发者ID:Satariall,项目名称:izurit,代码行数:23,代码来源:results.php
示例5: _absolute_path_recursive_delete
private static function _absolute_path_recursive_delete($path)
{
if (strlen($path) == 0 || $path == '/') {
return false;
}
$f = true;
if (is_file($path) || is_link($path)) {
if (@unlink($path)) {
return true;
}
return false;
} elseif (is_dir($path)) {
if ($handle = opendir($path)) {
while (($file = readdir($handle)) !== false) {
if ($file == "." || $file == "..") {
continue;
}
if (!CTempFile::_absolute_path_recursive_delete($path . "/" . $file)) {
$f = false;
}
}
closedir($handle);
}
if (!@rmdir($path)) {
return false;
}
return $f;
}
return false;
}
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:30,代码来源:file_temp.php
示例6: ResizeImageFile
function ResizeImageFile($sourceFile, &$destinationFile, $arSize, $resizeType = BX_RESIZE_IMAGE_PROPORTIONAL, $arWaterMark = array(), $jpgQuality = false, $arFilters = false)
{
$io = CBXVirtualIo::GetInstance();
if (!$io->FileExists($sourceFile)) {
return false;
}
$bNeedCreatePicture = false;
if ($resizeType != BX_RESIZE_IMAGE_EXACT && $resizeType != BX_RESIZE_IMAGE_PROPORTIONAL_ALT) {
$resizeType = BX_RESIZE_IMAGE_PROPORTIONAL;
}
if (!is_array($arSize)) {
$arSize = array();
}
if (!array_key_exists("width", $arSize) || intval($arSize["width"]) <= 0) {
$arSize["width"] = 0;
}
if (!array_key_exists("height", $arSize) || intval($arSize["height"]) <= 0) {
$arSize["height"] = 0;
}
$arSize["width"] = intval($arSize["width"]);
$arSize["height"] = intval($arSize["height"]);
$arSourceSize = array("x" => 0, "y" => 0, "width" => 0, "height" => 0);
$arDestinationSize = array("x" => 0, "y" => 0, "width" => 0, "height" => 0);
$arSourceFileSizeTmp = CFile::GetImageSize($sourceFile);
if (!in_array($arSourceFileSizeTmp[2], array(IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF, IMAGETYPE_BMP))) {
return false;
}
if (class_exists("imagick") && function_exists('memory_get_usage')) {
//When memory limit reached we'll try to use ImageMagic
$memoryNeeded = round(($arSourceFileSizeTmp[0] * $arSourceFileSizeTmp[1] * $arSourceFileSizeTmp['bits'] * ($arSourceFileSizeTmp['channels'] > 0 ? $arSourceFileSizeTmp['channels'] : 1) / 8 + pow(2, 16)) * 1.65);
$memoryLimit = CUtil::Unformat(ini_get('memory_limit'));
if (memory_get_usage() + $memoryNeeded > $memoryLimit) {
if ($arSize["width"] <= 0 || $arSize["height"] <= 0) {
$arSize["width"] = $arSourceFileSizeTmp[0];
$arSize["height"] = $arSourceFileSizeTmp[1];
}
CFile::ScaleImage($arSourceFileSizeTmp[0], $arSourceFileSizeTmp[1], $arSize, $resizeType, $bNeedCreatePicture, $arSourceSize, $arDestinationSize);
if ($bNeedCreatePicture) {
$new_image = CTempFile::GetFileName(bx_basename($sourceFile));
CheckDirPath($new_image);
$im = new Imagick();
try {
$im->setSize($arDestinationSize["width"], $arDestinationSize["height"]);
$im->readImage($io->GetPhysicalName($sourceFile));
$im->setImageFileName($new_image);
$im->thumbnailImage($arDestinationSize["width"], $arDestinationSize["height"], true);
$im->writeImage();
$im->destroy();
} catch (ImagickException $e) {
$new_image = "";
}
if ($new_image != "") {
$sourceFile = $new_image;
$arSourceFileSizeTmp = CFile::GetImageSize($io->GetPhysicalName($sourceFile));
}
}
}
}
if ($io->Copy($sourceFile, $destinationFile)) {
switch ($arSourceFileSizeTmp[2]) {
case IMAGETYPE_GIF:
$sourceImage = imagecreatefromgif($io->GetPhysicalName($sourceFile));
$bHasAlpha = true;
break;
case IMAGETYPE_PNG:
$sourceImage = imagecreatefrompng($io->GetPhysicalName($sourceFile));
$bHasAlpha = true;
break;
case IMAGETYPE_BMP:
$sourceImage = CFile::ImageCreateFromBMP($io->GetPhysicalName($sourceFile));
$bHasAlpha = false;
break;
default:
$sourceImage = imagecreatefromjpeg($io->GetPhysicalName($sourceFile));
$bHasAlpha = false;
break;
}
$sourceImageWidth = intval(imagesx($sourceImage));
$sourceImageHeight = intval(imagesy($sourceImage));
if ($sourceImageWidth > 0 && $sourceImageHeight > 0) {
if ($arSize["width"] <= 0 || $arSize["height"] <= 0) {
$arSize["width"] = $sourceImageWidth;
$arSize["height"] = $sourceImageHeight;
}
CFile::ScaleImage($sourceImageWidth, $sourceImageHeight, $arSize, $resizeType, $bNeedCreatePicture, $arSourceSize, $arDestinationSize);
if ($bNeedCreatePicture) {
if (CFile::IsGD2()) {
$picture = ImageCreateTrueColor($arDestinationSize["width"], $arDestinationSize["height"]);
if ($arSourceFileSizeTmp[2] == IMAGETYPE_PNG) {
$transparentcolor = imagecolorallocatealpha($picture, 0, 0, 0, 127);
imagefilledrectangle($picture, 0, 0, $arDestinationSize["width"], $arDestinationSize["height"], $transparentcolor);
imagealphablending($picture, false);
imagecopyresampled($picture, $sourceImage, 0, 0, $arSourceSize["x"], $arSourceSize["y"], $arDestinationSize["width"], $arDestinationSize["height"], $arSourceSize["width"], $arSourceSize["height"]);
imagealphablending($picture, true);
} elseif ($arSourceFileSizeTmp[2] == IMAGETYPE_GIF) {
imagepalettecopy($picture, $sourceImage);
//Save transparency for GIFs
$transparentcolor = imagecolortransparent($sourceImage);
if ($transparentcolor >= 0 && $transparentcolor < imagecolorstotal($sourceImage)) {
$RGB = imagecolorsforindex($sourceImage, $transparentcolor);
//.........这里部分代码省略.........
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:101,代码来源:file.php
示例7: EMailMessageAdd
function EMailMessageAdd($arMessageFields, $ACTION_VARS)
{
$arActionVars = explode("&", $ACTION_VARS);
$countAr = count($arActionVars);
for ($i = 0; $i < $countAr; $i++) {
$v = $arActionVars[$i];
if ($pos = strpos($v, "=")) {
${substr($v, 0, $pos)} = urldecode(substr($v, $pos + 1));
}
}
if (!CModule::IncludeModule("support")) {
return false;
}
if (strlen($W_SUPPORT_SITE_ID) > 0) {
$rs = CSite::GetByID($W_SUPPORT_SITE_ID);
if ($ar = $rs->Fetch()) {
$SITE_ID = $ar["LID"];
}
}
if (strlen($SITE_ID) <= 0) {
$SITE_ID = $arMessageFields["LID"];
}
$sourceMail = COption::GetOptionString("support", "SOURCE_MAIL");
$dbr = CTicketDictionary::GetBySID($sourceMail, "SR", $SITE_ID);
if (!($ar = $dbr->Fetch())) {
return false;
}
$TICKET_SOURCE_ID = $ar["ID"];
$ID = $arMessageFields["ID"];
$message_email = strlen($arMessageFields["FIELD_REPLY_TO"]) > 0 ? $arMessageFields["FIELD_REPLY_TO"] : $arMessageFields["FIELD_FROM"];
$message_email_addr = strtolower(CMailUtil::ExtractMailAddress($message_email));
$TID = 0;
$arSubjects = explode("\n", trim($W_SUPPORT_SUBJECT));
$countAr = count($arSubjects);
for ($i = 0; $i < $countAr; $i++) {
$arSubjects[$i] = Trim($arSubjects[$i]);
if (strlen($arSubjects[$i]) > 0) {
if (preg_match("/" . $arSubjects[$i] . "/" . BX_UTF_PCRE_MODIFIER, $arMessageFields["SUBJECT"], $regs)) {
$TID = IntVal($regs[1]);
break;
}
}
}
if ($TID > 0) {
$db_ticket = CTicket::GetByID($TID, $SITE_ID, "N", "N", "N");
if ($ar_ticket = $db_ticket->Fetch()) {
//check user email address limits
if ($W_SUPPORT_SEC == "domain" || $W_SUPPORT_SEC == "email") {
$bEMailOK = false;
if ($TICKET_SOURCE_ID == $ar_ticket["SOURCE_ID"]) {
$ticket_email = strtolower(CMailUtil::ExtractMailAddress($ar_ticket["OWNER_SID"]));
if ($W_SUPPORT_SEC == "domain") {
$ticket_email = substr($ticket_email, strpos($ticket_email, "@"));
}
if (strpos($message_email_addr, $ticket_email) !== false) {
$bEMailOK = true;
}
}
if (!$bEMailOK && $ar_ticket["OWNER_USER_ID"] > 0) {
$db_user = CUser::GetByID($ar_ticket["OWNER_USER_ID"]);
if ($arUser = $db_user->Fetch()) {
$ticket_email = strtolower(CMailUtil::ExtractMailAddress($arUser["EMAIL"]));
if ($check_type == "domain") {
$ticket_email = substr($ticket_email, strpos($ticket_email, "@"));
}
if (strpos($message_email_addr, $ticket_email) !== false) {
$bEMailOK = true;
}
}
}
if (!$bEMailOK) {
$TID = 0;
}
}
} else {
$TID = 0;
}
}
//when message subject is empty - generate it from message body
$title = trim($arMessageFields["SUBJECT"]);
if (strlen($title) <= 0) {
$title = trim($arMessageFields["BODY"]);
$title = preg_replace("/[\n\r\t ]+/s" . BX_UTF_PCRE_MODIFIER, " ", $title);
$title = substr($title, 0, 50);
}
$arFieldsTicket = array("CLOSE" => "N", "TITLE" => $title, "MESSAGE" => $arMessageFields["BODY"], "MESSAGE_AUTHOR_SID" => $message_email, "MESSAGE_SOURCE_SID" => "email", "MODIFIED_MODULE_NAME" => "mail", "EXTERNAL_ID" => $ID, "EXTERNAL_FIELD_1" => $arMessageFields["HEADER"]);
if ($W_SUPPORT_USER_FIND == "Y") {
$o = "LAST_LOGIN";
$b = "DESC";
$res = CUser::GetList($o, $b, array("ACTIVE" => "Y", "=EMAIL" => $message_email_addr));
if (($arr = $res->Fetch()) && strtolower(CMailUtil::ExtractMailAddress($arr["EMAIL"])) == $message_email_addr) {
$AUTHOR_USER_ID = $arr["ID"];
}
}
// process attach files
$arFILES = array();
$rsAttach = CMailAttachment::GetList(array(), array("MESSAGE_ID" => $ID));
while ($arAttach = $rsAttach->Fetch()) {
// save from db to hdd
$filename = CTempFile::GetFileName(md5(uniqid("")) . ".tmp");
//.........这里部分代码省略.........
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:101,代码来源:email.php
示例8: UnpackFileArchive
function UnpackFileArchive($strfile, $path_to)
{
global $APPLICATION;
$res = true;
$arcname = CTempFile::GetFileName(md5(uniqid(rand(), true)) . '.tar.gz');
CheckDirPath($arcname);
if (file_put_contents($arcname, $strfile) !== false) {
include_once dirname(__FILE__) . '/tar_gz.php';
$ob = new CArchiver($arcname);
CheckDirPath($_SERVER['DOCUMENT_ROOT'] . $path_to);
$res = $ob->extractFiles($_SERVER['DOCUMENT_ROOT'] . $path_to);
if (!$res && is_object($APPLICATION)) {
$arErrors = $ob->GetErrors();
if (count($arErrors)) {
$strError = "";
foreach ($arErrors as $error) {
$strError .= $error[1] . "<br>";
}
$e = new CApplicationException($strError);
$APPLICATION->ThrowException($e);
}
}
}
return $res;
}
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:25,代码来源:controller_member.php
示例9: 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)) {
开发者ID:spas-viktor,项目名称:books,代码行数:31,代码来源:smile_import.php
示例10: array
$arFilter["ID!"] = $ID;
}
$db_res = CIBlockSection::GetList(array(), $arFilter);
if ($db_res && ($res = $db_res->Fetch())) {
$arError = array("code" => "CODE_EXIST", "title" => GetMessage("P_ERROR_CODE_EXIST"));
}
}
$arFiles = array();
if (empty($arError) && !empty($_FILES["AVATAR"]) && !empty($_FILES["AVATAR"]["tmp_name"])) {
include_once $_SERVER["DOCUMENT_ROOT"] . "/" . BX_PERSONAL_ROOT . "/components/bitrix/photogallery.upload/functions.php";
$arRealFile = $_FILES["AVATAR"];
$arAlbumSights = array("DETAIL_PICTURE" => array("code" => "album", "notes" => "for_album", "width" => $arParams["GALLERY_AVATAR"]["WIDTH"], "height" => $arParams["GALLERY_AVATAR"]["HEIGHT"]), "PICTURE" => array("code" => "album_thumbs", "notes" => "for_album", "width" => $arParams["GALLERY_AVATAR_THUMBS"]["WIDTH"], "height" => $arParams["GALLERY_AVATAR_THUMBS"]["HEIGHT"]));
foreach ($arAlbumSights as $key => $Sight) {
$File = $arRealFile;
$File["name"] = "avatar_" . $Sight["code"] . $arRealFile["name"];
$File["tmp_name"] = $File["tmp_name"] = CTempFile::GetFileName() . $File["name"];
CFile::ResizeImageFile($arRealFile["tmp_name"], $File['tmp_name'], $Sight, BX_RESIZE_IMAGE_EXACT);
$File["MODULE_ID"] = "iblock";
$arFiles[$key] = $File;
}
}
if (empty($arError)) {
$arUserFields = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("IBLOCK_" . $arParams["IBLOCK_ID"] . "_SECTION", 0, LANGUAGE_ID);
if (empty($arUserFields) || empty($arUserFields["UF_DEFAULT"])) {
$db_res = CUserTypeEntity::GetList(array($by => $order), array("ENTITY_ID" => "IBLOCK_" . $arParams["IBLOCK_ID"] . "_SECTION", "FIELD_NAME" => "UF_DEFAULT"));
if (!$db_res || !($res = $db_res->GetNext())) {
$arFields = array("ENTITY_ID" => "IBLOCK_" . $arParams["IBLOCK_ID"] . "_SECTION", "FIELD_NAME" => "UF_DEFAULT", "USER_TYPE_ID" => "string", "MULTIPLE" => "N", "MANDATORY" => "N");
$arFieldName = array();
$rsLanguage = CLanguage::GetList($by, $order, array());
while ($arLanguage = $rsLanguage->Fetch()) {
if (LANGUAGE_ID == $arLanguage["LID"]) {
开发者ID:Satariall,项目名称:izurit,代码行数:31,代码来源:component.php
示例11: AddAttachment
function AddAttachment($arFields)
{
global $DB;
$strSql = "SELECT ATTACHMENTS FROM b_mail_message WHERE ID=" . IntVal($arFields["MESSAGE_ID"]);
$dbr = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if (!($dbr_arr = $dbr->Fetch())) {
return false;
}
$n = IntVal($dbr_arr["ATTACHMENTS"]) + 1;
if (strlen($arFields["FILE_NAME"]) <= 0) {
$arFields["FILE_NAME"] = $n . ".";
if (strpos($arFields["CONTENT_TYPE"], "message/") === 0) {
$arFields["FILE_NAME"] .= "msg";
} else {
$arFields["FILE_NAME"] .= "tmp";
}
}
if (is_set($arFields, "CONTENT_TYPE")) {
$arFields["CONTENT_TYPE"] = strtolower($arFields["CONTENT_TYPE"]);
}
if (strpos($arFields["CONTENT_TYPE"], "image/") === 0 && (!is_set($arFields, "IMAGE_WIDTH") || !is_set($arFields, "IMAGE_HEIGHT")) && is_set($arFields, "FILE_DATA")) {
$filename = CTempFile::GetFileName(md5(uniqid("")) . '.tmp');
CheckDirPath($filename);
if (file_put_contents($filename, $arFields["FILE_DATA"]) !== false) {
$img_arr = CFile::GetImageSize($filename);
$arFields["IMAGE_WIDTH"] = $img_arr ? $img_arr[0] : 0;
$arFields["IMAGE_HEIGHT"] = $img_arr ? $img_arr[1] : 0;
}
}
if (is_set($arFields, "FILE_DATA") && !is_set($arFields, "FILE_SIZE")) {
$arFields["FILE_SIZE"] = CUtil::BinStrlen($arFields["FILE_DATA"]);
}
if (!CMailUtil::IsSizeAllowed(strlen($DB->ForSQL($arFields["FILE_DATA"])) + 100)) {
return false;
}
$ID = $DB->Add("b_mail_msg_attachment", $arFields, array("FILE_DATA"));
if ($ID > 0) {
$strSql = "UPDATE b_mail_message SET ATTACHMENTS=" . $n . " WHERE ID=" . IntVal($arFields["MESSAGE_ID"]);
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
return $ID;
/*
$arFile = Array(
"name"=>$filename,
"size"=>strlen($part["BODY"]),
"type"=>$part["CONTENT-TYPE"],
"content"=>$part["BODY"],
"MODULE_ID"=>"mail"
);
$file_id = CFile::SaveFile($arFile, "mail");
*/
}
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:52,代码来源:mail.php
示例12: Export
function Export($documentId)
{
$work_dir = CTempFile::GetDirectoryName();
CheckDirPath($work_dir);
$file = "import";
$file_name = $work_dir . $file . ".xml";
$file_dir = $file . "_files/";
$arcname = $work_dir . $file . '.tar.gz';
if ($fp = fopen($file_name, "ab")) {
$documentService = $this->workflow->GetService("DocumentService");
$document = $documentService->GetDocument($documentId);
$obExport = new CIBlockCMLExport();
$step = array();
$PROPERTY_MAP = array();
$SECTION_MAP = array();
if ($obExport->Init($fp, $document["IBLOCK_ID"], $step, true, $work_dir, $file_dir)) {
$obExport->StartExport();
$obExport->StartExportMetadata();
$obExport->ExportProperties($PROPERTY_MAP);
$obExport->ExportSections($SECTION_MAP, time(), 0);
$obExport->EndExportMetadata();
$obExport->StartExportCatalog(true, true);
$obExport->ExportElements($PROPERTY_MAP, $SECTION_MAP, time(), 0, 0, array("SHOW_NEW" => "Y", "IBLOCK_ID" => $document["IBLOCK_ID"], "=ID" => $document["ID"]));
$obExport->EndExportCatalog();
$obExport->EndExport();
fclose($fp);
include_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . '/modules/main/classes/general/tar_gz.php';
$ob = new CArchiver($arcname);
$res = $ob->Add('"' . $file_name . '"', false, $work_dir);
if ($res) {
$res = $ob->Add('"' . $work_dir . $file_dir . '"', false, $work_dir);
}
if ($res) {
return $arcname;
} else {
return '';
}
} else {
return '';
}
} else {
return '';
}
}
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:44,代码来源:controllerremoteiblockactivity.php
示例13: array
if ($arParams["PERMISSION"] >= "W" && ($object == "group" || $object == "user" && $arResult["VARIABLES"]["user_id"] == $USER->GetID())) {
$arFiles = array();
if ($object == "user") {
$dbUser = CUser::GetByID($USER->GetID());
$arResult["USER"] = $dbUser->GetNext();
$arResult["USER"]["PERSONAL_PHOTO"] = intVal($arResult["USER"]["PERSONAL_PHOTO"]);
if ($arResult["USER"]["PERSONAL_PHOTO"] > 0) {
$arFile = CFile::MakeFileArray($arResult["USER"]["PERSONAL_PHOTO"]);
if (is_array($arFile)) {
$arFile["name"] = preg_replace("/[^a-z_.1-9]/is", "_", $arFile["name"]);
include_once $_SERVER["DOCUMENT_ROOT"] . "/" . BX_PERSONAL_ROOT . "/components/bitrix/photogallery.upload/functions.php";
$arAlbumSights = array("DETAIL_PICTURE" => array("code" => "album", "notes" => "for_album", "width" => $arParams["PHOTO"]["ALL"]["GALLERY_AVATAR_SIZE"], "height" => $arParams["PHOTO"]["ALL"]["GALLERY_AVATAR_SIZE"]), "PICTURE" => array("code" => "album_thumbs", "notes" => "for_album", "width" => $arParams["PHOTO"]["ALL"]["GALLERY_AVATAR_THUMBS_SIZE"], "height" => $arParams["PHOTO"]["ALL"]["GALLERY_AVATAR_THUMBS_SIZE"]));
foreach ($arAlbumSights as $key => $Sight) {
$File = $arFile;
$File["name"] = "avatar_" . $Sight["code"] . $arFile["name"];
$File["tmp_name"] = CTempFile::GetFileName($File["name"]);
CheckDirPath($File["tmp_name"]);
$res = CFile::ResizeImageFile(CBXVirtualIo::GetInstance()->GetLogicalName($arFile["tmp_name"]), $File["tmp_name"], $Sight, BX_RESIZE_IMAGE_PROPORTIONAL_ALT);
$File["MODULE_ID"] = "iblock";
$arFiles[$key] = $File;
}
if ($arFile["image"]) {
@imagedestroy($arFile["image"]);
}
}
}
}
$arUserFields = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("IBLOCK_" . $arParams["IBLOCK_ID"] . "_SECTION", 0, LANGUAGE_ID);
if (empty($arUserFields) || empty($arUserFields["UF_DEFAULT"])) {
$db_res = CUserTypeEntity::GetList(array($by => $order), array("ENTITY_ID" => "IBLOK_" . $arParams["IBLOCK_ID"] . "_SECTION", "FIELD_NAME" => "UF_DEFAULT"));
if (!$db_res || !($res = $db_res->GetNext())) {
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:31,代码来源:photogallery.php
示例14: 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"];
}
开发者ID:webgksupport,项目名称:alpina,代码行数:31,代码来源:component.php
示例15: ResizePicture
/**
* <p>Функция выполняет масштабирование файла.</p> <p><b>Примечание</b>: обрабатываются только файлы JPEG, GIF и PNG (зависит от используемой библиотеки GD). Файл указанный в параметре arFile будет перезаписан. <br></p>
*
*
*
*
* @param array $arFile Массив описывающий файл. Это может быть элемент массива $_FILES[имя]
* (или $HTTP_POST_FILES[имя]), а также результат функции <a
* href="http://dev.1c-bitrix.ru/api_help/main/reference/cfile/makefilearray.php">CFile::MakeFileArray</a>.
*
*
*
* @param array $arResize Массив параметров масштабирования. Содержит следующие ключи:
* <br><ul> <li>WIDTH - целое число. Размер картинки будет изменен таким
* образом, что ее ширина не будет превышать значения этого поля. <br>
* </li> <li>HEIGHT - целое число. Размер картинки будет изменен таким
* образом, что ее высота не будет превышать значения этого поля. </li>
* <li>METHOD - возможные значения: resample или пусто. Значение поля равное
* "resample" приведет к использованию функции масштабирования
* imagecopyresampled, а не imagecopyresized. Это более качественный метод, но требует
* больше серверных ресурсов. <br> </li> <li>COMPRESSION - целое от 0 до 100. Если
* значение больше 0, то для изображений jpeg оно будет использовано
* как параметр компрессии. 100 соответствует наилучшему качеству
* при большем размере файла. </li> </ul> Параметры METHOD и COMPRESSION
* применяются только если происходит изменение размера. Если
* картинка вписывается в ограничения WIDTH и HEIGHT, то никаких действий
* над файлом выполнено не будет. <br><br>
*
*
*
* @return array <p>Массив описывающий файл или строка с сообщением об ошибке.</p>
*
*
* <h4>Example</h4>
* <pre>
* <?<br>AddEventHandler("iblock", "OnBeforeIBlockElementAdd", Array("MyHandlers", "ResizeElementProperty"));<br>AddEventHandler("iblock", "OnBeforeIBlockElementUpdate", Array("MyHandlers", "ResizeElementProperty"));<br><br>class MyHandlers<br>{<br> function ResizeElementProperty(&$arFields)<br> {<br> global $APPLICATION;<br> //Код инфоблока свойство каторого нуждается в масштабировании<br> $IBLOCK_ID = 1;<br> //Идентификатор свойства<br> $PROPERTY_ID = 15;<br> //Наш инфоблок и значения свойства в наличии<br> if(<br> $arFields["IBLOCK_ID"] == $IBLOCK_ID<br> && is_array($arFields["PROPERTY_VALUES"])<br> && array_key_exists(15, $arFields["PROPERTY_VALUES"])<br> )<br> {<br> foreach($arFields["PROPERTY_VALUES"][$PROPERTY_ID] as $key => $arFile)<br> {<br> //Изменяем размеры картинки<br> $arNewFile = CIBlock::ResizePicture($arFile, array(<br> "WIDTH" => 100,<br> "HEIGHT" => 100,<br> "METHOD" => "resample",<br> ));<br> if(is_array($arNewFile))<br> $arFields["PROPERTY_VALUES"][$PROPERTY_ID][$key] = $arNewFile;<br> else<br> {<br> //Можно вернуть ошибку<br> $APPLICATION->throwException("Ошибка масштабирования изображения в свойстве \"Файлы\":".$arNewFile);<br> return false;<br> }<br> }<br> }<br> }<br>}<br>?>
* </pre>
*
*
*
* <h4>See Also</h4>
* <ul> <li><a href="http://dev.1c-bitrix.ru/api_help/main/reference/cfile/makefilearray.php">CFile::MakeFileArray</a></li>
* <li><a href="http://dev.1c-bitrix.ru/api_help/iblock/classes/ciblock/SetFields.php">CIBlock::SetFields</a></li> </ul><a
* name="examples"></a>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/iblock/classes/ciblock/ResizePicture.php
* @author Bitrix
*/
public static function ResizePicture($arFile, $arResize)
{
if (strlen($arFile["tmp_name"]) <= 0) {
return $arFile;
}
if (array_key_exists("error", $arFile) && $arFile["error"] !== 0) {
return GetMessage("IBLOCK_BAD_FILE_ERROR");
}
$file = $arFile["tmp_name"];
if (!file_exists($file) && !is_file($file)) {
return GetMessage("IBLOCK_BAD_FILE_NOT_FOUND");
}
$width = intval($arResize["WIDTH"]);
$height = intval($arResize["HEIGHT"]);
if ($width <= 0 && $height <= 0) {
return $arFile;
}
$orig = CFile::GetImageSize($file, true);
if (!is_array($orig)) {
return GetMessage("IBLOCK_BAD_FILE_NOT_PICTURE");
}
if ($width > 0 && $orig[0] > $width || $height > 0 && $orig[1] > $height) {
if ($arFile["COPY_FILE"] == "Y") {
$new_file = CTempFile::GetFileName(basename($file));
CheckDirPath($new_file);
$arFile["copy"] = true;
if (copy($file, $new_file)) {
$file = $new_file;
} else {
return GetMessage("IBLOCK_BAD_FILE_NOT_FOUND");
}
}
$width_orig = $orig[0];
$height_orig = $orig[1];
if ($width <= 0) {
$width = $width_orig;
}
if ($height <= 0) {
$height = $height_orig;
}
$height_new = $height_orig;
if ($width_orig > $width) {
$height_new = $width / $width_orig * $height_orig;
}
if ($height_new > $height) {
$width = $height / $height_orig * $width_orig;
} else {
$height = $height_new;
}
$image_type = $orig[2];
//.........这里部分代码省略.........
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:101,代码来源:iblock.php
示例16: 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";
$a
|
请发表评论