• Модуль: fileman
  • Путь к файлу: ~/bitrix/modules/fileman/classes/general/fileman_utils.php
  • Класс: CFilemanUtils
  • Вызов: CFilemanUtils::Request
static function Request($action, $site)
{
	global $USER;
	if (!$USER->CanDoOperation('fileman_view_file_structure'))
		return;

	$io = CBXVirtualIo::GetInstance();

	CUtil::JSPostUnescape();
	switch($action)
	{
		case "count":
		case "search":
		case "replace":

			$oSearch = new CFilemanSearch;
			$oSearch->Init(array(
				'lastPath' => isset($_POST['last_path']) ? $_POST['last_path'] : false,
				'bCount' => $action == "count",
				'bReplace' => $action == "replace",
				"fileName" => trim($_POST['file']),
				"phrase" => trim($_POST['phrase']),
				"replacePhrase" => trim($_POST['replace_phrase']),
				"dir" => CFilemanUtils::NormalizePath($_POST['dir']),
				"bSubdir" => $_POST['subdir'],
				"dateFrom" => $_POST['date_from'],
				"dateTo" => $_POST['date_to'],
				"sizeFrom" => intval($_POST['size_from']),
				"sizeTo" => intval($_POST['size_to']),
				"entire" => $_POST['entire'],
				"bCaseSens" => $_POST['case_sens'],
				"bDirsToo" => $_POST['dirs_too'],
				"ssess" => ($_POST['ssess'] ?? null),
				"bInResult" => $_POST['in_result'],
				"site" => CFileMan::__CheckSite($_GET['fu_site'])
				//"site" => $site
			));

			CFileMan::SaveLastPath(CFilemanUtils::NormalizePath($_POST['dir']));
		break;

		case "clean_old":
			CFilemanSearch::CleanOldSearchResult();
		break;

		case "search_save_config":
			CFilemanSearch::SaveConfig(array(
				"advMode" => (boolean) $_POST['adv_mode'],
				"bSubdir" => (boolean) $_POST['subdir'],
				"entire" => (boolean) $_POST['entire'],
				"bCaseSens" => (boolean) $_POST['case_sens'],
				"bDirsToo" => (boolean) $_POST['dirs_too']
			));
		break;

		case "copy_save_config":
			CFilemanCopy::SaveConfig(array(
				"advMode" => (boolean) $_POST['adv_mode'],
				"caseOption" => $_POST['case_option']
			));
		break;

		case "copy":
		case "move":
			$oCopy = new CFilemanCopy;
			$oCopy->Init(array(
				"bCopy" => $action == "copy",
				"caseOption" => $_POST['case_option'],
				"arFiles" => $_POST['files'],
				"copyTo" => $_POST['copy_to'],
				"createCopyTo" => ($_POST['create_copy_to'] ?? null) == "Y",

				"userCaseAnswer" => isset($_POST['uc_answer']) ? $_POST['uc_answer'] : false,
				"userCaseToAll" => isset($_POST['uc_to_all']) ? $_POST['uc_to_all'] : false,
				"userCaseLastPath" => isset($_POST['uc_last_path']) ? $_POST['uc_last_path'] : false,

				"bSearch" => ($_POST['search'] ?? null) == "Y",
				"ssess" => ($_POST['ssess'] ?? null),
				"siteTo" => CFileMan::__CheckSite($_GET['fu_site'])
			));

			CFileMan::SaveLastPath($_POST['copy_to']);
		break;

		case "get_last_pathes":
			?>
			
			IsAdmin())
				$pack_to = RemoveScriptExtension($pack_to);

			//check writing permissions
			if (!$USER->CanDoFileOperation('fm_create_new_file', array($siteTo, $pack_to)))
			{
				?>
				
				
				
				GetPhysicalName($docRootTo.$pack_to)))
			{
				if  (empty($startFile))
				{
					if (($_POST["bPackReplace"] ?? null) != "replace")
					{
						?>
						
						SetOptions(
					array(
						"COMPRESS"			=> true,
						"STEP_TIME"			=> COption::GetOptionString("fileman", "archive_step_time", 30),
						"ADD_PATH"			=> false,
						"REMOVE_PATH"		=> $docRootFrom.$quickPath,
						"CHECK_PERMISSIONS" => $USER->IsAdmin() ? false : true
						)
					);

				$arPackFiles = array();
				foreach ($_POST["files"] as $path2file)
				{
					$arPackFiles[] = $docRootFrom.$path2file['path'];
				}

				@set_time_limit(0);

				$pRes = $packarc->Pack($arPackFiles, $startFile);

				switch ($pRes)
				{
					case IBXArchive::StatusContinue:
					?>
						
					
						
					GetErrors();
					?>
						
					
				
				CanDoFileOperation('fm_create_new_file', array($siteTo, $_POST["packTo"])) ||
			$USER->CanDoFileOperation('fm_create_new_folder', array($siteTo, $_POST["packTo"]))))
			{
				?>
				
				SetOptions
					(
					array(
						"REMOVE_PATH"		=> $docRootFrom,
						"UNPACK_REPLACE"	=> $bReplaceFiles,
						"CHECK_PERMISSIONS" => $USER->IsAdmin() ? false : true
						)
					);

				$uRes = $arc->Unpack($docRootTo.$pack_to);

				if (!$uRes)
				{
					$uErrors = $arc->GetErrors();
				?>