fixed a prob with the url matching code
[glcas.git] / plugins / admin.php
index e6dea41..b746ebb 100644 (file)
@@ -4,6 +4,8 @@ error_log("admin loaded");
 
 global $URL_HANDLERS;
 $URL_HANDLERS["admin.*"] = "GLCASAdmin";
+global $CRON_CLASSES;
+$CRON_CLASSES["GLCASAdmin"] = "GLCASAdmin";
 
 class GLCASAdmin {
        function __construct($config)
@@ -46,6 +48,12 @@ class GLCASAdmin {
                GLCASpageBuilder($this, "body");
        }
        
+       function cron()
+       {
+               echo "ADMIN CRON: nothing to see here<br>";
+               // TODO: touch cronstamp file here
+       }
+       
        function body($url)
        {
                // for the main admin body, we hae the following components
@@ -111,7 +119,8 @@ class GLCASAdmin {
                        echo "<tr><td>Other (OS, Updates, etc)</td><td><input type=\"text\" name=\"other\" value=\"$other\"></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>";
-                       echo "<tr><td>Do Initial Update (can take a while)</td><td><input type=\"checkbox\" name=\"initial\" checked></td></tr>";
+                       echo "<tr><td>Do Initial Update (can take a while, but done in background)</td><td><input type=\"checkbox\" name=\"initial\" checked></td></tr>";
+                       echo "<tr><td>Expire time for Meta Data</td><td><input type=\"text\" name=\"expiretime\"> days</td></tr>";
                        echo "<tr><td><input type=\"submit\" name=\"Add\" value=\"Add\"></td></tr>";
                        echo "</table>";
                        echo "</form>";
@@ -132,12 +141,13 @@ class GLCASAdmin {
                $shorturl = $_REQUEST["shorturl"];
                $prefix = $_REQUEST["prefix"];
                $repurl = $_REQUEST["repourl"];
+               $expiretime = $REQUEST["expiretime"];
                $init = false;
                if(isset($_REQUEST["initial"])) $init = true;
                
                
                
-               $repo->addRepo($desc, $OS, $version, $arch, $other, $shorturl, $prefix, $repurl, "YUM", $init);
+               $repo->addRepo($desc, $OS, $version, $arch, $other, $shorturl, $prefix, $repurl, "YUM", $init, $expiretime);
                
                global $WEB_ROOT_FS, $URL_HANDLERS, $BASE_URL;
                header("Location: $BASE_URL/admin/");
@@ -156,6 +166,8 @@ class GLCASAdmin {
        
        function mainBody($url)
        {
+               global $WEB_ROOT_FS, $URL_HANDLERS, $BASE_URL;
+               
                // first, list available repos
                echo "<h3>Repositories</h3>";
                echo "<br><table border=\"1\">";
@@ -179,7 +191,14 @@ class GLCASAdmin {
                        echo "<tr><td>$desc</td><td>$repotype</td><td>$os</td><td>$version</td><td>$arch</td><td>$other</td><td>$prefix</td><td>$shorturl</td>";
                        
                        // get url
-                       echo "<td><a href=\"/asdf/asdf\">Browse</td><td>";
+                       $browseurl = "$BASE_URL/repo/$rkey";
+                       if($shorturl!="-") {
+                               $brurl = $shorturl;
+                               if($prefix != "-") $brurl = "$prefix/$shorturl";
+                               $browseurl = "$BASE_URL/$brurl/";
+                       }
+                       
+                       echo "<td><a href=\"$browseurl\">Browse</td><td>";
                        
                        // Edit
                        echo "<a href=\"?action=editrepo&repo=$rkey\">Edit</a> ";