Get a specific dir if treeType is a branch type

Boot user out if not logged in
If the treeType is branch or branchReload, scan the dir at the specific
location, sort into dir and files arrays, nat case sort them and merge.
This is then finalArray and can be used to create the UL list
This commit is contained in:
Matt Pass
2013-02-24 13:53:53 +00:00
parent f03cfcb0e3
commit c49acc9084

View File

@@ -1,4 +1,36 @@
<?php
include_once("lib/settings.php");
if (!$_SESSION['loggedIn']) {
header("Location: ../");
}
// If we're just getting a branch, get that and set as the finalArray
if ($ICEcoder['treeType'] == "branch" || $ICEcoder['treeType'] == "branchReload") {
$scanDir = ($docRoot && $iceRoot) ? $docRoot.$iceRoot : $_SERVER['DOCUMENT_ROOT'];
$location = "";
if (isset($_GET['location'])) {
$location = str_replace("|","/",$_GET['location']);
}
$dirArray = $filesArray = $finalArray = array();
$finalArray = scanDir($scanDir.$location);
foreach($finalArray as $entry) {
$canAdd = true;
for ($i=0;$i<count($_SESSION['bannedFiles']);$i++) {
if(strpos($entry,$_SESSION['bannedFiles'][$i])!==false) {$canAdd = false;}
}
if ($entry != "." && $entry != ".." && $canAdd) {
is_dir($docRoot.$iceRoot."/".$entry)
? array_push($dirArray,"/".$entry)
: array_push($filesArray,"/".$entry);
}
}
natcasesort($dirArray);
natcasesort($filesArray);
$finalArray = array_merge($dirArray,$filesArray);
}
// Finally, we have our ordered list, so display in a UL
$fileAtts = "";
if ($serverType=="Linux") {