die(); } elseif ($_REQUEST['action'] == 'restore') { if (!copy($f = DOCUMENT_ROOT.BX_ROOT.'/modules/main/admin/restore.php', DOCUMENT_ROOT.'/restore.php')) RaiseErrorAndDie(GetMessage("MAIN_DUMP_ERR_COPY_FILE").htmlspecialcharsbx($f)); $url = ''; $name = $path.'/'.$_REQUEST['f_id']; if ($BUCKET_ID = intval($_REQUEST['BUCKET_ID'])) { if (CModule::IncludeModule('clouds')) { $obBucket = new CCloudStorageBucket($BUCKET_ID); if ($obBucket->Init()) $url = 'arc_down_url='.htmlspecialcharsbx($obBucket->GetFileSRC(array("URN" => $name))); } } else $url = 'local_arc_name='.htmlspecialcharsbx($name); if ($url) echo '<script>document.location = "/restore.php?Step=1&'.$url.'";</script>'; echo '<script>EndDump();</script>'; die(); } } $DB->Query("UNLOCK TABLES",true); ######### Admin list ####### $arFilterFields = array(); $lAdmin->InitFilter($arFilterFields);
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); } } } } } } }
function GetItems($Params) { global $APPLICATION, $USER; static $checkChildren, $genTmb; if (!isset($checkChildren, $genTmb)) { $checkChildren = COption::GetOptionString("fileman", "file_dialog_check_children", "Y") == 'Y'; $genTmb = COption::GetOptionString("fileman", "file_dialog_gen_thumb", "Y") == 'Y'; } if (strlen($Params["site"]) > 2) { if (!$USER->CanDoOperation('clouds_browse')) { return $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR') . ': ' . GetMessage('BX_FD_ACCESS_DENIED'), 'access_denied'); } if ($Params['operation'] !== 'O') { return $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR') . ': ' . GetMessage('BX_FD_PATH_CORRUPT') . ' [clouds 04]', 'path_corrupt'); } if (!CModule::IncludeModule('clouds')) { return $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR') . ': ' . GetMessage('BX_FD_PATH_CORRUPT') . ' [clouds 01]', 'path_corrupt'); } $obBucket = null; foreach (CCloudStorageBucket::GetAllBuckets() as $arBucket) { if ($arBucket["ACTIVE"] == "Y" && $arBucket["BUCKET"] === $Params["site"]) { $obBucket = new CCloudStorageBucket($arBucket["ID"]); } } if (!$obBucket) { return $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR') . ': ' . GetMessage('BX_FD_PATH_CORRUPT') . ' [clouds 02]', 'path_corrupt'); } if (!$obBucket->Init()) { return $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR') . ': ' . GetMessage('BX_FD_PATH_CORRUPT') . ' [clouds 03]', 'path_corrupt'); } $path = preg_replace("#[\\\\\\/]+#", "/", "/" . $APPLICATION->UnJSEscape($Params['path'])); $path_js = $path == "" ? "/" : addslashes(htmlspecialcharsex($path)); $path_js = str_replace("//", "/", $path_js); $arFiles = $obBucket->ListFiles($path); if (!is_array($arFiles)) { return $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR') . ': ' . GetMessage('BX_FD_PATH_CORRUPT') . ' [clouds 05]', 'path_corrupt'); } ?> arFDDirs['<?php echo $path_js; ?> '] = []; arFDFiles['<?php echo $path_js; ?> '] = []; <?php foreach ($arFiles["dir"] as $ind => $dir) { ?> arFDDirs['<?php echo $path_js; ?> '][<?php echo $ind; ?> ] = { name : '<?php echo CUtil::JSEscape($dir); ?> ', path : '<?php echo CUtil::JSEscape(preg_replace("#[\\\\\\/]+#", "/", $path . "/" . $dir)); ?> ', empty: false, permission : {del : false, ren : false}, date : '', timestamp : '', size : 0 }; <?php } if ($Params['getFiles']) { foreach ($arFiles['file'] as $ind => $file) { ?> arFDFiles['<?php echo $path_js; ?> '][<?php echo $ind; ?> ] = { name : '<?php echo CUtil::JSEscape($file); ?> ', path : '<?php echo CUtil::JSEscape($obBucket->GetFileSRC($path . "/" . $file)); ?> ', permission : {del : false, ren : false}, date : '', timestamp : '', size : '<?php echo $arFiles["file_size"][$ind]; ?> ' }; <?php } } ?> arFDPermission['<?php echo $path_js; ?> '] = { new_folder : false, upload : false }; <?php return; } $io = CBXVirtualIo::GetInstance(); $site = $Params['site']; $path = $io->CombinePath("/", $APPLICATION->UnJSEscape($Params['path'])); $path_js = $path == "" ? "/" : addslashes(htmlspecialcharsex($path)); $path_js = str_replace("//", "/", $path_js); $bCheckEmpty = $Params['bCheckEmpty']; $rootPath = CSite::GetSiteDocRoot($site); if (!$io->FileExists($rootPath . $path) && !$io->DirectoryExists($rootPath . $path) && $Params['bThrowException'] === true) { return $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR') . ': ' . GetMessage('BX_FD_PATH_CORRUPT'), 'path_corrupt'); } elseif (!$USER->CanDoFileOperation('fm_view_listing', array($site, $path))) { return $APPLICATION->ThrowException(GetMessage('BX_FD_ERROR') . ': ' . GetMessage('BX_FD_ACCESS_DENIED'), 'access_denied'); } $arDirs = array(); $arFiles = array(); GetDirList(array($site, $path), $arDirs, $arFiles, array(), array("name" => "asc"), "DF", false, true); ?> arFDDirs['<?php echo $path_js; ?> '] = []; arFDFiles['<?php echo $path_js; ?> '] = []; <?php $ind = -1; foreach ($arDirs as $Dir) { $name = addslashes(htmlspecialcharsex($Dir["NAME"])); $path_i = addslashes(htmlspecialcharsex($path)) . "/" . $name; $path_i = str_replace("//", "/", $path_i); $arPath_i = array($site, $path_i); if (!$USER->CanDoFileOperation('fm_view_listing', $arPath_i)) { continue; } $ind++; $empty = true; if ($bCheckEmpty) { $dirTmp = $io->GetDirectory($rootPath . $path . '/' . $name); $arDirTmpChildren = $dirTmp->GetChildren(); foreach ($arDirTmpChildren as $child) { if (!$child->IsDirectory()) { continue; } $empty = false; break; } } $perm_del = $USER->CanDoFileOperation('fm_delete_folder', $arPath_i) ? 'true' : 'false'; $perm_ren = $USER->CanDoFileOperation('fm_rename_folder', $arPath_i) ? 'true' : 'false'; ?> arFDDirs['<?php echo $path_js; ?> '][<?php echo $ind; ?> ] = { name : '<?php echo $name; ?> ', path : '<?php echo $path_i; ?> ', empty: <?php echo $empty ? 'true' : 'false'; ?> , permission : {del : <?php echo $perm_del; ?> , ren : <?php echo $perm_ren; ?> }, 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 }
} $showField = '<table cellpadding="0" cellspacing="0" border="0"><tr><td align="left">' . $showFieldIcon . '</td><td align="left"> ' . $showFieldText . '</td></tr></table>'; if ($arRes["TYPE"] === "dir") { $row->AddViewField("FILE_NAME", $showField); $row->AddViewField("FILE_SIZE", ' '); } else { $row->AddViewField("FILE_NAME", $showField); $row->AddViewField("FILE_SIZE", CFile::FormatSize((double) $arRes["SIZE"])); } } $lAdmin->BeginPrologContent(); if (is_object($message)) { echo $message->Show(); } if ($obBucket->Init() && $_GET["file"] === "y") { echo "<script>SelFile('" . CUtil::JSEscape(urldecode($obBucket->GetFileSRC(rtrim($path, "/")))) . "');</script>"; } $lAdmin->EndPrologContent(); $lAdmin->CheckListMode(); $APPLICATION->SetTitle(GetMessage("CLO_STORAGE_SEARCH_TITLE")); require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_popup_admin.php"; ?> <form name="form1" method="GET" action="<?php echo $APPLICATION->GetCurPage(); ?> "> <?php $arFindFields = array("bucket" => GetMessage("CLO_STORAGE_SEARCH_BUCKET"), "path" => GetMessage("CLO_STORAGE_SEARCH_PATH")); $oFilter = new CAdminFilter($sTableID . "_filter", $arFindFields); $oFilter->Begin(); ?>
$row->AddViewField("FILE_NAME", '<a href="' . htmlspecialcharsbx('clouds_file_list.php?lang=' . urlencode(LANGUAGE_ID) . '&bucket=' . urlencode($obBucket->ID) . '&path=' . urlencode(preg_replace('#([^/]+)/$#', '', $path))) . '" class="clouds-up-icon">' . htmlspecialcharsex($arRes["NAME"]) . '</a>'); $row->AddViewField("FILE_SIZE", ' '); } else { $row->AddViewField("FILE_NAME", '<a href="' . htmlspecialcharsbx('clouds_file_list.php?lang=' . urlencode(LANGUAGE_ID) . '&bucket=' . urlencode($obBucket->ID) . '&path=' . urlencode($path . $arRes["NAME"] . '/')) . '" class="clouds-directory-icon">' . htmlspecialcharsex($arRes["NAME"]) . '</a>'); if ($_GET["size"] === "y") { $arDirFiles = $obBucket->ListFiles($path . $arRes["NAME"] . "/", true); $size = array_sum($arDirFiles["file_size"]); $row->AddViewField("FILE_SIZE", CFile::FormatSize((double) $size)); $total_size += $size; $total_count += count($arDirFiles["file"]); } else { $row->AddViewField("FILE_SIZE", ' '); } } } else { $row->AddViewField("FILE_NAME", '<a href="' . htmlspecialcharsbx($obBucket->GetFileSRC(array("URN" => $path . $arRes["NAME"]))) . '">' . htmlspecialcharsex($arRes["NAME"]) . '</a>'); $row->AddViewField("FILE_SIZE", CFile::FormatSize((double) $arRes["SIZE"])); $total_size += $arRes["SIZE"]; $total_count++; } $arActions = array(); if ($USER->CanDoOperation("clouds_upload")) { $arActions[] = array("ICON" => "delete", "TEXT" => GetMessage("CLO_STORAGE_FILE_DELETE"), "ACTION" => "if(confirm('" . GetMessage("CLO_STORAGE_FILE_DELETE_CONF") . "')) " . $lAdmin->ActionDoGroup($arRes["ID"], "delete", 'bucket=' . urlencode($obBucket->ID) . '&path=' . urlencode($path))); } if (!empty($arActions)) { $row->AddActions($arActions); } } if ($_GET["size"] === "y" && is_array($arFiles) && (round($total_size / 1024) != round($obBucket->FILE_SIZE / 1024) || $total_count != $obBucket->FILE_COUNT)) { $obBucket->SetFileCounter($total_size, $total_count); }
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( 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)) { $cache_time = 3600*24*30; // 30 days header("Cache-Control: max-age=".$cache_time); header("Expires: ".gmdate("D, d M Y H:i:s", time()+$cache_time)." GMT"); header_remove("Pragma"); LocalRedirect($to_file, true, "301 Moved Permanently"); } } elseif($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); } } } } } } }
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); } } } } } } }
//1M $arFile = CFile::GetFileArray($ar["ID"]); $filePath = preg_replace("#[\\\\\\/]+#", "/", "/" . $arFile["SUBDIR"] . "/" . $arFile["FILE_NAME"]); $absPath = preg_replace("#[\\\\\\/]+#", "/", $_SERVER["DOCUMENT_ROOT"] . "/" . COption::GetOptionString("main", "upload_dir", "upload") . $filePath); $absPath = $io->GetPhysicalName($absPath); $absTempPath = $absPath . "~"; if (!file_exists($absPath)) { CheckDirPath($absTempPath); $obRequest = new CHTTP(); $obRequest->follow_redirect = true; $obRequest->fp = fopen($absTempPath, "ab"); if (is_resource($obRequest->fp)) { if ($arFile["FILE_SIZE"] > $maxPartSize) { $obRequest->additional_headers["Range"] = sprintf("bytes=%u-%u", $last_file_pos, ($last_file_pos + $maxPartSize > $arFile["FILE_SIZE"] ? $arFile["FILE_SIZE"] : $last_file_pos + $maxPartSize) - 1); } $res = $obRequest->HTTPQuery('GET', $ob->GetFileSRC($arFile)); fclose($obRequest->fp); unset($obRequest->fp); if ($res && ($obRequest->status == 200 || $obRequest->status == 206)) { $bFileMoved = true; if ($arFile["FILE_SIZE"] > $maxPartSize) { $last_file_pos += $maxPartSize; $_SESSION["last_file_pos"] = $last_file_pos; $bNextFile = false; } else { $last_file_pos = $arFile["FILE_SIZE"]; } if (array_key_exists("Content-Range", $obRequest->headers) && preg_match("/(\\d+)-(\\d+)\\/(\\d+)\$/", $obRequest->headers["Content-Range"], $match)) { $FILE_SIZE = $match[3]; } elseif (array_key_exists("Content-Length", $obRequest->headers) && preg_match("/^(\\d+)\$/", $obRequest->headers["Content-Length"], $match) && $match[1] > $maxPartSize) { $FILE_SIZE = 0;