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


PHP CDiskQuota::checkDiskQuota方法代码示例

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


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

示例1: BaseCheckFields

 function BaseCheckFields($val)
 {
     $arErrors = array();
     if (!is_array($val)) {
         $val = array();
     }
     // Check uploaded file
     if ($val["B_NEW_FILE"] != "N" && isset($val["FILE"])) {
         if ($val["FILE"]["error"] == 1 || $val["FILE"]["error"] == 2) {
             $arErrors[] = GetMessage("IBLOCK_PROP_VIDEO_SIZE_ERROR", array('#FILE_NAME#' => $pathto)) . "\n";
         }
         if (strlen($val["FILE"]["tmp_name"]) > 0) {
             $name = $val["FILE"]["name"];
             $name = preg_replace("/[^a-zA-Z0-9_:\\.]/is", "_", $name);
             $ext = GetFileExtension($name);
             if (strlen($ext) == 0 || HasScriptExtension($name) || substr($name, 0, 1) == ".") {
                 $arErrors[] = GetMessage("IBLOCK_PROP_VIDEO_INCORRECT_EXT", array("#EXT#" => strtoupper($ext)));
             } elseif (!is_uploaded_file($val["FILE"]["tmp_name"])) {
                 $arErrors[] = GetMessage("IBLOCK_PROP_VIDEO_UPLOAD_ERROR");
             } else {
                 $quota = new CDiskQuota();
                 if (!$quota->checkDiskQuota(array("FILE_SIZE" => $val["FILE"]["size"]))) {
                     $arErrors[] = GetMessage("IBLOCK_PROP_VIDEO_QUOTE_ERROR") . "\n";
                 }
             }
         }
     }
     return $arErrors;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:29,代码来源:properties.php

示例2: ResizeImageGet

 function ResizeImageGet($file, $arSize, $resizeType = BX_RESIZE_IMAGE_PROPORTIONAL, $bInitSizes = false, $arFilters = false, $bImmediate = false, $jpgQuality = false)
 {
     if (!is_array($file) && intval($file) > 0) {
         $file = CFile::GetFileArray($file);
     }
     if (!is_array($file) || !array_key_exists("FILE_NAME", $file) || strlen($file["FILE_NAME"]) <= 0) {
         return 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"]);
     $uploadDirName = COption::GetOptionString("main", "upload_dir", "upload");
     $imageFile = "/" . $uploadDirName . "/" . $file["SUBDIR"] . "/" . $file["FILE_NAME"];
     $arImageSize = false;
     $bFilters = is_array($arFilters) && !empty($arFilters);
     if (($arSize["width"] <= 0 || $arSize["width"] >= $file["WIDTH"]) && ($arSize["height"] <= 0 || $arSize["height"] >= $file["HEIGHT"])) {
         if ($bFilters) {
             //Only filters. Leave size unchanged
             $arSize["width"] = $file["WIDTH"];
             $arSize["height"] = $file["HEIGHT"];
             $resizeType = BX_RESIZE_IMAGE_PROPORTIONAL;
         } else {
             global $arCloudImageSizeCache;
             $arCloudImageSizeCache[$file["SRC"]] = array($file["WIDTH"], $file["HEIGHT"]);
             return array("src" => $file["SRC"], "width" => intval($file["WIDTH"]), "height" => intval($file["HEIGHT"]), "size" => $file["FILE_SIZE"]);
         }
     }
     $io = CBXVirtualIo::GetInstance();
     $cacheImageFile = "/" . $uploadDirName . "/resize_cache/" . $file["SUBDIR"] . "/" . $arSize["width"] . "_" . $arSize["height"] . "_" . $resizeType . (is_array($arFilters) ? md5(serialize($arFilters)) : "") . "/" . $file["FILE_NAME"];
     $cacheImageFileCheck = $cacheImageFile;
     if ($file["CONTENT_TYPE"] == "image/bmp") {
         $cacheImageFileCheck .= ".jpg";
     }
     static $cache = array();
     $cache_id = $cacheImageFileCheck;
     if (isset($cache[$cache_id])) {
         return $cache[$cache_id];
     } elseif (!file_exists($io->GetPhysicalName($_SERVER["DOCUMENT_ROOT"] . $cacheImageFileCheck))) {
         /****************************** QUOTA ******************************/
         $bDiskQuota = true;
         if (COption::GetOptionInt("main", "disk_space") > 0) {
             $quota = new CDiskQuota();
             $bDiskQuota = $quota->checkDiskQuota($file);
         }
         /****************************** QUOTA ******************************/
         if ($bDiskQuota) {
             if (!is_array($arFilters)) {
                 $arFilters = array(array("name" => "sharpen", "precision" => 15));
             }
             $sourceImageFile = $_SERVER["DOCUMENT_ROOT"] . $imageFile;
             $cacheImageFileTmp = $_SERVER["DOCUMENT_ROOT"] . $cacheImageFile;
             $bNeedResize = true;
             $callbackData = null;
             foreach (GetModuleEvents("main", "OnBeforeResizeImage", true) as $arEvent) {
                 if (ExecuteModuleEventEx($arEvent, array($file, array($arSize, $resizeType, array(), false, $arFilters, $bImmediate), &$callbackData, &$bNeedResize, &$sourceImageFile, &$cacheImageFileTmp))) {
                     break;
                 }
             }
             if ($bNeedResize && CFile::ResizeImageFile($sourceImageFile, $cacheImageFileTmp, $arSize, $resizeType, array(), $jpgQuality, $arFilters)) {
                 $cacheImageFile = substr($cacheImageFileTmp, strlen($_SERVER["DOCUMENT_ROOT"]));
                 /****************************** QUOTA ******************************/
                 if (COption::GetOptionInt("main", "disk_space") > 0) {
                     CDiskQuota::updateDiskQuota("file", filesize($io->GetPhysicalName($cacheImageFileTmp)), "insert");
                 }
                 /****************************** QUOTA ******************************/
             } else {
                 $cacheImageFile = $imageFile;
             }
             foreach (GetModuleEvents("main", "OnAfterResizeImage", true) as $arEvent) {
                 if (ExecuteModuleEventEx($arEvent, array($file, array($arSize, $resizeType, array(), false, $arFilters), &$callbackData, &$cacheImageFile, &$cacheImageFileTmp, &$arImageSize))) {
                     break;
                 }
             }
         } else {
             $cacheImageFile = $imageFile;
         }
         $cacheImageFileCheck = $cacheImageFile;
     }
     if ($bInitSizes && !is_array($arImageSize)) {
         $arImageSize = CFile::GetImageSize($_SERVER["DOCUMENT_ROOT"] . $cacheImageFileCheck);
         $f = $io->GetFile($_SERVER["DOCUMENT_ROOT"] . $cacheImageFileCheck);
         $arImageSize[2] = $f->GetFileSize();
     }
     $cache[$cache_id] = array("src" => $cacheImageFileCheck, "width" => intval($arImageSize[0]), "height" => intval($arImageSize[1]), "size" => $arImageSize[2]);
     return $cache[$cache_id];
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:97,代码来源:file.php

示例3: CheckFields


//.........这里部分代码省略.........
                             break;
                         }
                     }
                     $bError = $bCount <= 0;
                 }
             }
             if ($arProperty["IS_REQUIRED"] == "Y" && $arProperty['PROPERTY_TYPE'] != 'F') {
                 $len = 0;
                 foreach ($property_values as $key2 => $property_value) {
                     if (array_key_exists("GetLength", $arUserType)) {
                         $len += call_user_func_array($arUserType["GetLength"], array($arProperty, array("VALUE" => $property_value)));
                     } else {
                         $len += strlen($property_value);
                     }
                     if ($len > 0) {
                         break;
                     }
                 }
                 $bError = $len <= 0;
             }
             if ($bError) {
                 $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_PROPERTY", array("#PROPERTY#" => $arProperty["NAME"])) . "<br>";
             }
             // check file properties for correctness
             if ($arProperty['PROPERTY_TYPE'] == 'F') {
                 $bImageOnly = False;
                 $arImageExtentions = explode(",", strtoupper(CFile::GetImageExtensions()));
                 if (strlen($arProperty["FILE_TYPE"])) {
                     $bImageOnly = True;
                     $arAvailTypes = explode(",", strtoupper($arProperty["FILE_TYPE"]));
                     foreach ($arAvailTypes as $avail_type) {
                         if (!in_array(trim($avail_type), $arImageExtentions)) {
                             $bImageOnly = False;
                             break;
                         }
                     }
                 }
                 foreach ($property_values as $key2 => $property_value) {
                     if (!is_array($property_value) && intval($property_value) > 0 && intval($arFields["WF_PARENT_ELEMENT_ID"]) > 0) {
                         if (CIBlockElement::DeleteFile($property_value, $ID, "PROPERTY", intval($arFields["WF_PARENT_ELEMENT_ID"]), $arFields["IBLOCK_ID"], true) <= 0) {
                             $this->LAST_ERROR .= GetMessage("IBLOCK_ERR_FILE_PROPERTY") . "<br>";
                         }
                     } elseif (is_array($property_value)) {
                         if (is_object($property_value["bucket"])) {
                             //This is trusted image from xml import
                             $error = "";
                         } else {
                             if ($bImageOnly) {
                                 $error = CFile::CheckImageFile($property_value);
                             } else {
                                 $error = CFile::CheckFile($property_value, 0, false, $arProperty["FILE_TYPE"]);
                             }
                         }
                         //For user without edit php permissions
                         //we allow only pictures upload
                         if (!is_object($USER) || !$USER->IsAdmin()) {
                             if (HasScriptExtension($property_value["name"])) {
                                 $error = GetMessage("FILE_BAD_TYPE") . " (" . $property_value["name"] . ").";
                             }
                         }
                         if (strlen($error) > 0) {
                             $this->LAST_ERROR .= $error . "<br>";
                         }
                     }
                 }
             }
         }
     }
     $APPLICATION->ResetException();
     if ($ID === false) {
         $db_events = GetModuleEvents("iblock", "OnBeforeIBlockElementAdd", true);
     } else {
         $arFields["ID"] = $ID;
         $db_events = GetModuleEvents("iblock", "OnBeforeIBlockElementUpdate", true);
     }
     foreach ($db_events as $arEvent) {
         $bEventRes = ExecuteModuleEventEx($arEvent, array(&$arFields));
         if ($bEventRes === false) {
             if ($err = $APPLICATION->GetException()) {
                 $this->LAST_ERROR .= $err->GetString() . "<br>";
             } else {
                 $APPLICATION->ThrowException("Unknown error");
                 $this->LAST_ERROR .= "Unknown error.<br>";
             }
             break;
         }
     }
     /****************************** QUOTA ******************************/
     if ($bCheckDiskQuota && empty($this->LAST_ERROR) && COption::GetOptionInt("main", "disk_space") > 0) {
         $quota = new CDiskQuota();
         if (!$quota->checkDiskQuota($arFields)) {
             $this->LAST_ERROR = $quota->LAST_ERROR;
         }
     }
     /****************************** QUOTA ******************************/
     if (!empty($this->LAST_ERROR)) {
         return false;
     }
     return true;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:iblockelement.php

