{ $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); } } else { while(file_exists(DOCUMENT_ROOT.$path.'/'.$item))
$path = (string) $_GET["path"]; $sTableID = "tbl_clouds_file_list"; $lAdmin = new CAdminList($sTableID); $arID = $lAdmin->GroupAction(); $action = isset($_REQUEST["action"]) && is_string($_REQUEST["action"]) ? "{$_REQUEST['action']}" : ""; if ($USER->CanDoOperation("clouds_upload") && is_array($arID)) { foreach ($arID as $ID) { if (strlen($ID) <= 0) { continue; } $ID = urldecode($ID); switch ($action) { case "delete": if (substr($ID, 0, 1) === "F") { $file_size = $obBucket->GetFileSize($path . substr($ID, 1)); if (!$obBucket->DeleteFile($path . substr($ID, 1))) { $e = $APPLICATION->GetException(); if (is_object($e)) { $lAdmin->AddUpdateError($e->GetString(), $ID); } else { $lAdmin->AddUpdateError(GetMessage("CLO_STORAGE_FILE_UNKNOWN_ERROR", array("#CODE#" => "D01")), $ID); } } else { $obBucket->DecFileCounter($file_size); } } elseif (substr($ID, 0, 1) === "D") { $arFiles = $obBucket->ListFiles($path . substr($ID, 1), true); foreach ($arFiles["file"] as $i => $file) { if (!$obBucket->DeleteFile($path . substr($ID, 1) . "/" . $file)) { $e = $APPLICATION->GetException(); if (is_object($e)) {
public static function DeleteDirFilesEx($path) { $path = rtrim($path, "/") . "/"; foreach (CCloudStorageBucket::GetAllBuckets() as $bucket) { $obBucket = new CCloudStorageBucket($bucket["ID"]); if ($obBucket->Init()) { $arCloudFiles = $obBucket->ListFiles($path, true); if (is_array($arCloudFiles["file"])) { foreach ($arCloudFiles["file"] as $i => $file_name) { $tmp = $obBucket->DeleteFile($path . $file_name); if ($tmp) { $obBucket->DecFileCounter($arCloudFiles["file_size"][$i]); } } } } } }
$bFileMoved = true; $bNextFile = true; } } else { //An error occured @unlink($absTempPath); $bFileMoved = false; } } } if ($bNextFile) { $_SESSION["last_file_id"] = $ar["ID"]; $_SESSION["last_file_pos"] = 0.0; if ($bFileMoved) { rename($absTempPath, $absPath); $ob->DeleteFile($filePath); $DB->Query("\n\t\t\t\t\t\t\t\tUPDATE b_file\n\t\t\t\t\t\t\t\tSET HANDLER_ID = null\n\t\t\t\t\t\t\t\tWHERE ID = " . intval($arFile["ID"]) . "\n\t\t\t\t\t\t\t"); CFile::CleanCache($arFile["ID"]); $ob->DecFileCounter((double) $arFile["FILE_SIZE"]); $ob->Update(array("LAST_FILE_ID" => 0)); } } CAdminMessage::ShowMessage(array("TYPE" => "PROGRESS", "MESSAGE" => GetMessage("CLO_STORAGE_LIST_DOWNLOAD_IN_PROGRESS"), "DETAILS" => GetMessage("CLO_STORAGE_LIST_DOWNLOAD_PROGRESS", array("#remain#" => $ar["CNT"] - $bNextFile, "#bytes#" => CFile::FormatSize($ar["FILE_SIZE"] - $last_file_pos))), "HTML" => true, "BUTTONS" => array(array("VALUE" => GetMessage("CLO_STORAGE_LIST_STOP"), "ONCLICK" => 'window.location = \'/bitrix/admin/clouds_storage_list.php?lang=' . LANGUAGE_ID . '\'')))); $bOnTheMove = true; echo '<script>', $lAdmin->ActionDoGroup($ID, "download", "themove=y"), '</script>'; } else { unset($_SESSION["last_file_id"]); unset($_SESSION["last_file_pos"]); CAdminMessage::ShowMessage(array("MESSAGE" => GetMessage("CLO_STORAGE_LIST_DOWNLOAD_DONE"), "TYPE" => "OK", "HTML" => true)); $bOnTheMove = false; }