Example #1
0
									$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))
						{
							if ($strWarning_tmp = CFileMan::DeleteEx(Array($site, CFileMan::NormalizePath($path."/".$item))))
								$lAdmin->AddGroupError($strWarning_tmp, $ID);

							$item = CTar::getNextName($item);
						}
					}
				}
			break;
			case "rename":
				if (preg_match('#^[a-z0-9\-\._]+$#i',$_REQUEST['name']))
				{
					$arName = ParseFileName($_REQUEST['ID']);
					$new_name = $_REQUEST['name'].'.'.$arName['ext'];

					if ($BUCKET_ID = intval($_REQUEST['BUCKET_ID']))
					{
Example #2
0
 function Remove($Params)
 {
     if (CModule::IncludeModule("fileman")) {
         global $USER, $APPLICATION;
         $io = CBXVirtualIo::GetInstance();
         $path = Rel2Abs("/", $APPLICATION->UnJSEscape($Params['path']));
         $path = CFileMan::SecurePathVar($path);
         $site = $Params['site'];
         $arPath = array($site, $path);
         $DOC_ROOT = CSite::GetSiteDocRoot($site);
         $abs_path = $DOC_ROOT . $path;
         $strWarning = '';
         $type = false;
         if ($io->DirectoryExists($abs_path)) {
             $type = 'folder';
         }
         if ($io->FileExists($abs_path)) {
             $type = 'file';
         }
         //Check access to folder or file
         if (!$type) {
             // Not found
             $strWarning = GetMessage("FD_ELEMENT_NOT_FOUND", array('#PATH#' => addslashes(htmlspecialcharsbx($path))));
         } elseif (!$USER->CanDoFileOperation('fm_delete_' . $type, $arPath)) {
             // Access denied
             $strWarning = GetMessage("ACCESS_DENIED");
         } else {
             // Ok, delete it!
             $strWarning = CFileMan::DeleteEx($path);
         }
     } else {
         $strWarning = GetMessage("BX_FD_NO_FILEMAN");
     }
     self::EchoActionStatus($strWarning);
     if ($strWarning == '') {
         // get parent dir path and load content
         $parPath = substr($path, 0, strrpos($path, '/'));
         self::LoadItems(array('path' => $parPath, 'site' => $site, 'bAddToMenu' => $Params['bAddToMenu'], 'loadRecursively' => false, 'getFiles' => $Params['getFiles']));
     }
 }
Example #3
0
     if (!($USER->CanDoFileOperation('fm_delete_file', $arPath_i) || $USER->CanDoFileOperation('fm_delete_folder', $arPath_i))) {
         break;
     }
     $module_id = "fileman";
     if (COption::GetOptionString($module_id, "log_page", "Y") == "Y") {
         $res_log['file_name'] = $ID;
         $res_log['path'] = substr($path, 1);
         if (is_dir($_SERVER['DOCUMENT_ROOT'] . "/" . $res_log['path'] . "/" . $ID)) {
             $res_log['path'] = empty($res_log['path']) ? $ID : $res_log['path'] . "/" . $ID;
             CEventLog::Log("content", "SECTION_DELETE", "fileman", "", serialize($res_log));
         } else {
             CEventLog::Log("content", "FILE_DELETE", "fileman", "", serialize($res_log));
         }
     }
     @set_time_limit(0);
     $strWarning_tmp = CFileMan::DeleteEx(array($site, CFileMan::NormalizePath($pathEx)));
     // Delete file from search results, stored in db
     if ($bSearch) {
         CFilemanSearch::DelFromSearchResult($searchSess, $pathEx);
     }
     if (strlen($strWarning_tmp) > 0) {
         $lAdmin->AddGroupError($strWarning_tmp, $ID);
     }
     break;
 case "copy":
 case "move":
     if (!($USER->CanDoFileOperation('fm_create_new_file', $arPath_i) || $USER->CanDoFileOperation('fm_create_new_folder', $arPath_i)) || !($USER->CanDoFileOperation('fm_delete_file', $arPath_i) || $USER->CanDoFileOperation('fm_delete_folder', $arPath_i)) && $_REQUEST['action'] == 'move') {
         break;
     }
     if (!CSite::IsDistinctDocRoots() || CFileMan::__CheckSite($copy_to_site) === false) {
         $copy_to_site = $site;
Example #4
0
 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()) {
             //go to recursion
             $strWarning .= CFileMan::CopyEx(array($site_from, $path_from . "/" . $fn), array($site_to, $path_to . "/" . $fn), $bDeleteAfterCopy, $bOverride);
             //back from recursion, in this subfolder all right
             //if($bDeleteAfterCopy) //necessary delete this subfolder
             //	$strWarning .= CFileMan::DeleteDir($path_from."/".$file);
         } else {
             if ($fn == ".access.php") {
                 continue;
             }
             //let's check, if we can to write there
             if (!$USER->CanDoFileOperation('fm_create_new_file', array($site_to, $path_to . "/" . $fn))) {
                 $strWarning .= GetMessage("FILEMAN_FILEMAN_FILE_WRITE_DENY") . " \"" . $path_to . "/" . $fn . "\".\n";
             } elseif (!$USER->CanDoFileOperation('fm_view_file', array($site_from, $path_from . "/" . $fn))) {
                 $strWarning .= GetMessage("FILEMAN_FILEMAN_FILE_READ_DENY") . " \"" . $path_from . "/" . $fn . "\".\n";
             } elseif (!($USER->CanDoOperation('edit_php') || $USER->CanDoFileOperation('fm_lpa', array($site_from, $path_from . "/" . $fn)) || !(HasScriptExtension($fn) || substr($fn, 0, 1) == "."))) {
                 $strWarning .= GetMessage("FILEMAN_FILEMAN_FILE_READ_DENY") . " \"" . $path_from . "/" . $fn . "\".\n";
             } else {
                 if ($io->FileExists($DOC_ROOT_TO . $path_to . "/" . $fn)) {
                     if ($bOverride) {
                         $strWarn = CFileMan::DeleteEx(array($site_to, $path_to . "/" . $fn));
                         if ($strWarn != "") {
                             $strWarning .= $strWarn . "\n";
                         }
                     } else {
                         $strWarning .= GetMessage("FILEMAN_FILEMAN_FILE_WITH_NAME") . " \"" . $path_to . "/" . $fn . "\" " . GetMessage("FILEMAN_FILEMAN_ALREADY_EXISTS") . "!\n";
                     }
                 }
                 if ($strWarning == "") {
                     //it means we can copy, if we found here
                     $APPLICATION->CopyFileAccessPermission(array($site_from, $path_from . "/" . $fn), array($site_to, $path_to . "/" . $fn));
                     if (DEBUG_FILE_MAN) {
                         echo "copy(" . $DOC_ROOT_FROM . $path_from . "/" . $fn . "," . $DOC_ROOT_TO . $path_to . "/" . $fn . ");<br>";
                     }
                     if (!$io->Copy($DOC_ROOT_FROM . $path_from . "/" . $fn, $DOC_ROOT_TO . $path_to . "/" . $fn)) {
                         $strWarning .= GetMessage('FILEMAN_COPY_ERROR', array('#PATH_FROM#' => htmlspecialcharsex($path_from . "/" . $fn), '#PATH_TO#' => htmlspecialcharsex($path_to . "/" . $fn)));
                     }
                     //************************** Quota **************************//
                     if (COption::GetOptionInt("main", "disk_space") > 0) {
                         $f = $io->GetFile($DOC_ROOT_TO . $path_to . "/" . $fn);
                         $quota = new CDiskQuota();
                         $quota->updateDiskQuota("file", $f->GetFileSize(), "copy");
                     }
                     //************************** Quota **************************//
                     if (CModule::IncludeModule("search")) {
                         $site = CSite::GetSiteByFullPath($DOC_ROOT_TO, $path_to . "/" . $fn);
                         CSearch::ReindexFile($path_to . "/" . $fn, $site);
                     }
                     if ($bDeleteAfterCopy && strlen($strWarning) <= 0) {
                         $strWarning .= CFileMan::DeleteFile(array($site_from, $path_from . "/" . $fn));
                     }
                 }
             }
         }
     }
     //we may be need, to delete our initial folder
     if ($bDeleteAfterCopy) {
         $strWarning .= CFileMan::DeleteDir(array($site_from, $path_from));
     }
     return $strWarning;
 }
Example #5
0
$DOC_ROOT = CSite::GetSiteDocRoot($_GET["site"]);

$arOptions = CUserOptions::GetOption("public_structure", "options", array());
if(!isset($arOptions['show_file_info']))
	$arOptions['show_file_info'] = true;

$io = CBXVirtualIo::GetInstance();
// **********************************************
//ajax requests
if($_GET['ajax'] == 'Y')
{
	if($_GET['action'] == 'delfolder' && check_freetrix_sessid() && $bFileman)
	{
		$normPath = $io->CombinePath("/", $_GET["path"]);
		if($normPath <> "")
			$strWarning = CFileMan::DeleteEx(array($_GET["site"], $normPath));
			
		$module_id = "fileman";
		if(COption::GetOptionString($module_id, "log_page", "Y")=="Y")
		{	
			$res_log['path'] = substr($_GET["path"], 1);
			CEventLog::Log(
				"content",                   
				"SECTION_DELETE",
				"main",
				"",
				serialize($res_log)
			);
		}
	}
	elseif(($_GET['action'] == 'copy' || $_GET['action'] == 'move') && check_freetrix_sessid() && $bFileman)