From 4d1b4e223712e42cc573f156bcca870c1fdcc983 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Thu, 13 Aug 2015 08:57:38 +0100 Subject: [PATCH] Can now get branch over FTP Include new FTP lib and if we have FTP site params available connect over FTP as the list to show --- lib/get-branch.php | 72 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 10 deletions(-) diff --git a/lib/get-branch.php b/lib/get-branch.php index 95ce162..32ef197 100644 --- a/lib/get-branch.php +++ b/lib/get-branch.php @@ -2,6 +2,7 @@ if (!isset($ICEcoder['root'])) { include("headers.php"); include("settings.php"); + include("ftp-control.php"); } if (!$_SESSION['loggedIn']) { @@ -26,7 +27,7 @@ $t = $text['get-branch']; getPathname(), $b->getPathname()); @@ -120,19 +121,48 @@ $location = str_replace("|","/",$_GET['location']); if ($location=="/") {$location = "";}; $dirArray = $filesArray = $finalArray = array(); -$finalArray = scanDir($scanDir.$location); + +// Get dir/file list over FTP +if (isset($ftpSite)) { + // Establish connection, result, maybe use pasv and alert error if no good connection + $ftpConn = ftp_connect($ftpHost); + $ftpLogin = ftp_login($ftpConn, $ftpUser, $ftpPass); + if ($ftpPasv) { + ftp_pasv($ftpConn, true); + } + if (!$ftpConn || !$ftpLogin) { + die(''); + exit; + } + // Get our simple and detailed lists and close the FTP connection + $ftpList = ftpGetList($ftpConn, $root.$location); + $finalArray = $ftpList['simpleList']; + $ftpItems = $ftpList['detailedList']; + ftp_close($ftpConn); +// or get local list +} else { + $finalArray = scanDir($scanDir.$location); +} + foreach($finalArray as $entry) { $canAdd = true; for ($i=0;$i        ".xssClean(basename($fileFolderName),"html")." "; - $thisPermVal = $serverType=="Linux" ? substr(sprintf('%o', fileperms($docRoot.$iceRoot.$fileFolderName)), -3) : ''; + if (!isset($ftpSite)) { + $thisPermVal = $serverType=="Linux" ? 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; + // 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; + // 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; + } $permColors = $thisPermVal == 777 ? 'background: #800; color: #eee' : 'color: #888'; echo ''; echo $thisPermVal; @@ -170,7 +222,7 @@ for ($i=0;$i'; -if ($_SESSION['githubDiff']) { +if (!isset($ftpSite) && $_SESSION['githubDiff']) { // Show the loading screen until we're done comparing files with GitHub echo ""; $i=0; @@ -409,7 +461,7 @@ if ($_SESSION['githubDiff']) { // If we're not in githubDiff mode, show files here if (folderContent.indexOf('-1 || folderContent.indexOf('-1) { - + } else {