From ed9290dd166f5b83501d1876f552575d4d7bab33 Mon Sep 17 00:00:00 2001 From: mattpass Date: Fri, 8 May 2020 09:32:55 +0100 Subject: [PATCH] get-branch.php tidy --- lib/get-branch.php | 120 +++++++++++++++++++++++---------------------- 1 file changed, 62 insertions(+), 58 deletions(-) diff --git a/lib/get-branch.php b/lib/get-branch.php index dc7aa12..61806be 100644 --- a/lib/get-branch.php +++ b/lib/get-branch.php @@ -1,8 +1,8 @@ '; -$location = str_replace("|","/",xssClean($_GET['location'],"html")); -if ($location=="/") {$location = "";}; +$location = str_replace("|", "/", xssClean($_GET['location'], "html")); +if ("/" === $location) { + $location = ""; +}; -$dirArray = $filesArray = $finalArray = array(); +$dirArray = $filesArray = $finalArray = []; // Get dir/file list over FTP if (isset($ftpSite)) { ftpStart(); // Show user warning if no good connection if (!$ftpConn || !$ftpLogin) { - die(''); + die(''); exit; } // Get our simple and detailed lists and close the FTP connection - $ftpList = ftpGetList($ftpConn, $ftpRoot.$location); + $ftpList = ftpGetList($ftpConn, $ftpRoot . $location); $finalArray = $ftpList['simpleList']; $ftpItems = $ftpList['detailedList']; ftpEnd(); // or get local list } else { - $finalArray = scanDir($scanDir.$location); + $finalArray = scanDir($scanDir . $location); } foreach($finalArray as $entry) { $canAdd = true; - for ($i=0;$i\n";} - if ($i==count($finalArray)-1 && isset($_GET['location'])) { - echo "\n"; + if (0 === $i) {echo ""; } - $type == "folder" ? $class = 'pft-directory' : $class = 'pft-file '.strtolower($ext); - $loadParam = $type == "folder" ? "true" : "false"; - echo "
  •         ".xssClean(basename($fileFolderName),"html")." "; if (!isset($ftpSite)) { - $thisPermVal = $serverType=="Linux" ? substr(sprintf('%o', fileperms($docRoot.$iceRoot.$fileFolderName)), -3) : ''; + $thisPermVal = "Linux" === $serverType ? substr(sprintf('%o', fileperms($docRoot . $iceRoot . $fileFolderName)), -3) : ''; } else { // Work out perms value $thisPermVal = 0; $r = $ftpItems[basename($fileFolderName)]['rights']; // Owner - $thisPermVal += substr($r,1,1) == "r" ? 400 : 0; - $thisPermVal += substr($r,2,1) == "w" ? 200 : 0; - $thisPermVal += substr($r,3,1) == "x" ? 100 : 0; + $thisPermVal += "r" === substr($r,1,1) ? 400 : 0; + $thisPermVal += "w" === substr($r,2,1) ? 200 : 0; + $thisPermVal += "x" === substr($r,3,1) ? 100 : 0; // Group - $thisPermVal += substr($r,4,1) == "r" ? 40 : 0; - $thisPermVal += substr($r,5,1) == "w" ? 20 : 0; - $thisPermVal += substr($r,6,1) == "x" ? 10 : 0; + $thisPermVal += "r" === substr($r,4,1) ? 40 : 0; + $thisPermVal += "w" === substr($r,5,1) ? 20 : 0; + $thisPermVal += "x" === substr($r,6,1) ? 10 : 0; // Public - $thisPermVal += substr($r,7,1) == "r" ? 4 : 0; - $thisPermVal += substr($r,8,1) == "w" ? 2 : 0; - $thisPermVal += substr($r,9,1) == "x" ? 1 : 0; + $thisPermVal += "r" === substr($r,7,1) ? 4 : 0; + $thisPermVal += "w" === substr($r,8,1) ? 2 : 0; + $thisPermVal += "x" === substr($r,9,1) ? 1 : 0; } - $permColors = $thisPermVal == 777 ? 'background: #800; color: #eee' : 'color: #888'; - echo ''; + $permColors = 777 === $thisPermVal ? 'background: #800; color: #eee' : 'color: #888'; + echo ''; echo $thisPermVal; echo "
  • \n"; } @@ -129,11 +133,11 @@ for ($i=0;$i'; ?> - \ No newline at end of file +