示例4: UploadFile

 function UploadFile($Params)
 {
     $buffer = 'parent.oWaitWindow.Hide();';
     $F = $Params['file'];
     $io = CBXVirtualIo::GetInstance();
     if (isset($F["tmp_name"]) && strlen($F["tmp_name"]) > 0 && strlen($F["name"]) > 0 || is_uploaded_file($F["tmp_name"])) {
         global $APPLICATION, $USER;
         $strWarning = '';
         $filename = $Params['filename'];
         $path = $Params['path'];
         $site = $Params['site'];
         $upload_and_open = $Params['upload_and_open'];
         $rootPath = CSite::GetSiteDocRoot($site);
         if ($filename == '') {
             $filename = $F["name"];
         }
         $pathto = Rel2Abs($path, $filename);
         if (strlen($filename) > 0 && ($mess = self::CheckFileName($filename)) !== true) {
             $strWarning = $mess;
         }
         if ($strWarning == '') {
             $fn = $io->ExtractNameFromPath($pathto);
             if ($APPLICATION->GetFileAccessPermission(array($site, $pathto)) > "R" && ($USER->IsAdmin() || !HasScriptExtension($fn) && substr($fn, 0, 1) != "." && $io->ValidateFilenameString($fn))) {
                 if (!$io->FileExists($rootPath . $pathto) || $_REQUEST["rewrite"] == "Y") {
                     //************************** Quota **************************//
                     $bQuota = true;
                     if (COption::GetOptionInt("main", "disk_space") > 0) {
                         $bQuota = false;
                         $quota = new CDiskQuota();
                         if ($quota->checkDiskQuota(array("FILE_SIZE" => filesize($F["tmp_name"])))) {
                             $bQuota = true;
                         }
                     }
                     //************************** Quota **************************//
                     if ($bQuota) {
                         $io->Copy($F["tmp_name"], $rootPath . $pathto);
                         $flTmp = $io->GetFile($rootPath . $pathto);
                         $flTmp->MarkWritable();
                         if (COption::GetOptionInt("main", "disk_space") > 0) {
                             CDiskQuota::updateDiskQuota("file", $flTmp->GetFileSize(), "copy");
                         }
                         $buffer = 'setTimeout(function(){parent.oBXDialogControls.Uploader.OnAfterUpload("' . $filename . '", ' . ($upload_and_open == "Y" ? 'true' : 'false') . ');}, 50);';
                     } else {
                         $strWarning = $quota->LAST_ERROR;
                     }
                 } else {
                     $strWarning = GetMessage("FD_LOAD_EXIST_ALERT");
                 }
             } else {
                 $strWarning = GetMessage("FD_LOAD_DENY_ALERT");
             }
         }
     } else {
         $strWarning = GetMessage("FD_LOAD_ERROR_ALERT");
     }
     if ($strWarning != '') {
         $buffer = 'alert("' . addslashes(htmlspecialcharsex($strWarning)) . '");';
     }
     return '<script>' . $buffer . '</script>';
 }
