Added a hosts bit
authorpaulr <me@pjr.cc>
Sun, 7 Aug 2011 17:39:18 +0000 (03:39 +1000)
committerpaulr <me@pjr.cc>
Sun, 7 Aug 2011 17:39:18 +0000 (03:39 +1000)
libglcas/web.php
plugins/adhoc.php
plugins/admin.php
plugins/hosts.php [new file with mode: 0644]

index 433b764..5dd6f91 100644 (file)
@@ -32,12 +32,20 @@ class GLCASWeb {
 
 function GLCASMenuBuilder()
 {
-       global $BASE_URL;
+       global $BASE_URL, $MENU_ITEMS;
+       
+       sort($MENU_ITEMS);
        ?>
-<a href="<?php echo $BASE_URL ?>">Home</a>
-<a href="<?php echo $BASE_URL."/admin/"?>">Admin</a>
-<a href="<?php echo $BASE_URL."/adhoc/"?>">Adhoc</a>
+       <table border="1"><tr><th>Menu</th><td>
+<a href="<?php echo $BASE_URL ?>">Home</a></td>
        <?php
+       foreach($MENU_ITEMS as $key => $val) {
+               $link = $val["link"];
+               $name = $val["name"];
+               echo "<td><a href=$link>$name</a></td>";
+       }
+       
+       echo "</table>";
 }
 
 function GLCASMessageBuilder()
index cfffa2e..6df9241 100644 (file)
@@ -4,6 +4,10 @@ error_log("adhoc loaded");
 
 global $URL_HANDLERS;
 $URL_HANDLERS["adhoc.*"] = "GLCASAdhoc";
+global $BASE_URL, $MENU_ITEMS;
+$MENU_ITEMS["20adhoc"]["name"] = "Adhoc Packages";
+$MENU_ITEMS["20adhoc"]["link"] = "$BASE_URL/adhoc";
+
 
 class GLCASAdhoc {
        function __construct($config)
@@ -27,6 +31,10 @@ class GLCASAdhoc {
                                        error_log("in updaterepo");
                                        GLCASpageBuilder($this,"addPackage");
                                        return;
+                               case "deletepkg":
+                                       error_log("in delete pkg");
+                                       GLCASpageBuilder($this, "delPackage");
+                                       return;
                        }
                }
                
@@ -35,6 +43,25 @@ class GLCASAdhoc {
                
        }
        
+       function delPackage($url)
+       {       
+               $repostore = $this->config->getConfigVar("storagelocation");
+               
+               $pkgid = $_REQUEST["pkgid"];
+               
+               $pkgs = unserialize($this->config->getConfigVar("adhocpackages"));
+               
+               if(isset($pkgs[$pkgid])) {
+                       unset($pkgs[$pkgid]);
+                       $this->config->setConfigVar("adhocpackages", serialize($pkgs));
+                       $this->config->saveConfig();
+               }
+               
+               global $WEB_ROOT_FS, $URL_HANDLERS, $BASE_URL;
+               header("Location: $BASE_URL/adhoc/");
+               
+       }
+       
        function addPackage($url)
        {
                $repostore = $this->config->getConfigVar("storagelocation");
@@ -120,20 +147,24 @@ class GLCASAdhoc {
        function mainBody($url)
        {
                echo "<h2>Packages</h2>";
-               
-               $kos = getKnownOSList();
-               
-               echo "<hr>";
-               echo "<h3>Add a Package</h3><br>";
+
                $pkgs = unserialize($this->config->getConfigVar("adhocpackages"));
+               echo "<table border=\"1\"><tr><th>Name</th><th>Package Types</th><th>Architecture</th><th>Control</th></tr>";
+               
                foreach($pkgs as $key => $var) {
                        $name = $var["pkgname"];
                        $arch = $var["arch"];
                        $type = $var["type"];
-                       echo "$key: $name $arch, $type<br>";
+                       echo "<tr><td>$name</td><td>$type</td><td>$arch</td><td>Add another arch <a href=\"?action=deletepkg&pkgid=$key\">Delete</a></td></tr>";
                }
+               echo "<table>";
+               
+               $kos = getKnownOSList();
+               
+               echo "<hr>";
+               echo "<h3>Add a Package</h3><br>";
                echo "<form enctype=\"multipart/form-data\" method=\"post\" action=\"?action=addpackage\">";
-               echo "Name <input type=\"text\" name=\"pkgname\"><br>";
+               echo "Name <input type=\"text\" name=\"pkgname\"> or Add version of <select name=\"origpkg\"></select><br>";
                echo "Arch <select name=\"arch\">";
                foreach($kos["pkgarch"] as $key => $val) {
                        echo "<option value=\"$key\">$val</option>";
@@ -149,6 +180,8 @@ class GLCASAdhoc {
                echo "<input type=\"submit\" name=\"add\" value=\"Add\">";
                echo "</form>";
        }
+       
+       private $config;
 }
 
 ?>
index 56d86dd..c10ce86 100644 (file)
@@ -2,6 +2,10 @@
 
 error_log("admin loaded");
 
+global $BASE_URL, $MENU_ITEMS;
+$MENU_ITEMS["10admin"]["name"] = "Admin";
+$MENU_ITEMS["10admin"]["link"] = "$BASE_URL/admin";
+
 global $URL_HANDLERS;
 $URL_HANDLERS["admin.*"] = "GLCASAdmin";
 global $CRON_CLASSES;
@@ -436,12 +440,25 @@ class GLCASAdmin {
                echo "</td></tr></table>";
                
                // repo storage location
-               echo "<h3>Storage<h3><br>";
+               echo "<h3>Storage</h3><br>";
                echo "<form method=\"post\" action=\"?action=setstorage\">";
                $storloc = $this->config->getConfigVar("storagelocation");
                echo "<input class=\"storage\" type=\"text\" name=\"storageloc\" value=\"$storloc\" size=\"100\">";
                echo "<input type=\"submit\" name=\"Set\" value=\"Set\">";
                echo "</form>";
+               
+               echo "<hr>";
+               echo "<h3>Proxy Config</h3><br>";
+               echo "<form method=\"post\" action=\"?action=setproxy\">";
+               $proxyaddress = $this->config->getConfigVar("proxyaddress");
+               $proxylogin = $this->config->getConfigVar("proxylogin");
+               $proxypass = $this->config->getConfigVar("proxypass");
+               echo "Proxy Address <input type=\"text\" name=\"proxyaddress\" value=\"$proxyaddress\" size=\"100\"><br>";
+               echo "Proxy Login <input type=\"text\" name=\"proxylogin\" value=\"$proxylogin\" size=\"100\"><br>";
+               echo "Proxy Password <input type=\"text\" name=\"proxypassword\" value=\"$proxypass\" size=\"100\"><br>";
+               echo "<input type=\"submit\" name=\"Set\" value=\"Set\">";
+               echo "</form>";
+               
        }
 
        private $config;
diff --git a/plugins/hosts.php b/plugins/hosts.php
new file mode 100644 (file)
index 0000000..a5709a5
--- /dev/null
@@ -0,0 +1,47 @@
+<?php 
+
+error_log("hosts loaded");
+
+global $URL_HANDLERS;
+$URL_HANDLERS["hosts.*"] = "GLCASHosts";
+global $BASE_URL, $MENU_ITEMS;
+$MENU_ITEMS["30hosts"]["name"] = "Known Machines";
+$MENU_ITEMS["30hosts"]["link"] = "$BASE_URL/hosts";
+
+class GLCASHosts {
+       function __construct($config)
+       {
+               $this->config = $config;
+               error_log("constructor for GLCASHosts");
+               
+       }
+       
+       function go($url)
+       {
+               if(isset($_REQUEST["action"])) {
+                       switch($_REQUEST["action"]) {
+                               case "addpackage":
+                                       error_log("in updaterepo");
+                                       GLCASpageBuilder($this,"addPackage");
+                                       return;
+                               case "deletepkg":
+                                       error_log("in delete pkg");
+                                       GLCASpageBuilder($this, "delPackage");
+                                       return;
+                       }
+               }
+               
+               GLCASpageBuilder($this,"mainBody");
+               return;
+               
+       }
+       
+       function mainBody($url)
+       {
+               echo "I am a hosts thingy";
+       }
+       
+       private $config;
+}
+
+?>
\ No newline at end of file