{ case "delete": if (preg_match('#^([0-9]+)_(.+)$#', $ID, $regs)) { $BUCKET_ID = $regs[1]; $item = $regs[2]; if ($BUCKET_ID) { if (CModule::IncludeModule('clouds')) { $obBucket = new CCloudStorageBucket($BUCKET_ID); if ($obBucket->Init()) { $name = $path.'/'.$item; while($obBucket->FileExists($name)) { $file_size = $obBucket->GetFileSize($name); if ($obBucket->DeleteFile($name)) $obBucket->DecFileCounter($file_size); $name = CTar::getNextName($name); } $e = $APPLICATION->GetException(); if(is_object($e)) $lAdmin->AddGroupError($e->GetString(), $ID); } else $lAdmin->AddGroupError(GetMessage("MAIN_DUMP_ERR_INIT_CLOUD"), $ID); } }
public static function OnBeforeProlog() { if (defined("BX_CHECK_SHORT_URI") && BX_CHECK_SHORT_URI) { $upload_dir = "/" . trim(COption::GetOptionString("main", "upload_dir", "upload"), "/") . "/"; $request_uri = urldecode($_SERVER["REQUEST_URI"]); $request_uri = CCloudUtil::URLEncode($request_uri, LANG_CHARSET); foreach (CCloudStorageBucket::GetAllBuckets() as $arBucket) { if ($arBucket["ACTIVE"] == "Y") { $obBucket = new CCloudStorageBucket($arBucket["ID"]); if ($obBucket->Init()) { $match = array(); if ($obBucket->FileExists($request_uri)) { if (COption::GetOptionString("clouds", "log_404_errors") === "Y") { CEventLog::Log("WARNING", "CLOUDS_404", "clouds", $_SERVER["REQUEST_URI"], $_SERVER["HTTP_REFERER"]); } LocalRedirect($obBucket->GetFileSRC($request_uri), true); } elseif (strpos($request_uri, $upload_dir) === 0) { $check_url = substr($request_uri, strlen($upload_dir) - 1); if ($obBucket->FileExists($check_url)) { if (COption::GetOptionString("clouds", "log_404_errors") === "Y") { CEventLog::Log("WARNING", "CLOUDS_404", "clouds", $_SERVER["REQUEST_URI"], $_SERVER["HTTP_REFERER"]); } LocalRedirect($obBucket->GetFileSRC($check_url), true); } } elseif (COption::GetOptionString("clouds", "delayed_resize") === "Y" && preg_match("#^(/" . $obBucket->PREFIX . "|)(/resize_cache/.*\$)#", $request_uri, $match)) { session_write_close(); $to_file = $obBucket->GetFileSRC(urldecode($match[2])); if (CCloudStorage::ResizeImageFileCheck($obBucket, $to_file)) { LocalRedirect($to_file, true); } } } } } } }
} } break; case "chunk_upload": require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_js.php"; $strError = ""; $bytes = 0; $fileSize = doubleval($_REQUEST["file_size"]); $tempDir = CTempFile::GetDirectoryName(6, "clouds_ipload"); $absPath = $tempDir . "tmp_name"; if (isset($_REQUEST["file_name"])) { $filePath = $_REQUEST["file_name"]; $filePath = "/" . $_REQUEST["path_to_upload"] . "/" . $filePath; $filePath = preg_replace("#[\\\\\\/]+#", "/", $filePath); if (isset($_REQUEST["chunk_start"]) && $_REQUEST["chunk_start"] == 0) { if ($obBucket->FileExists($filePath)) { $strError = GetMessage("CLO_STORAGE_FILE_EXISTS_ERROR"); } } } if (isset($_REQUEST["chunk_start"])) { CheckDirPath($tempDir); // read contents from the input stream $inputHandler = fopen('php://input', "rb"); // create a temp file where to save data from the input stream $fileHandler = fopen($absPath, "ab"); // save data from the input stream while (!feof($inputHandler)) { fwrite($fileHandler, fread($inputHandler, 1024 * 1024)); } } else {
function FindFileURIByURN($urn, $log_descr = "") { foreach (CCloudStorageBucket::GetAllBuckets() as $bucket) { if ($bucket["ACTIVE"] == "Y") { $obBucket = new CCloudStorageBucket($bucket["ID"]); if ($obBucket->Init() && $obBucket->FileExists($urn)) { $uri = $obBucket->GetFileSRC($urn); if ($log_descr && COption::GetOptionString("clouds", "log_404_errors") === "Y") { CEventLog::Log("WARNING", "CLOUDS_404", "clouds", $uri, $log_descr); } return $uri; } } } return ""; }
function OnBeforeProlog() { if (defined("BX_CHECK_SHORT_URI") && BX_CHECK_SHORT_URI) { $upload_dir = "/" . trim(COption::GetOptionString("main", "upload_dir", "upload"), "/") . "/"; $request_uri = urldecode($_SERVER["REQUEST_URI"]); $request_uri = CCloudUtil::URLEncode($request_uri, LANG_CHARSET); foreach (CCloudStorageBucket::GetAllBuckets() as $arBucket) { if ($arBucket["ACTIVE"] == "Y") { $obBucket = new CCloudStorageBucket($arBucket["ID"]); if ($obBucket->Init()) { if ($obBucket->FileExists($request_uri)) { if (COption::GetOptionString("clouds", "log_404_errors") === "Y") { CEventLog::Log("WARNING", "CLOUDS_404", "clouds", $_SERVER["REQUEST_URI"], $_SERVER["HTTP_REFERER"]); } LocalRedirect($obBucket->GetFileSRC($request_uri), true); } elseif (strpos($request_uri, $upload_dir) === 0) { $check_url = substr($request_uri, strlen($upload_dir) - 1); if ($obBucket->FileExists($check_url)) { if (COption::GetOptionString("clouds", "log_404_errors") === "Y") { CEventLog::Log("WARNING", "CLOUDS_404", "clouds", $_SERVER["REQUEST_URI"], $_SERVER["HTTP_REFERER"]); } LocalRedirect($obBucket->GetFileSRC($check_url), true); } } } } } } }