From 486854e1f39db5dd0fe2f317d2a586dd6ac39124 Mon Sep 17 00:00:00 2001 From: paulr Date: Mon, 8 Aug 2011 03:39:18 +1000 Subject: [PATCH] Added a hosts bit --- libglcas/web.php | 16 ++++++++++++---- plugins/adhoc.php | 47 ++++++++++++++++++++++++++++++++++++++++------- plugins/admin.php | 19 ++++++++++++++++++- plugins/hosts.php | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 117 insertions(+), 12 deletions(-) create mode 100644 plugins/hosts.php diff --git a/libglcas/web.php b/libglcas/web.php index 433b764..5dd6f91 100644 --- a/libglcas/web.php +++ b/libglcas/web.php @@ -32,12 +32,20 @@ class GLCASWeb { function GLCASMenuBuilder() { - global $BASE_URL; + global $BASE_URL, $MENU_ITEMS; + + sort($MENU_ITEMS); ?> -Home -">Admin -">Adhoc + $val) { + $link = $val["link"]; + $name = $val["name"]; + echo ""; + } + + echo "
Menu +Home $name
"; } function GLCASMessageBuilder() diff --git a/plugins/adhoc.php b/plugins/adhoc.php index cfffa2e..6df9241 100644 --- a/plugins/adhoc.php +++ b/plugins/adhoc.php @@ -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 "

Packages

"; - - $kos = getKnownOSList(); - - echo "
"; - echo "

Add a Package


"; + $pkgs = unserialize($this->config->getConfigVar("adhocpackages")); + echo ""; + foreach($pkgs as $key => $var) { $name = $var["pkgname"]; $arch = $var["arch"]; $type = $var["type"]; - echo "$key: $name $arch, $type
"; + echo ""; } + echo "
NamePackage TypesArchitectureControl
$name$type$archAdd another arch Delete
"; + + $kos = getKnownOSList(); + + echo "
"; + echo "

Add a Package


"; echo ""; - echo "Name
"; + echo "Name or Add version of
"; echo "Arch "; echo ""; } + + private $config; } ?> diff --git a/plugins/admin.php b/plugins/admin.php index 56d86dd..c10ce86 100644 --- a/plugins/admin.php +++ b/plugins/admin.php @@ -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 "
"; // repo storage location - echo "

Storage


"; + echo "

Storage


"; echo "
"; $storloc = $this->config->getConfigVar("storagelocation"); echo ""; echo ""; echo "
"; + + echo "
"; + echo "

Proxy Config


"; + echo "
"; + $proxyaddress = $this->config->getConfigVar("proxyaddress"); + $proxylogin = $this->config->getConfigVar("proxylogin"); + $proxypass = $this->config->getConfigVar("proxypass"); + echo "Proxy Address
"; + echo "Proxy Login
"; + echo "Proxy Password
"; + echo ""; + echo "
"; + } private $config; diff --git a/plugins/hosts.php b/plugins/hosts.php new file mode 100644 index 0000000..a5709a5 --- /dev/null +++ b/plugins/hosts.php @@ -0,0 +1,47 @@ +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 -- 1.7.0.4