开发者ID:spas-viktor,项目名称:books,代码行数:60,代码来源:file_dialog.php

示例5: CheckFields

 public function CheckFields(&$arFields, $ID = false)
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION;
     $this->LAST_ERROR = "";
     $NAME = isset($arFields["NAME"]) ? $arFields["NAME"] : "";
     if (($ID === false || array_key_exists("NAME", $arFields)) && strlen($NAME) <= 0) {
         $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_NAME") . "<br>";
     }
     if ($ID === false && !is_set($arFields, "IBLOCK_TYPE_ID")) {
         $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_BLOCK_TYPE") . "<br>";
     }
     if ($ID === false) {
         //For new record take default values
         $WORKFLOW = array_key_exists("WORKFLOW", $arFields) ? $arFields["WORKFLOW"] : "Y";
         $BIZPROC = array_key_exists("BIZPROC", $arFields) ? $arFields["BIZPROC"] : "N";
     } else {
         //For existing one read old values
         $arIBlock = CIBlock::GetArrayByID($ID);
         $WORKFLOW = array_key_exists("WORKFLOW", $arFields) ? $arFields["WORKFLOW"] : $arIBlock["WORKFLOW"];
         $BIZPROC = array_key_exists("BIZPROC", $arFields) ? $arFields["BIZPROC"] : $arIBlock["BIZPROC"];
         if ($BIZPROC != "Y") {
             $BIZPROC = "N";
         }
         //This is cache compatibility issue
     }
     if ($WORKFLOW == "Y" && $BIZPROC == "Y") {
         $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_WORKFLOW_AND_BIZPROC") . "<br>";
     }
     if (is_set($arFields, "IBLOCK_TYPE_ID")) {
         $r = CIBlockType::GetByID($arFields["IBLOCK_TYPE_ID"]);
         if (!$r->Fetch()) {
             $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_BLOCK_TYPE_ID") . "<br>";
         }
     }
     if (is_array($arFields["PICTURE"]) && array_key_exists("bucket", $arFields["PICTURE"]) && is_object($arFields["PICTURE"]["bucket"])) {
         //This is trusted image from xml import
     } elseif (isset($arFields["PICTURE"]) && is_array($arFields["PICTURE"]) && isset($arFields["PICTURE"]["name"])) {
         $error = CFile::CheckImageFile($arFields["PICTURE"]);
         if (strlen($error) > 0) {
             $this->LAST_ERROR .= $error . "<br>";
         }
     }
     if ($ID === false && !is_set($arFields, "LID") || is_set($arFields, "LID") && (is_array($arFields["LID"]) && count($arFields["LID"]) <= 0 || !is_array($arFields["LID"]) && strlen($arFields["LID"]) <= 0)) {
         $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_SITE_ID_NA") . "<br>";
     } elseif (is_set($arFields, "LID")) {
         if (!is_array($arFields["LID"])) {
             $arFields["LID"] = array($arFields["LID"]);
         }
         foreach ($arFields["LID"] as $v) {
             $r = CSite::GetByID($v);
             if (!$r->Fetch()) {
                 $this->LAST_ERROR .= "'" . $v . "' - " . GetMessage("IBLOCK_BAD_SITE_ID") . "<br>";
             }
         }
     }
     $APPLICATION->ResetException();
     if ($ID === false) {
         $db_events = GetModuleEvents("iblock", "OnBeforeIBlockAdd", true);
     } else {
         $arFields["ID"] = $ID;
         $db_events = GetModuleEvents("iblock", "OnBeforeIBlockUpdate", true);
     }
     foreach ($db_events as $arEvent) {
         $bEventRes = ExecuteModuleEventEx($arEvent, array(&$arFields));
         if ($bEventRes === false) {
             if ($err = $APPLICATION->GetException()) {
                 $this->LAST_ERROR .= $err->GetString() . "<br>";
             } else {
                 $APPLICATION->ThrowException("Unknown error");
                 $this->LAST_ERROR .= "Unknown error.<br>";
             }
             break;
         }
     }
     /****************************** QUOTA ******************************/
     if (empty($this->LAST_ERROR) && COption::GetOptionInt("main", "disk_space") > 0) {
         $quota = new CDiskQuota();
         if (!$quota->checkDiskQuota($arFields)) {
             $this->LAST_ERROR = $quota->LAST_ERROR;
         }
     }
     /****************************** QUOTA ******************************/
     if (strlen($this->LAST_ERROR) > 0) {
         return false;
     }
     return true;
 }
