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 function Init($Params)
    {
        $this->maxFileOpenSize = 1024 * COption::GetOptionString("fileman", "search_max_open_file_size", 1024);
        $this->maxResultCount = COption::GetOptionString("fileman", "search_max_res_count", false);
        $this->startTime = time();
        $this->Params = $Params;
        $this->Result = array();
        $this->docRoot = CSite::GetSiteDocRoot($Params['site']);
        $this->bSkip = $this->Params['lastPath'] ? true : false;
        if ($this->bSkip) {
            $this->Params['lastPath'] = Rel2Abs("/", $this->Params['lastPath']);
            $this->Params['lastPath'] = $this->docRoot . $this->Params['lastPath'];
        }
        $this->sSess = $this->Params['ssess'] ? $this->Params['ssess'] : false;
        $this->bReplace = $this->Params['bReplace'] && strlen($this->Params['phrase']) > 0;
        if ($this->bReplace) {
            $this->Params['bDirsToo'] = false;
        }
        $bSuccess = false;
        $bBreak = false;
        $nextPath = '';
        // Search in results of the previous search
        if ($this->Params['bInResult']) {
            $searchRes = CFilemanSearch::GetSearchResult($this->Params['ssess'], array('id', 'asc'));
            for ($i = 0, $l = count($searchRes); $i < $l; $i++) {
                $path = $this->docRoot . $searchRes[$i]['path'];
                if ($this->CheckBreak()) {
                    $bBreak = true;
                    $nextPath = $path;
                    break;
                } else {
                    $this->Search($path);
                }
            }
            $bSuccess = true;
            $bStoped = false;
        } else {
            $path = Rel2Abs("/", $this->Params["dir"]);
            $path = $this->docRoot . $path;
            $oDir = new CFilemanUtilDir($path, array('obj' => $this, 'site' => $Params['site'], 'callBack' => "Search", 'checkBreak' => "CheckBreak", 'checkSubdirs' => $this->Params["bSubdir"]));
            $bSuccess = $oDir->Start();
            $bBreak = $oDir->bBreak;
            $nextPath = $oDir->nextPath;
            $bStoped = $oDir->bStoped;
            if ($bStoped) {
                $bBreak = false;
            }
        }
        if ($bSuccess) {
            ?>
<script>
<?php 
            if ($bBreak) {
                // Execution breaks on timeout
                ?>
	window.fmsBtimeout = true;
	window.fmsLastPath = '<?php 
                echo CUtil::JSEscape(CFilemanUtils::TrimPath($nextPath, $this->docRoot));
                ?>
';
<?php 
            } else {
                ?>
	window.fmsBtimeout = false;
<?php 
            }
            ?>

<?php 
            if ($bStoped) {
                // Execution breaks on timeout
                ?>
	window.fmsBstoped = true;
<?php 
            } else {
                ?>
	window.fmsBstoped = false;
<?php 
            }
            ?>

<?php 
            if ($this->Params['bCount']) {
                ?>
	window.fmsResult = <?php 
                echo count($this->Result);
                ?>
;
<?php 
            } else {
                ?>
	window.fmsResult = <?php 
                echo CUtil::PhpToJSObject($this->Result);
                ?>
;
<?php 
            }
            ?>
</script>
<?php 
        } else {
            ?>
<script>
<?php 
            if ($this->Params['bCount']) {
                ?>
	window.fmsResult = 0;
<?php 
            } else {
                ?>
	window.fmsResult = [];
<?php 
            }
            ?>
</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'])))