本文整理汇总了PHP中CFile::ResizeImageFile方法的典型用法代码示例。如果您正苦于以下问题:PHP CFile::ResizeImageFile方法的具体用法?PHP CFile::ResizeImageFile怎么用?PHP CFile::ResizeImageFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFile
的用法示例。
在下文中一共展示了CFile::ResizeImageFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetItems
//.........这里部分代码省略.........
},
date : '<?php
echo $Dir["DATE"];
?>
',
timestamp : '<?php
echo $Dir["TIMESTAMP"];
?>
',
size : 0
};
<?php
}
if ($Params['getFiles']) {
$ind = -1;
foreach ($arFiles as $File) {
$name = addslashes(htmlspecialcharsex($File["NAME"]));
$path_i = addslashes(htmlspecialcharsex($File["ABS_PATH"]));
$path_i = str_replace("//", "/", $path_i);
$arPath_i = array($site, $path_i);
if (!$USER->CanDoFileOperation('fm_view_file', $arPath_i)) {
continue;
}
$ind++;
$perm_del = $USER->CanDoFileOperation('fm_delete_file', $arPath_i) ? 'true' : 'false';
$perm_ren = $USER->CanDoFileOperation('fm_rename_file', $arPath_i) ? 'true' : 'false';
$imageAddProps = '';
if ($genTmb) {
$ext = strtolower(GetFileExtension($name));
if (in_array($ext, array('gif', 'jpg', 'jpeg', 'png', 'jpe', 'bmp'))) {
$tmbPath = BX_PERSONAL_ROOT . "/tmp/fd_tmb" . $path_i;
$destinationFile = $rootPath . $tmbPath;
if (!file_exists($destinationFile)) {
$sourceFile = $File['PATH'];
if (CFile::ResizeImageFile($sourceFile, $destinationFile, array('width' => 140, 'height' => 110))) {
$imageAddProps = ",\n" . 'tmb_src : \'' . CUtil::JSEscape($tmbPath) . '\'';
}
} else {
$imageAddProps = ",\n" . 'tmb_src : \'' . CUtil::JSEscape($tmbPath) . '\'';
}
}
}
?>
arFDFiles['<?php
echo $path_js;
?>
'][<?php
echo $ind;
?>
] =
{
name : '<?php
echo $name;
?>
',
path : '<?php
echo $path_i;
?>
',
permission : {del : <?php
echo $perm_del;
?>
, ren : <?php
echo $perm_ren;
?>
},
date : '<?php
echo $File["DATE"];
?>
',
timestamp : '<?php
echo $File["TIMESTAMP"];
?>
',
size : '<?php
echo $File["SIZE"];
?>
'<?php
echo $imageAddProps;
?>
};
<?php
}
}
$arPath = array($site, $path);
?>
arFDPermission['<?php
echo $path_js;
?>
'] = {
new_folder : <?php
echo $USER->CanDoFileOperation('fm_create_new_folder', $arPath) ? 'true' : 'false';
?>
,
upload : <?php
echo $USER->CanDoFileOperation('fm_upload_file', $arPath) ? 'true' : 'false';
?>
};
<?php
}
示例2: ResizePicture
function ResizePicture($file, $resize, $primaryField, $secondaryField = "")
{
static $errorFile = array("tmp_name" => "", "del" => "Y");
$external_id = md5($file);
if (strlen($file) <= 0) {
return $errorFile;
}
if (file_exists($this->files_dir . $file) && is_file($this->files_dir . $file)) {
$file = $this->files_dir . $file;
} elseif (file_exists($file) && is_file($file)) {
} elseif (($fileId = $this->CheckFileByName($external_id, array($primaryField))) > 0) {
return CFile::MakeFileArray($fileId);
} elseif ($secondaryField && ($fileId = $this->CheckFileByName($external_id, array($secondaryField))) > 0) {
$storedFile = CFile::MakeFileArray($fileId);
if ($storedFile) {
$tempFile = CTempFile::GetFileName(bx_basename($storedFile["tmp_name"]));
CheckDirPath($tempFile);
if (copy($storedFile["tmp_name"], $tempFile)) {
$storedFile["tmp_name"] = $tempFile;
return $storedFile;
} else {
return $errorFile;
}
} else {
return $errorFile;
}
} else {
return $errorFile;
}
if (!is_array($resize) || !preg_match("#(\\.)([^./\\\\]+?)\$#", $file)) {
$arFile = CFile::MakeFileArray($file, false, false, $external_id);
if ($arFile && $this->iblock_resize) {
$arFile["COPY_FILE"] = "Y";
}
return $arFile;
}
$i = 1;
while (file_exists(preg_replace("#(\\.)([^./\\\\]+?)\$#", ".resize" . $i . ".\\2", $file))) {
$i++;
}
$new_file = preg_replace("#(\\.)([^./\\\\]+?)\$#", ".resize" . $i . ".\\2", $file);
if (!CFile::ResizeImageFile($file, $new_file, array("width" => $resize[0], "height" => $resize[1]))) {
return CFile::MakeFileArray($file, false, false, $external_id);
}
$this->arTempFiles[] = $new_file;
return CFile::MakeFileArray($new_file, false, false, $external_id);
}
示例3: handleFile
function handleFile($hash, $photo, &$package, &$upload, &$error)
{
if (!CModule::IncludeModule("iblock")) {
return false;
}
global $USER;
$arParams = $this->arParams;
if (!($upload["SECTION_ID"] > 0)) {
if ($this->post["photo_album_id"] > 0) {
$upload["SECTION_ID"] = $this->post["photo_album_id"];
} else {
$upload["NEW_SECTION_ID"] = $upload["SECTION_ID"] = self::createAlbum($this->arParams, $this->arResult, $this->post["new_album_name"]);
}
$this->arParams["SECTION_ID"] = $upload["SECTION_ID"];
$upload["redirectUrl"] = CComponentEngine::MakePathFromTemplate($this->arParams["~SECTION_URL"], array("USER_ALIAS" => $this->arParams["USER_ALIAS"], "SECTION_ID" => $this->arParams["SECTION_ID"]));
self::adjustIBlock($this->arParams);
}
if (!($upload["SECTION_ID"] > 0)) {
$error = "Album is not created or does not exist.";
return false;
}
$arParams["bxu"]->checkCanvases($hash, $photo, $arParams['converters'], $this->arWatermark);
// Props
$_REQUEST["Public"] = $_REQUEST["Public"] == "N" ? "N" : "Y";
$Prop = array("REAL_PICTURE" => array("n0" => $photo["files"]["default"]), "PUBLIC_ELEMENT" => array("n0" => $_REQUEST["Public"]), "APPROVE_ELEMENT" => array("n0" => ($arParams["ABS_PERMISSION"] >= "U" || $arParams["APPROVE_BY_DEFAULT"] == "Y") && $_REQUEST["Public"] == "Y" ? "Y" : "X"));
foreach ($arParams['converters'] as $val) {
if ($val['code'] != "default" && $val['code'] != "thumbnail") {
$Prop[strtoupper($val['code'])] = array("n0" => $photo["files"][$val['code']]);
}
}
// Real photo
$arFields = array("ACTIVE" => $arParams["MODERATION"] == "Y" && $arParams["ABS_PERMISSION"] < "U" ? "N" : "Y", "MODIFIED_BY" => $USER->GetID(), "IBLOCK_SECTION" => $upload['SECTION_ID'], "IBLOCK_ID" => $arParams["IBLOCK_ID"], "NAME" => $photo['name'], "CODE" => $photo['name'], "TAGS" => $photo['tags'], "DETAIL_TEXT" => $photo['description'], "DETAIL_TEXT_TYPE" => "text", "PREVIEW_PICTURE" => $photo["files"]["thumbnail"], "PREVIEW_TEXT" => $photo['description'], "PREVIEW_TEXT_TYPE" => "text", "PROPERTY_VALUES" => $Prop);
$bs = new CIBlockElement();
$ID = $bs->Add($arFields);
if ($ID <= 0) {
$error = $bs->LAST_ERROR;
return false;
}
$arFields['ID'] = $ID;
$_SESSION['arUploadedPhotos'][] = $ID;
CIBlockElement::RecalcSections($ID);
$arParams['SECTION_ID'] = $upload['SECTION_ID'];
$arResult = $this->arResult;
foreach (GetModuleEvents("photogallery", "OnAfterUpload", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array(&$arFields, $arParams, $arResult));
}
// Add thumbnail only for new album
if ($upload["NEW_SECTION_ID"] > 0 && !array_key_exists('NEW_SECTION_PICTURE', $upload)) {
$File = $photo["files"]["default"];
// Big picture
$File['~tmp_name'] = $File['tmp_name'];
$File['tmp_name'] .= "_album_cover.tmp";
if (CFile::ResizeImageFile($File['tmp_name'], $File['tmp_name_1'], array('width' => $arParams["ALBUM_PHOTO_THUMBS"]["SIZE"], 'height' => $arParams["ALBUM_PHOTO_THUMBS"]["SIZE"]), BX_RESIZE_IMAGE_PROPORTIONAL)) {
$bs = new CIBlockSection();
if ($bs->Update($upload["SECTION_ID"], array("PICTURE" => $File), false, false)) {
$upload['NEW_SECTION_PICTURE'] = true;
}
}
}
return $ID;
}
示例4: ResizeImageFileCheck
/**
* @param CCloudStorageBucket $obBucket
* @param string $path
* @return bool
*/
public static function ResizeImageFileCheck($obBucket, $path)
{
global $DB;
$path = preg_replace("/^https?:/i", "", $path);
$q = $DB->Query("\n\t\t\tselect\n\t\t\t\tID\n\t\t\t\t,ERROR_CODE\n\t\t\t\t,TO_PATH\n\t\t\t\t,FROM_PATH\n\t\t\t\t,PARAMS\n\t\t\t\t," . $DB->DateToCharFunction("TIMESTAMP_X", "FULL") . " TIMESTAMP_X\n\t\t\tfrom b_clouds_file_resize\n\t\t\twhere TO_PATH = '" . $DB->ForSql($path) . "'\n\t\t");
$task = $q->Fetch();
if (!$task) {
return false;
}
if ($task["ERROR_CODE"] !== "0") {
if (MakeTimeStamp($task["TIMESTAMP_X"]) + 300 > time() + CTimeZone::GetOffset()) {
return false;
}
}
$tmpFile = CFile::MakeFileArray($task["FROM_PATH"]);
if (!is_array($tmpFile) || !file_exists($tmpFile["tmp_name"])) {
$DB->Query("\n\t\t\t\tUPDATE b_clouds_file_resize\n\t\t\t\tSET ERROR_CODE = '1'\n\t\t\t\tWHERE ID = " . $task["ID"] . "\n\t\t\t");
return false;
}
$arResizeParams = unserialize($task["PARAMS"]);
if (!is_array($arResizeParams)) {
$DB->Query("\n\t\t\t\tUPDATE b_clouds_file_resize\n\t\t\t\tSET ERROR_CODE = '2'\n\t\t\t\tWHERE ID = " . $task["ID"] . "\n\t\t\t");
return false;
}
$arSize = $arResizeParams[0];
$resizeType = $arResizeParams[1];
$arWaterMark = $arResizeParams[2];
$jpgQuality = $arResizeParams[3];
$arFilters = $arResizeParams[4];
$to_path = CFile::GetTempName('', bx_basename($task["TO_PATH"]));
if (!CFile::ResizeImageFile($tmpFile["tmp_name"], $to_path, $arSize, $resizeType, $arWaterMark, $jpgQuality, $arFilters)) {
$DB->Query("\n\t\t\t\tUPDATE b_clouds_file_resize\n\t\t\t\tSET ERROR_CODE = '3'\n\t\t\t\tWHERE ID = " . $task["ID"] . "\n\t\t\t");
return false;
}
$fileToStore = CFile::MakeFileArray($to_path);
$baseURL = preg_replace("/^https?:/i", "", $obBucket->GetFileSRC("/"));
$pathToStore = substr($task["TO_PATH"], strlen($baseURL) - 1);
if (!$obBucket->SaveFile(urldecode($pathToStore), $fileToStore)) {
$DB->Query("\n\t\t\t\tUPDATE b_clouds_file_resize\n\t\t\t\tSET ERROR_CODE = '4'\n\t\t\t\tWHERE ID = " . $task["ID"] . "\n\t\t\t");
return false;
}
$DB->Query("\n\t\t\tUPDATE b_clouds_file_resize\n\t\t\tSET ERROR_CODE = '0'\n\t\t\tWHERE ID = " . $task["ID"] . "\n\t\t");
return true;
}
示例5: intVal
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())) {
$arFields = array("ENTITY_ID" => "IBLOCK_" . $arParams["IBLOCK_ID"] . "_SECTION", "FIELD_NAME" => "UF_DEFAULT", "USER_TYPE_ID" => "string", "MULTIPLE" => "N", "MANDATORY" => "N");
$arFieldName = array();
示例6: array
}
$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"]) {
$arFieldName[$arLanguage["LID"]] = GetMessage("IBLOCK_DEFAULT");
示例7: ResizePicture
function ResizePicture($file, $resize)
{
if(strlen($file) <= 0)
return array("tmp_name"=>"", "del"=>"Y");
if(file_exists($this->files_dir.$file) && is_file($this->files_dir.$file))
$file = $this->files_dir.$file;
elseif(file_exists($file) && is_file($file))
;
else
return array("tmp_name"=>"", "del"=>"Y");
if(!is_array($resize) || !preg_match("#(\\.)([^./\\\\]+?)$#", $file))
{
$arFile = CFile::MakeFileArray($file);
if($arFile && $this->iblock_resize)
$arFile["COPY_FILE"] = "Y";
return $arFile;
}
$i = 1;
while(file_exists(preg_replace("#(\\.)([^./\\\\]+?)$#", ".resize".$i.".\\2", $file)))
$i++;
$new_file = preg_replace("#(\\.)([^./\\\\]+?)$#", ".resize".$i.".\\2", $file);
if (!CFile::ResizeImageFile($file, $new_file, array("width"=>$resize[0], "height"=>$resize[1])))
return CFile::MakeFileArray($file);
$this->arTempFiles[] = $new_file;
return CFile::MakeFileArray($new_file);
}
示例8: updateAvatar
/**
* При загрузке аватара уменьшаем его размер до 150х150px
*/
public static function updateAvatar($USER_ID)
{
$imageMaxWidth = 216;
// Максимальная ширина уменьшенной картинки
$imageMaxHeight = 216;
// Максимальная высота уменьшенной картинки
$rsUser = \CUser::GetByID($USER_ID);
$arUser = $rsUser->Fetch();
if (intval($arUser["PERSONAL_PHOTO"]) > 0) {
$arFile = \CFile::GetFileArray($arUser["PERSONAL_PHOTO"]);
// проверяем, что файл является картинкой
if (!\CFile::IsImage($arFile["FILE_NAME"])) {
echo "не является картинкой";
continue;
}
// Если размер больше допустимого
if ($arFile["WIDTH"] > $imageMaxWidth || $arFile["HEIGHT"] > $imageMaxHeight) {
// Временная картинка
$tmpFilePath = $_SERVER['DOCUMENT_ROOT'] . "/upload/tmp/" . $arFile["FILE_NAME"];
// Уменьшаем картинку
$resizeRez = \CFile::ResizeImageFile($source = $_SERVER['DOCUMENT_ROOT'] . $arFile["SRC"], $dest = $tmpFilePath, array('width' => $imageMaxWidth, 'height' => $imageMaxHeight), $resizeType = BX_RESIZE_IMAGE_EXACT, $waterMark = array(), $jpgQuality = 95);
// Записываем изменение в свойство
if ($resizeRez && $tmpFilePath) {
$arNewFile = \CFile::MakeFileArray($tmpFilePath);
$arNewFile['del'] = "Y";
$arNewFile['old_file'] = $arUser['PERSONAL_PHOTO'];
$arNewFile["MODULE_ID"] = "main";
$fields['PERSONAL_PHOTO'] = $arNewFile;
$user = new \CUser();
$user->Update($arUser["ID"], $fields);
$rsUser = \CUser::GetByID($USER_ID);
$arUser = $rsUser->Fetch();
// Удалим временный файл
unlink($tmpFilePath);
}
}
}
return $arUser;
}
示例9: resizePic
public static function resizePic($id, $url)
{
$socialChannel = "vk";
$file_name = $id . ".jpg";
$dir = self::$img_dir;
$file_path = $dir . $socialChannel . "_" . $file_name;
$file_path_crop = $dir . $socialChannel . "_288x288_" . $file_name;
file_put_contents($_SERVER["DOCUMENT_ROOT"] . $file_path, file_get_contents($url));
if (!file_exists($_SERVER["DOCUMENT_ROOT"] . $file_path_crop)) {
$resizeRez = CFile::ResizeImageFile($_SERVER["DOCUMENT_ROOT"] . $file_path, $dest = $_SERVER["DOCUMENT_ROOT"] . $file_path_crop, array('width' => 288, 'height' => 288), $resizeType = BX_RESIZE_IMAGE_EXACT, $waterMark = array(), $jpgQuality = 100);
}
unlink($_SERVER["DOCUMENT_ROOT"] . $file_path);
return $file_path_crop;
}
示例10: ResizeImageFileCheck
function ResizeImageFileCheck($obBucket, $path)
{
global $DB, $APPLICATION;
$path = preg_replace("/^https?:/i", "", $path);
$q = $DB->Query("
select
ID
,ERROR_CODE
,TO_PATH
,FROM_PATH
,PARAMS
,".$DB->DateToCharFunction("TIMESTAMP_X", "FULL")." TIMESTAMP_X
from b_clouds_file_resize
where TO_PATH = '".$DB->ForSql($path)."'
");
$task = $q->Fetch();
if (!$task)
return false;
if ($task["ERROR_CODE"] !== "0")
{
if ((MakeTimeStamp($resize["TIMESTAMP_X"]) + 300/*5min*/) > (time() + CTimeZone::GetOffset()))
return false;
}
$tmpFile = CFile::MakeFileArray($task["FROM_PATH"]);
if (!is_array($tmpFile) || !file_exists($tmpFile["tmp_name"]))
{
$DB->Query("
UPDATE b_clouds_file_resize
SET ERROR_CODE = '1'
WHERE ID = ".$task["ID"]."
");
return false;
}
$arResizeParams = unserialize($task["PARAMS"]);
if (!is_array($arResizeParams))
{
$DB->Query("
UPDATE b_clouds_file_resize
SET ERROR_CODE = '2'
WHERE ID = ".$task["ID"]."
");
return false;
}
$arSize = $arResizeParams[0];
$resizeType = $arResizeParams[1];
$arWaterMark = $arResizeParams[2];
$jpgQuality = $arResizeParams[3];
$arFilters = $arResizeParams[4];
$to_path = CFile::GetTempName('', bx_basename($task["TO_PATH"]));
if (!CFile::ResizeImageFile($tmpFile["tmp_name"], $to_path, $arSize, $resizeType, $arWaterMark, $jpgQuality, $arFilters))
{
$DB->Query("
UPDATE b_clouds_file_resize
SET ERROR_CODE = '3'
WHERE ID = ".$task["ID"]."
");
return false;
}
$fileToStore = CFile::MakeFileArray($to_path);
$baseURL = preg_replace("/^https?:/i", "", $obBucket->GetFileSRC("/"));
$pathToStore = substr($task["TO_PATH"], strlen($baseURL)-1);
if (!$obBucket->SaveFile($pathToStore, $fileToStore))
{
$DB->Query("
UPDATE b_clouds_file_resize
SET ERROR_CODE = '4'
WHERE ID = ".$task["ID"]."
");
return false;
}
$DB->Query("
UPDATE b_clouds_file_resize
SET ERROR_CODE = '0'
WHERE ID = ".$task["ID"]."
");
return true;
}
示例11: foreach
if (!file_exists($photoInfo['ORIG']['0']) or 'Y' == $_GET['clear_cache']) {
foreach (array('ORIG', 'BIG', 'MED', 'SML') as $photoSize) {
@unlink($photoInfo[$photoSize]['0']);
}
$from = fopen($sourcePhotoPath, 'rb', false);
$to = fopen($photoInfo['ORIG']['0'], 'wb', false);
$bytes = stream_copy_to_stream($from, $to);
if (@file_exists($photoInfo['ORIG']['0']) && 10 > @filesize($photoInfo['ORIG']['0']) or $bytes != @filesize($photoInfo['ORIG']['0'])) {
unset($arVehicles[$i]['PHOTO'][$c]);
foreach (array('ORIG', 'BIG', 'MED', 'SML') as $photoSize) {
@unlink($photoInfo[$photoSize]['0']);
}
} else {
@chmod($photoInfo['ORIG']['0'], 0666);
foreach (array('BIG', 'MED', 'SML') as $o => $photoSize) {
CFile::ResizeImageFile($photoInfo['ORIG']['0'], $photoInfo[$photoSize]['0'], ${'arSize' . ($o + 1)}, BX_RESIZE_IMAGE_PROPORTIONAL, array(), 80, false);
@chmod($photoInfo[$photoSize]['0'], 0666);
}
}
fclose($from);
fclose($to);
}
}
}
// Марка и модель
$arVehicles[$i]['MARK']['ID'] = $vehicle['#']['mark']['0']['@']['mark_id'];
$arVehicles[$i]['MARK']['NAME'] = $vehicle['#']['mark']['0']['#'];
$arVehicles[$i]['MODEL']['ID'] = $vehicle['#']['model']['0']['@']['model_id'];
$arVehicles[$i]['MODEL']['NAME'] = $vehicle['#']['model']['0']['#'];
// год выпуска
$arVehicles[$i]['YEAR'] = $vehicle['#']['year']['0']['#'];
示例12: ResizeImageFileCheck
/**
* @param CCloudStorageBucket $obBucket
* @param string $path
* @return bool
*/
function ResizeImageFileCheck($obBucket, $path)
{
global $DB;
$path = preg_replace("/^https?:/i", "", $path);
$q = $DB->Query("
select
ID
,ERROR_CODE
,TO_PATH
,FROM_PATH
,PARAMS
,".$DB->DateToCharFunction("TIMESTAMP_X", "FULL")." TIMESTAMP_X
from b_clouds_file_resize
where TO_PATH = '".$DB->ForSql($path)."'
");
$task = $q->Fetch();
if (!$task)
return false;
//File in the Sky with Diamonds
if ($task["ERROR_CODE"] == 9)
{
return true;
}
//Fatal error
if ($task["ERROR_CODE"] >= 20)
{
return false;
}
//Recoverable error
if ($task["ERROR_CODE"] >= 10 && $task["ERROR_CODE"] < 20)
{
if ((MakeTimeStamp($task["TIMESTAMP_X"]) + 300/*5min*/) > (time() + CTimeZone::GetOffset()))
return false;
}
$DB->Query("
UPDATE b_clouds_file_resize
SET ERROR_CODE = '11'
WHERE ID = ".$task["ID"]."
");
$tmpFile = CFile::MakeFileArray($task["FROM_PATH"]);
if (!is_array($tmpFile) || !file_exists($tmpFile["tmp_name"]))
{
$DB->Query("
UPDATE b_clouds_file_resize
SET ERROR_CODE = '22'
WHERE ID = ".$task["ID"]."
");
return false;
}
$arResizeParams = unserialize($task["PARAMS"]);
if (!is_array($arResizeParams))
{
$DB->Query("
UPDATE b_clouds_file_resize
SET ERROR_CODE = '23'
WHERE ID = ".$task["ID"]."
");
return false;
}
$DB->Query("
UPDATE b_clouds_file_resize
SET ERROR_CODE = '14'
WHERE ID = ".$task["ID"]."
");
$arSize = $arResizeParams[0];
$resizeType = $arResizeParams[1];
$arWaterMark = $arResizeParams[2];
$jpgQuality = $arResizeParams[3];
$arFilters = $arResizeParams[4];
$to_path = CFile::GetTempName('', bx_basename($task["TO_PATH"]));
if (!CFile::ResizeImageFile($tmpFile["tmp_name"], $to_path, $arSize, $resizeType, $arWaterMark, $jpgQuality, $arFilters))
{
$DB->Query("
UPDATE b_clouds_file_resize
SET ERROR_CODE = '25'
WHERE ID = ".$task["ID"]."
");
return false;
}
$DB->Query("
UPDATE b_clouds_file_resize
SET ERROR_CODE = '16'
WHERE ID = ".$task["ID"]."
");
//.........这里部分代码省略.........
示例13: foreach
foreach ($pictures as $title => $options) {
if (COption::GetOptionString('imageimport', sprintf('%s_%s', $options['type'], $title), 'N') == 'Y') {
$picture_sizes = array('width' => 0, 'height' => 0);
switch ($options['sizes']) {
case 'iblock':
$picture_sizes = array('width' => $iblockFields[$title]['DEFAULT_VALUE']['WIDTH'], 'height' => $iblockFields[$title]['DEFAULT_VALUE']['HEIGHT']);
break;
case 'option':
$picture_sizes = array('width' => $options['width'], 'height' => $options['height']);
break;
}
if (!empty($picture_sizes['width']) or !empty($picture_sizes['height'])) {
do {
$picture_source = sprintf('%s/_%s_%s_%s', $file_info['dirname'], $title, uniqid(), $file_name);
} while (file_exists($picture_source));
CFile::ResizeImageFile($file_path, $picture_source, $picture_sizes);
$unlink_queue[] = $picture_source;
} else {
$picture_source = $file_path;
}
$picture_array = CFile::MakeFileArray($picture_source);
switch ($options['type']) {
case 'field':
$arFields[$title] = $picture_array;
break;
case 'property':
$arFields['PROPERTY_VALUES'][$options['id']] = $picture_array;
break;
}
}
}
示例14: createCanvas
protected static function createCanvas($source, $dest, $canvasParams = array(), $watermarkParams = array())
{
$watermark = array_key_exists("watermark", $source) ? array() : $watermarkParams;
if (\CFile::ResizeImageFile($source["tmp_name"], $dest["tmp_name"], $canvasParams, BX_RESIZE_IMAGE_PROPORTIONAL, $watermark, $canvasParams["quality"], array())) {
$dest = array_merge($source, $dest);
if (array_key_exists("watermark", $source) || !empty($watermarkParams)) {
$dest["watermark"] = true;
}
} else {
$dest["error"] = 348;
}
return $dest;
}
示例15: simpleUploadHandler
function simpleUploadHandler($arParams, $arResult = array())
{
global $APPLICATION;
$APPLICATION->RestartBuffer();
$sTmpPath = CImageUploader::SetTmpPath($_REQUEST["PackageGuid"], $arParams["PATH_TO_TMP"]);
$savedData = CImageUploader::GetSavedData();
if ($savedData['SECTION_ID']) {
unset($savedData['SECTION_ID']);
CImageUploader::SetSavedData($savedData);
}
onBeforeUpload(array('pathToTmp' => $arParams["PATH_TO_TMP"], 'arParams' => $arParams, "~arResult" => $arResult, 'sessid' => bitrix_sessid(), 'packageFields' => array('photo_album_id' => $_POST['photo_album_id'], 'new_album_name' => $_POST['new_album_name'], 'photo_resize_size' => intVal($_POST['photo_resize_size']))));
$files = $_FILES['photos'];
$file_count = 0;
if (!empty($files)) {
if (!is_array($files['name']) && is_string($files['name'])) {
$files = array('name' => array($files['name']), 'type' => array($files['type']), 'tmp_name' => array($files['tmp_name']), 'error' => array($files['error']), 'size' => array($files['size']));
}
$file_count = count($files['name']);
}
if ($arParams['WATERMARK_RULES'] == 'ALL') {
$arWatermark = array('type' => strtolower($arParams['WATERMARK_TYPE']), 'position' => $arParams['WATERMARK_POSITION']);
if ($arParams['WATERMARK_TYPE'] == 'TEXT') {
$arWatermark['coefficient'] = $arParams['WATERMARK_SIZE'];
$arWatermark['text'] = trim($arParams['WATERMARK_TEXT']);
$arWatermark['font'] = trim($arParams['PATH_TO_FONT']);
$arWatermark['color'] = trim($arParams['WATERMARK_COLOR']);
$arWatermark['use_copyright'] = "N";
} else {
$arWatermark['file'] = $arParams['WATERMARK_FILE'];
$arWatermark['alpha_level'] = $arParams['WATERMARK_TRANSPARENCY'];
$arWatermark['size'] = 'real';
$arWatermark['fill'] = $arParams['WATERMARK_FILE_ORDER'] == 'usual' ? 'exact' : $arParams['WATERMARK_FILE_ORDER'];
}
} elseif ($_POST['photo_watermark_use'] == 'Y') {
$arWatermark = array('type' => $_POST['photo_watermark_type'], 'text' => $_POST['photo_watermark_text'], 'font' => $arParams['PATH_TO_FONT'], 'position' => $_POST['photo_watermark_position'], 'color' => $_POST['photo_watermark_color'], 'size' => $_POST['photo_watermark_size'], 'fill' => 'resize', 'file' => $_SERVER["DOCUMENT_ROOT"] . $_POST['photo_watermark_path'], 'alpha_level' => $_POST['photo_watermark_opacity'], 'use_copyright' => $_POST["photo_watermark_copyright"] == "Y" ? "Y" : "N");
} else {
$arWatermark = array();
}
$arIds = array();
for ($i = 0; $i < $file_count; $i++) {
$Info = array('name' => $files['name'][$i], 'filename' => $files['name'][$i], 'description' => '', 'tags' => '');
$arFiles = array();
$name_i = $files['name'][$i];
$type_i = $files['type'][$i];
$tmp_name_i = $files['tmp_name'][$i];
$error_i = $files['error'][$i];
$size_i = $files['size'][$i];
if ($size_i > 0 && $arParams["UPLOAD_MAX_FILE_SIZE"] > 0 && $size_i > $arParams["UPLOAD_MAX_FILE_SIZE"]) {
CImageUploader::SaveError(array(array("file" => $name_i, "id" => "BXPH_FUNC_HANDLE_LARGE_SIZE", "text" => GetMessage('P_WM_IMG_ERROR04'))));
continue;
}
if ($type_i && strpos(strtolower($type_i), 'image') === false) {
CImageUploader::SaveError(array(array("file" => $name_i, "id" => "BXPH_FUNC_HANDLE_TYPE", "text" => GetMessage('P_WM_IMG_ERROR02'))));
continue;
}
$ext_i = GetFileExtension($name_i);
$name_i = GetFileNameWithoutExtension($name_i);
$name_i_ = preg_replace("/[^a-zA-Z0-9_]/i", "", $name_i);
if ($name_i_ != $name_i) {
$name_i = ($name_i_ == '' ? substr(md5(mt_rand()), 0, 6) : '') . $name_i_;
}
// TODO: exif, iptc
//$exif = CFile::ExtractImageExif($tmp_name_i);
//$iptc = CFile::ExtractImageIPTC($tmp_name_i);
$thumbSize = round($arParams["THUMBNAIL_SIZE"] * 1.8);
foreach ($arParams['converters'] as $key => $val) {
$destPath = $sTmpPath . $name_i . "_" . $key . "." . $ext_i;
if ($val["code"] == "real_picture") {
$size = intVal($_POST['photo_resize_size']);
if ($arParams['ORIGINAL_SIZE'] && $arParams['ORIGINAL_SIZE'] > 0 && ($arParams['ORIGINAL_SIZE'] < $size || $size <= 0)) {
$size = $arParams['ORIGINAL_SIZE'];
}
$arSize = array('width' => $size, 'height' => $size);
$jpegQuality = $arParams['JPEG_QUALITY'];
} else {
if ($val["code"] == "thumbnail") {
$arSize = array('width' => $thumbSize, 'height' => $thumbSize);
$jpegQuality = $arParams['JPEG_QUALITY1'];
} else {
$arSize = array('width' => intVal($val['width']), 'height' => intVal($val['height']));
}
}
if (!$jpegQuality || $jpegQuality < 20) {
$jpegQuality = false;
}
$arCurWatermark = $arSize['width'] > $arParams['WATERMARK_MIN_PICTURE_SIZE'] || $arSize['height'] > $arParams['WATERMARK_MIN_PICTURE_SIZE'] ? $arWatermark : array();
$res = CFile::ResizeImageFile($tmp_name_i, $destPath, $arSize, BX_RESIZE_IMAGE_PROPORTIONAL_ALT, $arCurWatermark, $jpegQuality, array());
$arFiles[] = array('name' => $files['name'][$i], 'tmp_name' => $destPath, 'errors' => $files['error'][$i], 'type' => $files['type'][$i], 'size' => '', 'mode' => $val["code"], 'width' => '', 'height' => '', 'path' => $destPath);
}
$elementId = handleFile($Info, $arFiles, array('arParams' => $arParams, "~arResult" => $arResult));
if ($elementId) {
$arIds[] = $elementId;
}
foreach ($arFiles as $arFile) {
if (file_exists($arFile['tmp_name'])) {
unlink($arFile['tmp_name']);
}
}
}
$jsResFiles = array();
//.........这里部分代码省略.........