开发者ID:ASDAFF,项目名称:bxApiDocs,代码行数:88,代码来源:iblock.php

示例6: CopyEx

 function CopyEx($path_from, $path_to, $bDeleteAfterCopy = false, $bOverride = false)
 {
     global $APPLICATION, $USER;
     CMain::InitPathVars($site_from, $path_from);
     $DOC_ROOT_FROM = CSite::GetSiteDocRoot($site_from);
     CMain::InitPathVars($site_to, $path_to);
     $DOC_ROOT_TO = CSite::GetSiteDocRoot($site_to);
     $strWarning = '';
     //check: if we copy to the same directory
     if (strpos($DOC_ROOT_TO . $path_to . "/", $DOC_ROOT_FROM . $path_from . "/") === 0) {
         return GetMessage("FILEMAN_LIB_BAD_FOLDER") . ": \"" . $path_from . "\".\n";
     }
     $io = CBXVirtualIo::GetInstance();
     if ($io->DirectoryExists($DOC_ROOT_FROM . $path_from)) {
         // Minimal access - read/listing for copying files
         if (!$USER->CanDoFileOperation('fm_view_listing', array($site_from, $path_from))) {
             return GetMessage("FILEMAN_FILEMAN_FOLDER_READ_DENY") . " \"" . $path_from . "\".\n";
         }
         if ($bDeleteAfterCopy && !$USER->CanDoFileOperation('fm_delete_folder', array($site_from, $path_from))) {
             return GetMessage("FILEMAN_FILEMAN_FOLDER_DEL_DENY") . " \"" . $path_from . "\".\n";
         }
         //Check: folder exist or not
         $strWarTmp = CFileMan::CreateDir(array($site_to, $path_to));
         if (strlen($strWarTmp) > 0) {
             return $strWarTmp;
         }
         $APPLICATION->CopyFileAccessPermission(array($site_from, $path_from), array($site_to, $path_to));
     } else {
         // If we can write this file
         if (!$USER->CanDoFileOperation('fm_create_new_file', array($site_to, $path_to))) {
             return GetMessage("FILEMAN_FILEMAN_FILE_WRITE_DENY") . " \"" . $path_to . "\".\n";
         }
         // If we can't read source-file
         if (!$USER->CanDoFileOperation('fm_view_file', array($site_from, $path_from))) {
             return GetMessage("FILEMAN_FILEMAN_FILE_READ_DENY") . " \"" . $path_from . "\".\n";
         }
         // Copying php or system file without PHP or LPA access
         if (!($USER->CanDoOperation('edit_php') || $USER->CanDoFileOperation('fm_lpa', $arPath) || !(HasScriptExtension($Elem["NAME"]) || substr($Elem["NAME"], 0, 1) == "."))) {
             return GetMessage("FILEMAN_FILEMAN_FILE_READ_DENY") . " \"" . $path_from . "\".\n";
         }
         // If we can't move source-file
         if ($bDeleteAfterCopy && !$USER->CanDoFileOperation('fm_delete_file', array($site_from, $path_from))) {
             return GetMessage("FILEMAN_FILEMAN_FILE_DEL_DENY") . " \"" . $path_from . "\".\n";
         }
         //Check if folder already exist and trying to create if not
         $p = strrpos($path_to, "/");
         $path_to_dir = substr($path_to, 0, $p);
         $strWarTmp = CFileMan::CreateDir(array($site_to, $path_to_dir));
         if (strlen($strWarTmp) > 0) {
             return $strWarTmp;
         }
         if ($io->FileExists($DOC_ROOT_TO . $path_to) || $io->DirectoryExists($DOC_ROOT_TO . $path_to)) {
             if ($bOverride) {
                 $strWarn = CFileMan::DeleteEx(array($site_to, $path_to));
                 if ($strWarn != "") {
                     return $strWarn;
                 }
             } else {
                 return GetMessage("FILEMAN_FILEMAN_FILE_WITH_NAME") . " \"" . $path_to . "\" " . GetMessage("FILEMAN_FILEMAN_ALREADY_EXISTS") . "!\n";
             }
         }
         $APPLICATION->CopyFileAccessPermission(array($site_from, $path_from), array($site_to, $path_to));
         //************************** Quota **************************//
         if (COption::GetOptionInt("main", "disk_space") > 0) {
             $f = $io->GetFile($DOC_ROOT_FROM . $path_from);
             $size = $f->GetFileSize();
             $quota = new CDiskQuota();
             if (!$quota->checkDiskQuota(array("FILE_SIZE" => $size))) {
                 return $quota->LAST_ERROR;
             }
         }
         //************************** Quota **************************//
         // Copy file
         if (DEBUG_FILE_MAN) {
             echo "copy(" . $DOC_ROOT_FROM . $path_from . "," . $DOC_ROOT_TO . $path_to . ");<br>";
         }
         if (!$io->Copy($DOC_ROOT_FROM . $path_from, $DOC_ROOT_TO . $path_to)) {
             $strWarning .= GetMessage('FILEMAN_COPY_ERROR', array('#PATH_FROM#' => htmlspecialcharsex($path_from), '#PATH_TO#' => htmlspecialcharsex($path_to)));
         }
         //************************** Quota **************************//
         if (COption::GetOptionInt("main", "disk_space") > 0) {
             $quota->updateDiskQuota("file", $size, "copy");
         }
         //************************** Quota **************************//
         if (CModule::IncludeModule("search")) {
             $site = CSite::GetSiteByFullPath($DOC_ROOT_TO . $path_to);
             CSearch::ReIndexFile(array($site_to, $path_to), $site);
         }
         if ($bDeleteAfterCopy && strlen($strWarning) <= 0) {
             // If was command "delete after copy"?
             $strWarning .= CFileMan::DeleteFile(array($site_from, $path_from));
         }
         return $strWarning;
     }
     // Recursive
     $d = $io->GetDirectory($DOC_ROOT_FROM . $path_from);
     $arChildren = $d->GetChildren();
     foreach ($arChildren as $child) {
         $fn = $child->GetName();
         if ($child->IsDirectory()) {
//.........这里部分代码省略.........
开发者ID:Satariall,项目名称:izurit,代码行数:101,代码来源:fileman.php

示例7: SaveFileContent

 function SaveFileContent($abs_path, $strContent)
 {
     $strContent = str_replace("\r\n", "\n", $strContent);
     $file = array();
     $this->ResetException();
     foreach (GetModuleEvents("main", "OnBeforeChangeFile", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array($abs_path, &$strContent)) == false) {
             if (!$this->GetException()) {
                 $this->ThrowException(GetMessage("main_save_file_handler_error", array("#HANDLER#" => $arEvent["TO_NAME"])));
             }
             return false;
         }
     }
     $io = CBXVirtualIo::GetInstance();
     $fileIo = $io->GetFile($abs_path);
     $io->CreateDirectory($fileIo->GetPath());
     if ($fileIo->IsExists()) {
         $file["exists"] = true;
         if (!$fileIo->IsWritable()) {
             $fileIo->MarkWritable();
         }
         $file["size"] = $fileIo->GetFileSize();
     }
     /****************************** QUOTA ******************************/
     if (COption::GetOptionInt("main", "disk_space") > 0) {
         $quota = new CDiskQuota();
         if (false === $quota->checkDiskQuota(array("FILE_SIZE" => intVal(strLen($strContent) - intVal($file["size"]))))) {
             $this->ThrowException($quota->LAST_ERROR, "BAD_QUOTA");
             return false;
         }
     }
     /****************************** QUOTA ******************************/
     if ($fileIo->PutContents($strContent)) {
         $fileIo->MarkWritable();
     } else {
         if ($file["exists"]) {
             $this->ThrowException(GetMessage("MAIN_FILE_NOT_CREATE"), "FILE_NOT_CREATE");
         } else {
             $this->ThrowException(GetMessage("MAIN_FILE_NOT_OPENED"), "FILE_NOT_OPEN");
         }
         return false;
     }
     bx_accelerator_reset();
     $site = CSite::GetSiteByFullPath($abs_path);
     $DOC_ROOT = CSite::GetSiteDocRoot($site);
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         //Fix for name case under Windows
         $abs_path = strtolower($abs_path);
         $DOC_ROOT = strtolower($DOC_ROOT);
     }
     if (strpos($abs_path, $DOC_ROOT) === 0 && $site !== false) {
         $DOC_ROOT = rtrim($DOC_ROOT, "/\\");
         $path = "/" . ltrim(substr($abs_path, strlen($DOC_ROOT)), "/\\");
         foreach (GetModuleEvents("main", "OnChangeFile", true) as $arEvent) {
             ExecuteModuleEventEx($arEvent, array($path, $site));
         }
     }
     /****************************** QUOTA ******************************/
     if (COption::GetOptionInt("main", "disk_space") > 0) {
         $fs = $fileIo->GetFileSize();
         CDiskQuota::updateDiskQuota("files", intVal($fs - intVal($file["size"])), "update");
     }
     /****************************** QUOTA ******************************/
     return true;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:65,代码来源:main.php

示例8: writeFile

	/**
	 * Creates cache file
	 * Old Html Cache
	 * @param string $file_name
	 * @param string $content
	 */
	public static function writeFile($file_name, $content)
	{
		global $USER;
		if(is_object($USER) && $USER->IsAuthorized())
			return;

		$content_len = function_exists('mb_strlen')? mb_strlen($content, 'latin1'): strlen($content);
		if($content_len <= 0)
			return;

		$arHTMLPagesOptions = self::getOptions();

		//Let's be pessimists
		$bQuota = false;

		if(class_exists("cdiskquota"))
		{
			$quota = new CDiskQuota();
			if($quota->checkDiskQuota(array("FILE_SIZE" => $content_len)))
				$bQuota = true;
		}
		else
		{
			$bQuota = true;
		}

		$arStat = self::readStatistic();
		if($arStat)
			$cached_size = $arStat["FILE_SIZE"];
		else
			$cached_size = 0.0;

		$cache_quota = doubleval($arHTMLPagesOptions["~FILE_QUOTA"]);
		if($bQuota && ($cache_quota > 0.0))
		{
			if($cache_quota  < ($cached_size + $content_len))
				$bQuota = false;
		}

		if($bQuota)
		{
			CheckDirPath($file_name);
			$written = 0;
			$tmp_filename = $file_name.md5(mt_rand()).".tmp";
			$file = @fopen($tmp_filename, "wb");
			if($file !== false)
			{
				$written = fwrite($file, $content);
				if($written == $content_len)
				{
					fclose($file);
					if(file_exists($file_name))
						unlink($file_name);
					rename($tmp_filename, $file_name);
					@chmod($file_name, defined("BX_FILE_PERMISSIONS")? BX_FILE_PERMISSIONS: 0664);
					if(class_exists("cdiskquota"))
					{
						CDiskQuota::updateDiskQuota("file", $content_len, "copy");
					}
				}
				else
				{
					$written = 0;
					fclose($file);
					if(file_exists($file_name))
						unlink($file_name);
					if(file_exists($tmp_filename))
						unlink($tmp_filename);
				}
			}

			self::writeStatistic(
				0, //hit
				1, //miss
				0, //quota
				0, //posts
				$written //files
			);
		}
		else
		{
			//Fire cleanup
			$bytes = \Bitrix\Main\Data\StaticHtmlFileStorage::deleteRecursive("/");
			if (class_exists("cdiskquota"))
			{
				CDiskQuota::updateDiskQuota("file", $bytes, "delete");
			}

			self::writeStatistic(0, 0, 1, 0, false);
		}
	}
开发者ID:ASDAFF,项目名称:1C_Bitrix_info_site,代码行数:97,代码来源:cache_html.php

示例9: GetMessage

     $strWarning .= GetMessage("FILEMAN_FILEUPLOAD_SIZE_ERROR", array('#FILE_NAME#' => $pathto)) . "\n";
 } elseif (($mess = CFileMan::CheckFileName(str_replace('/', '', $pathto))) !== true) {
     $strWarning .= $mess . ".\n";
 } else {
     if ($io->FileExists($DOC_ROOT . $pathto)) {
         $strWarning .= GetMessage("FILEMAN_FILEUPLOAD_FILE_EXISTS1") . " \"" . $pathto . "\" " . GetMessage("FILEMAN_FILEUPLOAD_FILE_EXISTS2") . ".\n";
     } elseif (!$USER->IsAdmin() && (HasScriptExtension($pathto) || substr(CFileman::GetFileName($pathto), 0, 1) == ".")) {
         $strWarning .= GetMessage("FILEMAN_FILEUPLOAD_PHPERROR") . " \"" . $pathto . "\".\n";
     } else {
         $bQuota = true;
         if (COption::GetOptionInt("main", "disk_space") > 0) {
             $f = $io->GetFile($arFile["tmp_name"]);
             $bQuota = false;
             $size = $f->GetFileSize();
             $quota = new CDiskQuota();
             if ($quota->checkDiskQuota(array("FILE_SIZE" => $size))) {
                 $bQuota = true;
             }
         }
         if ($bQuota) {
             if (!$io->Copy($arFile["tmp_name"], $DOC_ROOT . $pathto)) {
                 $strWarning .= GetMessage("FILEMAN_FILEUPLOAD_FILE_CREATE_ERROR") . " \"" . $pathto . "\"\n";
             } elseif (COption::GetOptionInt("main", "disk_space") > 0) {
                 CDiskQuota::updateDiskQuota("file", $size, "copy");
             }
             $f = $io->GetFile($DOC_ROOT . $pathto);
             $f->MarkWritable();
             $module_id = 'fileman';
             if (COption::GetOptionString($module_id, "log_page", "Y") == "Y") {
                 $res_log['path'] = substr($pathto, 1);
                 CEventLog::Log("content", "FILE_ADD", "main", "", serialize($res_log));
开发者ID:Satariall,项目名称:izurit,代码行数:31,代码来源:fileman_file_upload.php


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