added a sort to printDir() so it prints dirs first, file second and
authorpaulr <me@pjr.cc>
Thu, 4 Aug 2011 16:42:23 +0000 (02:42 +1000)
committerpaulr <me@pjr.cc>
Thu, 4 Aug 2011 16:42:23 +0000 (02:42 +1000)
sorts both alphabetically.

plugins/admin.php
plugins/repo.php

index 2b1d1ef..b37850a 100644 (file)
@@ -163,10 +163,11 @@ class GLCASAdmin {
                        echo "<form method=\"post\" action=\"?action=addrepoapt\">";
                        echo "<input type=\"hidden\" name=\"repourl\" value=\"$repourl\">";
                        echo "<input type=\"hidden\" name=\"distro\" value=\"$distros\">";
-                       echo "<input type=\"hidden\" name=\"version\" value=\"$version\">";
                        echo "<input type=\"hidden\" name=\"arch\" value=\"$archs\">";
                        echo "<table>";
                        echo "<tr><td>Description</td><td><input type=\"text\" name=\"desc\" value=\"APT Repo$extratext\"></td>";
+                       // 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 "<tr><td>Provides</td><td><textarea name=\"provides\" rows=\"".$glt["nrepos"]."\" cols=\"100\">$provides</textarea></td></tr>";
                        echo "<tr><td>Short URL</td><td><input type=\"text\" name=\"shorturl\"></td></tr>";
                        echo "<tr><td>URL Prefix (blank for none)</td><td><input type=\"text\" name=\"prefix\"></td></tr>";
@@ -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 <select name=\"repotype\">";
                        echo "<option value=\"yumbase\">YUM (Base URL)</option>";
                        echo "<option value=\"yummirrorlist\">YUM (Mirror List) - not implemented</option>";
-                       echo "<option value=\"apt\">APT - not implemented</option>";
+                       echo "<option value=\"apt\">APT</option>";
                        echo "</select><br>";
                echo "URL <input type=\"text\" name=\"repourl\"><br>";
                echo "<input type=\"submit\" name=\"Add\" value=\"Add\"><br>";
index 55eaed3..c201756 100644 (file)
@@ -35,21 +35,27 @@ class GLCASRepo {
                                $this->config->saveConfig();                            
                        }
                        
-                       if(file_exists("$repostore/$rkey/repodata/repoupdate.lock")) {
-                               echo " - <font color=\"red\">Repo locked for update</font><br>";
+                       if(!isset($repo["repotype"])) {
+                               echo "<font color=\"red\">Repo type not set for repo</font><br>";
+                       } else if($repo["repotype"] == "YUM") {
+                               if(file_exists("$repostore/$rkey/repodata/repoupdate.lock")) {
+                                       echo " - <font color=\"red\">Repo locked for update</font><br>";
+                                       
+                               }
                                
-                       }
-                       
-                       // 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<br>";
-                       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 " - <font color=\"green\">updating repo</font><br>";
-                               $this->updateRepo($rkey);
-                       } else {
-                               echo " - not updating repo<br>";
+                               // 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<br>";
+                               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 " - <font color=\"green\">updating repo</font><br>";
+                                       $this->updateRepo($rkey);
+                               } else {
+                                       echo " - not updating repo<br>";
+                               }
+                       } else if($repo["repotype"] == "APT") {
+                               echo "<font color=\"red\">I have no idea how to spawn an update of an APT repo - apt is crap</font><br>";
                        }
                }
        }
@@ -745,18 +751,32 @@ class GLCASRepo {
                        $content .= "<html><head><title>Index of $localfile</title></head><body><h1>Index of $localfile</h1>";
                        $content .= "<table>";
                        $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 .= "<tr><td><img src=\"$icon\"></td><td><a href=\"$uri/$file\">$file</a></td><td>$fsize</td></tr>";
                                }
                        }
+                       if(isset($dirlist)) {
+                               sort($dirlist);
+                               foreach($dirlist as $dirs) {
+                                       $icon = "/icons/folder.png";
+                                       $content .= "<tr><td><img src=\"$icon\"></td><td><a href=\"$uri/$dirs\">$dirs</a></td><td></td></tr>";
+                               }
+                       }
+                       if(isset($filelist)) {
+                               sort($filelist);
+                               foreach($filelist as $files) {
+                                       $fsize = filesize("$dir/$files");
+                                       $icon = "/icons/text.png";
+                                       $content .= "<tr><td><img src=\"$icon\"></td><td><a href=\"$uri/$files\">$files</a></td><td>$fsize</td></tr>";
+                               }                               
+                       }
                        $content .= "</table></body></html>";
                                
                        GLCASpageBuilder(null, null, $content);