本文整理汇总了PHP中CFile::GetImageSize方法的典型用法代码示例。如果您正苦于以下问题:PHP CFile::GetImageSize方法的具体用法?PHP CFile::GetImageSize怎么用?PHP CFile::GetImageSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFile
的用法示例。
在下文中一共展示了CFile::GetImageSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DoValidate
function DoValidate($arParams, $arQuestion, $arAnswers, $arValues)
{
global $APPLICATION;
if (count($arValues) > 0) {
foreach ($arValues as $arImage) {
// if image successfully uploaded
if (strlen($arImage["tmp_name"]) > 0 && ($arImageInfo = CFile::GetImageSize($arImage["tmp_name"]))) {
// check minimum image width
if ($arParams["WIDTH_FROM"] > 0 && $arImageInfo[0] < $arParams["WIDTH_FROM"]) {
$APPLICATION->ThrowException(GetMessage("FORM_VALIDATOR_IMAGE_SIZE_ERROR_WIDTH_LESS"));
return false;
}
// check maximum image width
if ($arParams["WIDTH_TO"] > 0 && $arImageInfo[0] > $arParams["WIDTH_TO"]) {
$APPLICATION->ThrowException(GetMessage("FORM_VALIDATOR_IMAGE_SIZE_ERROR_WIDTH_MORE"));
return false;
}
// check minimum image height
if ($arParams["HEIGHT_FROM"] > 0 && $arImageInfo[1] < $arParams["HEIGHT_FROM"]) {
$APPLICATION->ThrowException(GetMessage("FORM_VALIDATOR_IMAGE_SIZE_ERROR_HEIGHT_LESS"));
return false;
}
// check maximum image height
if ($arParams["HEIGHT_TO"] > 0 && $arImageInfo[1] > $arParams["HEIGHT_TO"]) {
$APPLICATION->ThrowException(GetMessage("FORM_VALIDATOR_IMAGE_SIZE_ERROR_HEIGHT_MORE"));
return false;
}
}
}
}
return true;
}
示例2: CheckFile
public static function CheckFile($arFile, $iMaxSize = 0, $iMaxWidth = 0, $iMaxHeight = 0, $access_typies = array(), $bForceMD5 = false, $bSkipExt = false)
{
if ($arFile["name"] == "") {
return "";
}
if (preg_match("#^php://filter#i", $arFile["tmp_name"])) {
return GetMessage("FILE_BAD_FILE_TYPE") . ".<br>";
}
$extension = GetFileExtension(strtolower($arFile["name"]));
switch ($extension) {
case "jpg":
case "jpeg":
case "gif":
case "bmp":
case "png":
$file_type = "IMAGE";
break;
case "swf":
$file_type = "FLASH";
break;
case "mp4":
case "webm":
case "ogg":
$file_type = "VIDEO";
break;
default:
$file_type = "UNKNOWN";
}
// IMAGE by default
$flashEnabled = false;
if (!in_array($file_type, $access_typies)) {
$file_type = "IMAGE";
}
if ($file_type == "FLASH") {
$flashEnabled = true;
static $flashMime = array("application/x-shockwave-flash", "application/vnd.adobe.flash.movie");
$res = CFile::CheckFile($arFile, $iMaxSize, $flashMime, CFile::GetFlashExtensions(), $bForceMD5, $bSkipExt);
} else {
if ($file_type == "VIDEO") {
$res = CFile::CheckFile($arFile, $iMaxSize, "video/", "mp4,webm,ogg", $bForceMD5, $bSkipExt);
} else {
$res = CFile::CheckFile($arFile, $iMaxSize, "image/", CFile::GetImageExtensions(), $bForceMD5, $bSkipExt);
}
}
if ($res != '') {
return $res;
}
if ($file_type == 'IMAGE' || $file_type == "FLASH") {
$imgArray = CFile::GetImageSize($arFile["tmp_name"], true, $flashEnabled);
if (is_array($imgArray)) {
$intWIDTH = $imgArray[0];
$intHEIGHT = $imgArray[1];
} else {
return GetMessage("FILE_BAD_FILE_TYPE") . ".<br>";
}
//check for dimensions
if ($iMaxWidth > 0 && ($intWIDTH > $iMaxWidth || $intWIDTH == 0) || $iMaxHeight > 0 && ($intHEIGHT > $iMaxHeight || $intHEIGHT == 0)) {
return GetMessage("FILE_BAD_MAX_RESOLUTION") . " (" . $iMaxWidth . " * " . $iMaxHeight . " " . GetMessage("main_include_dots") . ").<br>";
}
}
return null;
}
示例3: SaveFile
function SaveFile($name, $arRestriction = array())
{
$wizard = $this->GetWizard();
$deleteFile = $wizard->GetVar($name . "_del");
$wizard->UnSetVar($name . "_del");
$oldFileID = $wizard->GetVar($name);
$fileNew = $wizard->GetRealName($name . "_new");
if (!array_key_exists($fileNew, $_FILES) || strlen($_FILES[$fileNew]["name"]) <= 0 && $deleteFile === null) {
return;
}
if (strlen($_FILES[$fileNew]["tmp_name"]) <= 0 && $deleteFile === null) {
$this->SetError(GetMessage("MAIN_WIZARD_FILE_UPLOAD_ERROR"), $name . "_new");
return;
}
$arFile = $_FILES[$fileNew] + array("del" => $deleteFile == "Y" ? "Y" : "", "old_file" => intval($oldFileID) > 0 ? intval($oldFileID) : 0, "MODULE_ID" => "tmp_wizard");
$max_file_size = array_key_exists("max_file_size", $arRestriction) ? intval($arRestriction["max_file_size"]) : 0;
$max_width = array_key_exists("max_width", $arRestriction) ? intval($arRestriction["max_width"]) : 0;
$max_height = array_key_exists("max_height", $arRestriction) ? intval($arRestriction["max_height"]) : 0;
$extensions = array_key_exists("extensions", $arRestriction) && strlen($arRestriction["extensions"]) > 0 ? trim($arRestriction["extensions"]) : false;
$make_preview = array_key_exists("make_preview", $arRestriction) && $arRestriction["make_preview"] == "Y" ? true : false;
$error = CFile::CheckFile($arFile, $max_file_size, false, $extensions);
if (strlen($error) > 0) {
$this->SetError($error, $name . "_new");
return;
}
if ($make_preview && $max_width > 0 && $max_height > 0) {
list($sourceWidth, $sourceHeight, $type, $attr) = CFile::GetImageSize($arFile["tmp_name"]);
if ($sourceWidth > $max_width || $sourceHeight > $max_height) {
$success = CWizardUtil::CreateThumbnail($arFile["tmp_name"], $arFile["tmp_name"], $max_width, $max_height);
if ($success) {
$arFile["size"] = @filesize($arFile["tmp_name"]);
}
}
} elseif ($max_width > 0 || $max_height > 0) {
$error = CFile::CheckImageFile($arFile, $max_file_size, $max_width, $max_height);
if (strlen($error) > 0) {
$this->SetError($error, $name . "_new");
return;
}
}
$fileID = (int) CFile::SaveFile($arFile, "tmp");
if ($fileID > 0) {
$wizard->SetVar($name, $fileID);
} else {
$wizard->UnSetVar($name);
}
return $fileID;
}
示例4: OnFileSave
public static function OnFileSave(&$arFile, $strFileName, $strSavePath, $bForceMD5 = false, $bSkipExt = false)
{
if (!$arFile["tmp_name"] && !array_key_exists("content", $arFile)) {
return false;
}
if (array_key_exists("bucket", $arFile)) {
$bucket = $arFile["bucket"];
} else {
$bucket = CCloudStorage::FindBucketForFile($arFile, $strFileName);
}
if (!is_object($bucket)) {
return false;
}
if (!$bucket->Init()) {
return false;
}
$copySize = false;
$subDir = "";
$filePath = "";
if (array_key_exists("content", $arFile)) {
$arFile["tmp_name"] = CTempFile::GetFileName($arFile["name"]);
CheckDirPath($arFile["tmp_name"]);
$fp = fopen($arFile["tmp_name"], "ab");
if ($fp) {
fwrite($fp, $arFile["content"]);
fclose($fp);
}
}
if (array_key_exists("bucket", $arFile)) {
$newName = bx_basename($arFile["tmp_name"]);
$prefix = $bucket->GetFileSRC("/");
$subDir = substr($arFile["tmp_name"], strlen($prefix));
$subDir = substr($subDir, 0, -strlen($newName) - 1);
} else {
if ($bForceMD5 != true && COption::GetOptionString("main", "save_original_file_name", "N") == "Y") {
if (COption::GetOptionString("main", "convert_original_file_name", "Y") == "Y") {
$newName = CCloudStorage::translit($strFileName);
} else {
$newName = $strFileName;
}
} else {
$strFileExt = $bSkipExt == true ? '' : strrchr($strFileName, ".");
$newName = md5(uniqid(mt_rand(), true)) . $strFileExt;
}
//check for double extension vulnerability
$newName = RemoveScriptExtension($newName);
while (true) {
$strRand = md5(mt_rand());
$strRand = substr($strRand, 0, 3) . "/" . $strRand;
if (substr($strSavePath, -1) == "/") {
$subDir = $strSavePath . $strRand;
} else {
$subDir = $strSavePath . "/" . $strRand;
}
$subDir = ltrim($subDir, "/");
$filePath = "/" . $subDir . "/" . $newName;
if (!$bucket->FileExists($filePath)) {
break;
}
}
$targetPath = $bucket->GetFileSRC("/");
if (strpos($arFile["tmp_name"], $targetPath) === 0) {
$arDbFile = array("SUBDIR" => "", "FILE_NAME" => substr($arFile["tmp_name"], strlen($targetPath)), "CONTENT_TYPE" => $arFile["type"]);
$copyPath = $bucket->FileCopy($arDbFile, $filePath);
if (!$copyPath) {
return false;
}
$copySize = $bucket->GetFileSize("/" . urldecode(substr($copyPath, strlen($targetPath))));
} else {
$imgArray = CFile::GetImageSize($arFile["tmp_name"], true, false);
if (is_array($imgArray) && $imgArray[2] == IMAGETYPE_JPEG) {
$exifData = CFile::ExtractImageExif($arFile["tmp_name"]);
if ($exifData && isset($exifData['Orientation'])) {
$properlyOriented = CFile::ImageHandleOrientation($exifData['Orientation'], $arFile["tmp_name"]);
if ($properlyOriented) {
$jpgQuality = intval(COption::GetOptionString('main', 'image_resize_quality', '95'));
if ($jpgQuality <= 0 || $jpgQuality > 100) {
$jpgQuality = 95;
}
imagejpeg($properlyOriented, $arFile["tmp_name"], $jpgQuality);
}
}
}
if (!$bucket->SaveFile($filePath, $arFile)) {
return false;
}
}
}
$arFile["HANDLER_ID"] = $bucket->ID;
$arFile["SUBDIR"] = $subDir;
$arFile["FILE_NAME"] = $newName;
$arFile["WIDTH"] = 0;
$arFile["HEIGHT"] = 0;
if (array_key_exists("bucket", $arFile)) {
$arFile["WIDTH"] = $arFile["width"];
$arFile["HEIGHT"] = $arFile["height"];
$arFile["size"] = $arFile["file_size"];
} elseif ($copySize !== false) {
$arFile["size"] = $copySize;
$bucket->IncFileCounter($copySize);
//.........这里部分代码省略.........
示例5: implode
$arResult["QUESTIONS"][$FIELD_SID]["HTML_CODE"] = implode("<br />", $arResult["QUESTIONS"][$FIELD_SID]["HTML_CODE"]);
// ******************************************************************************* //
if ($arResult["QUESTIONS"][$FIELD_SID]["IS_INPUT_CAPTION_IMAGE"] == "Y")
{
$arResult["QUESTIONS"][$FIELD_SID]["IMAGE"]["ID"] = $arResult["arQuestions"][$FIELD_SID]["IMAGE_ID"];
// assign field image path
$arImage = CFile::GetFileArray($arResult["QUESTIONS"][$FIELD_SID]["IMAGE"]["ID"]);
$arResult["QUESTIONS"][$FIELD_SID]["IMAGE"]["URL"] = $arImage["SRC"];
// check image file existance and assign image data
if (substr($arImage["SRC"], 0, 1) == "/")
{
$arSize = CFile::GetImageSize($_SERVER["DOCUMENT_ROOT"].$arImage["SRC"]);
if (is_array($arSize))
{
list(
$arResult["QUESTIONS"][$FIELD_SID]["IMAGE"]["WIDTH"],
$arResult["QUESTIONS"][$FIELD_SID]["IMAGE"]["HEIGHT"],
$arResult["QUESTIONS"][$FIELD_SID]["IMAGE"]["TYPE"],
$arResult["QUESTIONS"][$FIELD_SID]["IMAGE"]["ATTR"]
) = $arSize;
}
}
else
{
$arResult["QUESTIONS"][$FIELD_SID]["IMAGE"]["WIDTH"] = $arImage["WIDTH"];
$arResult["QUESTIONS"][$FIELD_SID]["IMAGE"]["HEIGHT"] = $arImage["HEIGHT"];
$arResult["QUESTIONS"][$FIELD_SID]["IMAGE"]["TYPE"] = false;
示例6: str_replace
$arParams["PATH_TO_FONT"] = str_replace(array("\\", "//"), "/", trim($arParams["PATH_TO_FONT"]));
if (file_exists($_SERVER['DOCUMENT_ROOT'] . $arParams["PATH_TO_FONT"])) {
$arParams["PATH_TO_FONT"] = $_SERVER['DOCUMENT_ROOT'] . $arParams["PATH_TO_FONT"];
} else {
$arParams["PATH_TO_FONT"] = str_replace(array("\\", "//"), "/", $_SERVER['DOCUMENT_ROOT'] . "/" . BX_ROOT . "/modules/photogallery/fonts/" . trim($arParams["PATH_TO_FONT"]));
$arParams["PATH_TO_FONT"] = file_exists($arParams["PATH_TO_FONT"]) ? $arParams["PATH_TO_FONT"] : "";
}
$arParams["WATERMARK_COLOR"] = '#' . trim($arParams["WATERMARK_COLOR"], ' #');
$arParams["WATERMARK_SIZE"] = intVal($arParams["WATERMARK_SIZE"]);
$arParams["WATERMARK_FILE_REL"] = '/' . trim($arParams["WATERMARK_FILE"], ' /');
$arParams["WATERMARK_FILE"] = str_replace(array("\\", "//"), "/", $_SERVER['DOCUMENT_ROOT'] . $arParams["WATERMARK_FILE_REL"]);
$arParams["WATERMARK_FILE"] = file_exists($arParams["WATERMARK_FILE"]) ? $arParams["WATERMARK_FILE"] : "";
$arParams["WATERMARK_FILE_ORDER"] = strtolower($arParams["WATERMARK_FILE_ORDER"]);
$arParams["WATERMARK_POSITION"] = trim($arParams["WATERMARK_POSITION"]);
if ($arParams["WATERMARK_FILE"] && CFile::IsImage($arParams["WATERMARK_FILE"])) {
$imgArray = CFile::GetImageSize($arParams["WATERMARK_FILE"]);
$arParams["WATERMARK_FILE_WIDTH"] = $imgArray[0];
$arParams["WATERMARK_FILE_HEIGHT"] = $imgArray[1];
} else {
$arParams["WATERMARK_FILE"] = "";
$arParams["WATERMARK_FILE_REL"] = "";
}
$arPositions = array("TopLeft", "TopCenter", "TopRight", "CenterLeft", "Center", "CenterRight", "BottomLeft", "BottomCenter", "BottomRight");
$arPositions2 = array("tl", "tc", "tr", "ml", "mc", "mr", "bl", "bc", "br");
if (in_array($arParams["WATERMARK_POSITION"], $arPositions2)) {
$arParams["WATERMARK_POSITION"] = str_replace($arPositions2, $arPositions, $arParams["WATERMARK_POSITION"]);
} else {
$arParams["WATERMARK_POSITION"] = "BottomRight";
}
$arParams["WATERMARK_TRANSPARENCY"] = trim($arParams["WATERMARK_TRANSPARENCY"]);
$arParams["WATERMARK_MIN_PICTURE_SIZE"] = intVal($arParams["WATERMARK_MIN_PICTURE_SIZE"]) > 0 ? intVal($arParams["WATERMARK_MIN_PICTURE_SIZE"]) : 800;
示例7: CheckDirPath
if ($SMILE_TYPE == "I") {
$strDirName .= "icon";
} else {
$strDirName .= "smile";
}
$strDirName .= "/";
$strFileName = $strFileName . "." . $strFileExt;
CheckDirPath($strDirName);
if (file_exists($strDirName . $strFileName) && (!$arOldSmile || $arOldSmile["SMILE_TYPE"] != $SMILE_TYPE || $arOldSmile["IMAGE"] != $strFileName)) {
$strErrorMessage .= GetMessage("ERROR_EXISTS_IMAGE") . ". \n";
} else {
if (!@copy($_FILES["IMAGE1"]["tmp_name"], $strDirName . $strFileName)) {
$strErrorMessage .= GetMessage("ERROR_COPY_IMAGE") . ". \n";
} else {
@chmod($strDirName . $strFileName, BX_FILE_PERMISSIONS);
$imgArray = CFile::GetImageSize($strDirName . $strFileName);
if (is_array($imgArray)) {
$iIMAGE_WIDTH = $imgArray[0];
$iIMAGE_HEIGHT = $imgArray[1];
} else {
$iIMAGE_WIDTH = 0;
$iIMAGE_HEIGHT = 0;
}
}
if ($arOldSmile && ($arOldSmile["SMILE_TYPE"] != $SMILE_TYPE || $arOldSmile["IMAGE"] != $strFileName) && strlen($arOldSmile["IMAGE"]) > 0) {
$strDirNameOld = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/images/blog/";
if ($arOldSmile["SMILE_TYPE"] == "I") {
$strDirNameOld .= "icon";
} else {
$strDirNameOld .= "smile";
}
示例8: GetMessage
:</td>
<td width="60%">
<table border="0" cellspacing="0" cellpadding="0" class="internal">
<tr class="heading">
<td align="center"><?php
echo GetMessage("post_file");
?>
</td>
<td align="center"><?php
echo GetMessage("post_size");
?>
</td>
</tr>
<?php
foreach ($tools->aMatches as $attachment) {
if (CFile::GetImageSize($attachment["PATH"], true) === false) {
continue;
}
?>
<tr>
<td><a href="<?php
echo $attachment["SRC"];
?>
" target=_blank><?php
echo $attachment["DEST"];
?>
</a></td>
<td align="right"><?php
echo filesize($attachment["PATH"]);
?>
</td>
示例9: Number2Word_Rus
echo Number2Word_Rus($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["SHOULD_PAY"]);
} else {
echo SaleFormatCurrency($GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["SHOULD_PAY"], $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["CURRENCY"]);
}
?>
</p>
<p>
<div align="right" style="padding-right:30px;"><?php
echo CSalePaySystemAction::GetParamValue("DATE_INSERT");
?>
</div><br />
<?php
$stamp = CSalePaySystemAction::GetParamValue("PATH_TO_STAMP");
if (strlen($stamp) > 0) {
if (file_exists($_SERVER["DOCUMENT_ROOT"] . $stamp) && is_file($_SERVER["DOCUMENT_ROOT"] . $stamp)) {
list($width, $height, $type, $attr) = CFile::GetImageSize($_SERVER["DOCUMENT_ROOT"] . $stamp);
?>
<img align="right" src="<?php
echo $stamp;
?>
" <?php
echo $attr;
?>
border="0" alt=""><br clear="all"><?php
}
}
?>
</p>
<p><font size="2">В случае непоступления средств на расчетный счет продавца в течение пяти
банковских дней со дня выписки счета, продавец оставляет за собой право
пересмотреть отпускную цену товара в рублях пропорционально изменению курса доллара
示例10: GetContentType
function GetContentType($path, $bPhysicalName = false)
{
if ($bPhysicalName) {
$pathX = $path;
} else {
$io = CBXVirtualIo::GetInstance();
$pathX = $io->GetPhysicalName($path);
}
if (function_exists("mime_content_type")) {
$type = mime_content_type($pathX);
} else {
$type = "";
}
if ($type == "" && function_exists("image_type_to_mime_type")) {
$arTmp = CFile::GetImageSize($pathX, true);
$type = $arTmp["mime"];
}
if ($type == "") {
static $arTypes = array("jpeg" => "image/jpeg", "jpe" => "image/jpeg", "jpg" => "image/jpeg", "png" => "image/png", "gif" => "image/gif", "bmp" => "image/bmp", "xla" => "application/vnd.ms-excel", "xlb" => "application/vnd.ms-excel", "xlc" => "application/vnd.ms-excel", "xll" => "application/vnd.ms-excel", "xlm" => "application/vnd.ms-excel", "xls" => "application/vnd.ms-excel", "xlsx" => "application/vnd.ms-excel", "xlt" => "application/vnd.ms-excel", "xlw" => "application/vnd.ms-excel", "dbf" => "application/vnd.ms-excel", "csv" => "application/vnd.ms-excel", "doc" => "application/msword", "docx" => "application/msword", "dot" => "application/msword", "rtf" => "application/msword", "rar" => "application/x-rar-compressed", "zip" => "application/zip");
$type = $arTypes[strtolower(substr($pathX, bxstrrpos($pathX, ".") + 1))];
}
if ($type == "") {
$type = "application/octet-stream";
}
return $type;
}
示例11: __replace_img
function __replace_img($matches)
{
$src = $matches[3];
if ($src != "") {
if (array_key_exists($src, $this->aMatches)) {
$uid = $this->aMatches[$src]["ID"];
} elseif (file_exists($_SERVER["DOCUMENT_ROOT"] . $src) && is_array(CFile::GetImageSize($_SERVER["DOCUMENT_ROOT"] . $src))) {
$dest = basename($src);
$uid = uniqid(md5($dest));
$this->aMatches[$src] = array("SRC" => $src, "DEST" => $dest, "ID" => $uid);
} else {
return $matches[0];
}
return $matches[1] . $matches[2] . "cid:" . $uid . $matches[4] . $matches[5];
}
return $matches[0];
}
示例12: GetMessage
<td width="60%">
<table border="0" cellspacing="0" cellpadding="0" class="internal">
<tr class="heading">
<td align="center"><?php
echo GetMessage("post_file");
?>
</td>
<td align="center"><?php
echo GetMessage("post_size");
?>
</td>
</tr>
<?php
foreach ($tools->aMatches as $attachment) {
$filename = $_SERVER["DOCUMENT_ROOT"] . $attachment["SRC"];
if (CFile::GetImageSize($filename) === false) {
continue;
}
?>
<tr>
<td><a href="<?php
echo $attachment["SRC"];
?>
" target=_blank><?php
echo $attachment["DEST"];
?>
</a></td>
<td align="right"><?php
echo filesize($filename);
?>
</td>
示例13: strlen
$FILE_PERM = strlen($FILE_PERM) > 0 ? $FILE_PERM : "D";
if ($FILE_PERM >= "R") {
if (CSaleAuxiliary::CheckAccess($USER->GetID(), $mp3AuxiliaryPrefix . $file, $mp3AccessTimeLength, $mp3AccessTimeType)) {
$bCanAccess = True;
}
}
}
if (!$bCanAccess) {
LocalRedirect($mp3Url2Folder . "auth.php?fname=" . urlencode($file) . "&DIR=" . urlencode($DIR));
} else {
$filesize = filesize($filename);
$f = fopen($filename, "rb");
$cur_pos = 0;
$size = $filesize - 1;
if ($bRealyImage) {
$imageParams = CFile::GetImageSize($filename);
}
if ($_SERVER["REQUEST_METHOD"] == "HEAD") {
if ($sapi == "cgi") {
header("Status: 200 OK");
} else {
header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
}
header("Accept-Ranges: bytes");
header("Content-Length: " . $filesize);
if ($bRealyImage) {
header("Content-Type: " . $imageParams["mime"] . "; name=\"" . $file . "\"");
} else {
header("Content-Type: application/force-download; name=\"" . $file . "\"");
}
header("Last-Modified: " . date("r", filemtime($filename)));
示例14: Copyright
##############################################
# Bitrix: SiteManager #
# Copyright (c) 2002 - 2011 Bitrix #
# http://www.bitrixsoft.com #
# mailto:admin@bitrixsoft.com #
##############################################
*/
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
if (CModule::IncludeModule("support") && strlen($hash) > 0) {
$rsFiles = CTicket::GetFileList($v1 = "s_id", $v2 = "asc", array("HASH" => $hash));
if ($arFile = $rsFiles->Fetch()) {
set_time_limit(0);
if ($action == "download") {
CFile::ViewByUser($arFile, array("force_download" => true));
} else {
if (substr($arFile["CONTENT_TYPE"], 0, 6) === 'image/' && CFile::IsImage($arFile["FILE_NAME"], $arFile["CONTENT_TYPE"]) && (!empty($arFile["SRC"]) && CFile::GetImageSize($_SERVER["DOCUMENT_ROOT"] . $arFile["SRC"]) || $arFile["WIDTH"] > 0 && $arFile["HEIGHT"] > 0)) {
CFile::ViewByUser($arFile, array("content_type" => $arFile["CONTENT_TYPE"]));
} else {
// check extension
$ar = pathinfo($arFile["ORIGINAL_NAME"]);
$ext = $ar["extension"];
switch (strtolower($ext)) {
case "xla":
case "xlb":
case "xlc":
case "xll":
case "xlm":
case "xls":
case "xlsx":
case "xlt":
case "xlw":
示例15: 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");
*/
}