Beispiel #1
0
        $Elem = $arDirContent_t[$i];
        $arPath = array($site, $Elem['ABS_PATH']);
        if ($Elem["TYPE"] == "F" && !$USER->CanDoFileOperation('fm_view_file', $arPath) || $Elem["TYPE"] == "D" && !$USER->CanDoFileOperation('fm_view_listing', $arPath) || $Elem["TYPE"] == "F" && $Elem["NAME"] == ".section.php") {
            continue;
        }
        $arDirContent[] = $Elem;
    }
    unset($arDirContent_t);
} else {
    $arDirContent = array();
    $date_format = CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL"));
    //CUtil::JSPostUnescape(); http://jabber.bx/view.php?id=32552
    if (isset($_POST['sres']) && CFilemanSearch::CheckSearchSess($searchSess)) {
        $searchRes = CFilemanSearch::SetSearchResult($_POST['sres'], $searchSess);
    } else {
        $searchRes = CFilemanSearch::GetSearchResult($searchSess, array($by, $order));
    }
    for ($i = 0, $l = count($searchRes); $i < $l; $i++) {
        $elPath = $searchRes[$i]['path'];
        $fullPath = $_SERVER["DOCUMENT_ROOT"] . $elPath;
        $bIsDir = $io->DirectoryExists($fullPath);
        $arPerm = $APPLICATION->GetFileAccessPermission(array($site, $elPath), $USER->GetUserGroupArray(), true);
        $arEl = array("PATH" => $fullPath, "ABS_PATH" => $elPath, "NAME" => CFileman::GetFileName($elPath), "PERMISSION" => $arPerm[0], "TIMESTAMP" => $searchRes[$i]['time'], "DATE" => date($date_format, $searchRes[$i]['time']), "SIZE" => $bIsDir ? 0 : $searchRes[$i]['size'], "TYPE" => $bIsDir ? "D" : "F");
        if (count($arPerm[1]) > 0) {
            $arEl["PERMISSION_EX"] = $arPerm[1];
        }
        $arDirContent[] = $arEl;
    }
}
$db_DirContent = new CDBResult();
$db_DirContent->InitFromArray($arDirContent);
Beispiel #2
0
    public static function Init($Params)
    {
        global $USER;
        $arWarnings = array();
        if (!$USER->CanDoOperation('fileman_admin_files') && !$USER->CanDoOperation('fileman_admin_folders')) {
            $arWarnings[] = GetMessage('FM_UTIL_ACCESS_DENIED');
        }
        $io = CBXVirtualIo::GetInstance();
        if (count($arWarnings) == 0) {
            $pathTo = trim($Params['copyTo'], " /");
            $site = CFileMan::__CheckSite($_GET['site']);
            $siteTo = $Params['siteTo'] ? $Params['siteTo'] : $site;
            $pathTo = $pathTo == "" ? "/" : "/" . $pathTo . "/";
            $absPathTo = CSite::GetSiteDocRoot($siteTo) . $pathTo;
            $docRootFrom = CSite::GetSiteDocRoot($site);
            if (!$io->DirectoryExists($absPathTo)) {
                // Create destination directory
                $bAccess = $USER->CanDoOperation('fileman_admin_folders') && $USER->CanDoFileOperation('fm_create_new_folder', $pathTo);
                if ($Params['createCopyTo']) {
                    if ($bAccess) {
                        CFileMan::CreateDir(array($siteTo, $pathTo));
                    }
                } else {
                    ?>
<script>window.BXFM_NoCopyToDir = "<?php 
                    echo $bAccess ? "ask_user" : "access_denied";
                    ?>
";</script><?php 
                    return;
                }
            }
            foreach ($Params['arFiles'] as $file) {
                $filePath = $file['path'];
                $caseOption = $Params['caseOption'];
                if ($Params["userCaseLastPath"]) {
                    if ($Params["userCaseLastPath"] != $filePath) {
                        continue;
                    }
                    $caseOption = $Params['userCaseAnswer'];
                    if ($Params["userCaseToAll"]) {
                        $Params['caseOption'] = $caseOption;
                    }
                    $Params["userCaseLastPath"] = false;
                }
                $arPath_i = array($site, $filePath);
                $absPath_i = $docRootFrom . $filePath;
                $bDir_i = $io->DirectoryExists($absPath_i);
                $name_i = CFileman::GetFileName($filePath);
                $strWarn = "";
                // Check if file already exists in destination folder
                if ($io->FileExists($absPathTo . $name_i) || $bDir_i == $io->DirectoryExists($absPathTo . $name_i) && $bDir_i) {
                    $fTmp = $io->GetFile($absPathTo . $name_i);
                    $fTmp1 = $io->GetFile($absPath_i);
                    $altName = CFilemanCopy::GetAltFileName($absPathTo, $name_i, $bDir_i);
                    if ($caseOption == 'ask') {
                        ?>
<script>
						window.BXFM_fileExist = {
							fileOld: {
								name: "<?php 
                        echo CUtil::JSEscape($name_i);
                        ?>
",
								path: "<?php 
                        echo CUtil::JSEscape($pathTo . $name_i);
                        ?>
",
								site: "<?php 
                        echo CUtil::JSEscape($siteTo);
                        ?>
",
								bDir: <?php 
                        echo $bDir_i ? "true" : "false";
                        ?>
,
								size: "<?php 
                        echo $bDir_i ? '-' : CFile::FormatSize($fTmp->GetFileSize());
                        ?>
",
								date: "<?php 
                        echo date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL")), CFilemanUtils::GetModifyTime($absPathTo . $name_i) + CTimeZone::GetOffset());
                        ?>
"
							},
							fileNew: {
								alt_name: "<?php 
                        echo CUtil::JSEscape($altName);
                        ?>
",
								name: "<?php 
                        echo CUtil::JSEscape($name_i);
                        ?>
",
								path: "<?php 
                        echo CUtil::JSEscape($filePath);
                        ?>
",
								site: "<?php 
                        echo CUtil::JSEscape($site);
                        ?>
",
								bDir: <?php 
                        echo $bDir_i ? "true" : "false";
                        ?>
,
								size: "<?php 
                        echo $bDir_i ? '-' : CFile::FormatSize($fTmp1->GetFileSize());
                        ?>
",
								date: "<?php 
                        echo date(CDatabase::DateFormatToPHP(CLang::GetDateFormat("FULL")), CFilemanUtils::GetModifyTime($absPath_i) + CTimeZone::GetOffset());
                        ?>
"
							}
						};
						</script><?php 
                        return;
                    } elseif ($caseOption == 'replace') {
                        // We don't need to replace, couse it's one file
                        if (CFileMan::NormalizePath($pathTo . "/" . $name_i) == $filePath) {
                            continue;
                        }
                        $strWarn = CFileMan::CopyEx($arPath_i, array($siteTo, CFileMan::NormalizePath($pathTo . "/" . $name_i)), !$Params['bCopy'], true);
                        if ($strWarn != "") {
                            $arWarnings[] = $strWarn;
                            $log = false;
                        } elseif ($Params['bSearch'] && $Params['ssess'] && !$Params['bCopy']) {
                            CFilemanSearch::DelFromSearchResult($Params['ssess'], $filePath);
                        }
                    } elseif ($caseOption == 'auto_rename') {
                        $strWarn = CFileMan::CopyEx($arPath_i, array($siteTo, CFileMan::NormalizePath($pathTo . "/" . $altName)), !$Params['bCopy']);
                        if ($strWarn != "") {
                            $arWarnings[] = $strWarn;
                            $log = false;
                        } elseif ($Params['bSearch'] && $Params['ssess'] && !$Params['bCopy']) {
                            CFilemanSearch::DelFromSearchResult($Params['ssess'], $filePath);
                        }
                    } elseif ($caseOption == 'skip') {
                        continue;
                    }
                } else {
                    $strWarn = CFileMan::CopyEx($arPath_i, array($siteTo, CFileMan::NormalizePath($pathTo . "/" . $name_i)), !$Params['bCopy']);
                    if ($strWarn != "") {
                        $arWarnings[] = $strWarn;
                        $log = false;
                    } elseif ($Params['bSearch'] && $Params['ssess'] && !$Params['bCopy']) {
                        CFilemanSearch::DelFromSearchResult($Params['ssess'], $filePath);
                    }
                }
                $module_id = "fileman";
                if (COption::GetOptionString($module_id, "log_page", "Y") == "Y" && $log) {
                    $res_log['copy_to'] = substr($pathTo, 1);
                    $res_log['path'] = substr($filePath, 1);
                    if ($Params['bCopy'] == "copy") {
                        if (!$bDir_i) {
                            CEventLog::Log("content", "FILE_COPY", "fileman", "", serialize($res_log));
                        } else {
                            CEventLog::Log("content", "SECTION_COPY", "fileman", "", serialize($res_log));
                        }
                    } else {
                        if (!$bDir_i) {
                            CEventLog::Log("content", "FILE_MOVE", "fileman", "", serialize($res_log));
                        } else {
                            CEventLog::Log("content", "SECTION_MOVE", "fileman", "", serialize($res_log));
                        }
                    }
                }
            }
        }
        $arWarnings;
        ?>
<script>
		window.BXFM_result = {
			status: "<?php 
        echo count($arWarnings) > 0 ? 'errors' : 'ok';
        ?>
",
			errors: <?php 
        echo count($arWarnings) > 0 ? CUtil::PhpToJSObject($arWarnings) : '{}';
        ?>
		};
		</script><?php 
    }
if (count($files) > 0)
{
	for($i = 0; $i < count($files); $i++)
	{
		if(!$USER->CanDoFileOperation('fm_edit_permission', Array($site, $path."/".$files[$i])))
			$strWarning .= GetMessage("FILEMAN_ACCESS_TO_DENIED")." \"".$files[$i]."\".\n";
		elseif($files[$i] != '.')
			$arFiles[] = $files[$i];
	}
}
else
{
	if ($bSearch)
	{
		$searchRes = CFilemanSearch::GetSearchResult($searchSess);
		for($i = 0, $l = count($searchRes); $i < $l; $i++)
			$arFiles[] = $searchRes[$i]['path'];
	}
	else
	{
		$arD = array();
		$arF = array();

		CFileMan::GetDirList(Array($site, $path), $arD, $arF, array("MIN_PERMISSION" => "X"), array(), "DF");
		foreach ($arD as $dir)
			if($USER->CanDoFileOperation('fm_edit_permission',Array($site, $dir['ABS_PATH'])))
				$arFiles[] = $dir["NAME"];

		foreach ($arF as $file)
			if($USER->CanDoFileOperation('fm_edit_permission',Array($site, $file['ABS_PATH'])))