From e935e20710eff1bcae9da93ead67ba0c4a4a849e Mon Sep 17 00:00:00 2001 From: paulr Date: Fri, 5 Aug 2011 02:42:23 +1000 Subject: [PATCH] added a sort to printDir() so it prints dirs first, file second and sorts both alphabetically. --- plugins/admin.php | 7 +++-- plugins/repo.php | 58 +++++++++++++++++++++++++++++++++++----------------- 2 files changed, 43 insertions(+), 22 deletions(-) diff --git a/plugins/admin.php b/plugins/admin.php index 2b1d1ef..b37850a 100644 --- a/plugins/admin.php +++ b/plugins/admin.php @@ -163,10 +163,11 @@ class GLCASAdmin { echo "
"; echo ""; echo ""; - echo ""; echo ""; echo ""; echo ""; + // TODO change this "provides" bit with a bit that allows us to choose which versions + // of ubuntu will be made available from the ones we found echo ""; echo ""; echo ""; @@ -207,7 +208,7 @@ class GLCASAdmin { $desc = $_REQUEST["desc"]; $OS = $_REQUEST["distro"]; - $version = $_REQUEST["version"]; + $version = $_REQUEST["provides"]; $arch = $_REQUEST["arch"]; $shorturl = $_REQUEST["shorturl"]; $prefix = $_REQUEST["prefix"]; @@ -325,7 +326,7 @@ class GLCASAdmin { echo "Type
"; echo "URL
"; echo "
"; diff --git a/plugins/repo.php b/plugins/repo.php index 55eaed3..c201756 100644 --- a/plugins/repo.php +++ b/plugins/repo.php @@ -35,21 +35,27 @@ class GLCASRepo { $this->config->saveConfig(); } - if(file_exists("$repostore/$rkey/repodata/repoupdate.lock")) { - echo " - Repo locked for update
"; + if(!isset($repo["repotype"])) { + echo "Repo type not set for repo
"; + } else if($repo["repotype"] == "YUM") { + if(file_exists("$repostore/$rkey/repodata/repoupdate.lock")) { + echo " - Repo locked for update
"; + + } - } - - // we still do this next bit, even if its locked because it may be a stray file - echo " - Expire time is ".$repo["expiretime"]." days, checking repo
"; - error_log("checking $repostore/$rkey/repodata/repomd.xml"); - $tdiff = time() - filemtime("$repostore/$rkey/repodata/repomd.xml"); - $maxtdiff = $repo["expiretime"] * 24 * 3600; - if($tdiff > $maxtdiff) { - echo " - updating repo
"; - $this->updateRepo($rkey); - } else { - echo " - not updating repo
"; + // we still do this next bit, even if its locked because it may be a stray file + echo " - Expire time is ".$repo["expiretime"]." days, checking repo
"; + error_log("checking $repostore/$rkey/repodata/repomd.xml"); + $tdiff = time() - filemtime("$repostore/$rkey/repodata/repomd.xml"); + $maxtdiff = $repo["expiretime"] * 24 * 3600; + if($tdiff > $maxtdiff) { + echo " - updating repo
"; + $this->updateRepo($rkey); + } else { + echo " - not updating repo
"; + } + } else if($repo["repotype"] == "APT") { + echo "I have no idea how to spawn an update of an APT repo - apt is crap
"; } } } @@ -745,18 +751,32 @@ class GLCASRepo { $content .= "Index of $localfile

Index of $localfile

"; $content .= "
Description
Provides
Short URL
URL Prefix (blank for none)
"; $dh = opendir($dir); + $dirn = 0; + $filen = 0; while(($file = readdir($dh))!==false) { if($file != "." && $file != "..") { if(is_dir("$dir/$file")) { - $fsize = ""; - $icon = "/icons/folder.png"; + $dirlist[$dirn++] = "$file"; } else { - $fsize = filesize("$dir/$file"); - $icon = "/icons/text.png"; + $filelist[$filen++] = "$file"; } - $content .= ""; } } + if(isset($dirlist)) { + sort($dirlist); + foreach($dirlist as $dirs) { + $icon = "/icons/folder.png"; + $content .= ""; + } + } + if(isset($filelist)) { + sort($filelist); + foreach($filelist as $files) { + $fsize = filesize("$dir/$files"); + $icon = "/icons/text.png"; + $content .= ""; + } + } $content .= "
$file$fsize
$dirs
$files$fsize
"; GLCASpageBuilder(null, null, $content); -- 1.7.0.4