X-Git-Url: http://git.pjr.cc/?a=blobdiff_plain;f=plugins%2Fadmin.php;h=c10ce862aa9304072641639d8cde43fde170ee88;hb=ddd1046cdf03ee9df49543da5a11c804c1498a41;hp=845d857dd8b32039485a91af00b87430dd70cdda;hpb=d180d75c38719089d9ecbb98f6c03a97af0199af;p=glcas.git
diff --git a/plugins/admin.php b/plugins/admin.php
index 845d857..c10ce86 100644
--- a/plugins/admin.php
+++ b/plugins/admin.php
@@ -2,8 +2,14 @@
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;
+$CRON_CLASSES["GLCASAdmin"] = "GLCASAdmin";
class GLCASAdmin {
function __construct($config)
@@ -28,6 +34,9 @@ class GLCASAdmin {
GLCASpageBuilder($this,"doRepoNextForm");
return;
break;
+ case "addrepoapt":
+ GLCASpageBuilder($this,"doAddRepoApt");
+ return;
case "addrepoyum":
GLCASpageBuilder($this,"doAddRepoYum");
return;
@@ -39,6 +48,10 @@ class GLCASAdmin {
error_log("call setstorage");
GLCASpageBuilder($this, "setStorage");
return;
+ case "freezerepo":
+ error_log("call freezerepo");
+ GLCASpageBuilder($this, "freezeRepo");
+ return;
case "scanrepo":
break;
}
@@ -46,6 +59,34 @@ class GLCASAdmin {
GLCASpageBuilder($this, "body");
}
+ function cron()
+ {
+ echo "ADMIN CRON: nothing to see here
";
+ // TODO: touch cronstamp file here
+
+ // make a backup of the config.. but.. errr. how to tell if theres an old backup?
+ // backups will occur... weekly and be called $configpath.DDMMYYYY
+ $configpath = glcas_getWebConfigPath();
+ $basepath = dirname($configpath);
+ echo "ADMIN CRON: backing up config, $configpath, $basepath
";
+ $nowtime = time();
+ $oneday = 3600 * 24; // 1 hour in seconds, by 24 hours
+ for($i = 0; $i < 7; $i ++) {
+ $cdatestr = strftime("%d-%h-%Y", $nowtime - ($oneday*$i));
+ $backupfile = "$configpath.$cdatestr";
+ error_log("checking for backup of config as $backupfile");
+ if(file_exists($backupfile)) {
+ error_log("backupconfig exists as $backupfile, exit");
+ echo "ADMIN CRON: backup of config is $backupfile, created $i days ago, not creating new one
";
+ return;
+ }
+ }
+ $nowdatestr = strftime("%d-%h-%Y");
+ $backupfile = "$configpath.$nowdatestr";
+ copy($configpath, $backupfile);
+ echo "ADMIN CRON: createing backup of config as $backupfile
";
+ }
+
function body($url)
{
// for the main admin body, we hae the following components
@@ -60,6 +101,22 @@ class GLCASAdmin {
$this->mainBody($url);
}
+ function freezeRepo($url)
+ {
+ $repo = $_REQUEST["repo"];
+
+
+ $myRep = new GLCASRepo($this->config);
+
+
+ error_log("called freeze repo on $repo");
+ $myRep->freezeRepo($repo);
+
+ global $WEB_ROOT_FS, $URL_HANDLERS, $BASE_URL;
+ header("Location: $BASE_URL/admin/");
+
+ }
+
function doRemoveRepo($url)
{
$repo = $_REQUEST["repo"];
@@ -83,7 +140,10 @@ class GLCASAdmin {
{
$myRep = new GLCASRepo($this->config);
+ $kos = getKnownOSList();
+
$wasyum = false;
+ $wasapt = false;
if($_REQUEST["repotype"] == "yumbase") {
$glt = $myRep->getRepoDetailsYum($_REQUEST["repourl"]);
$wasyum = true;
@@ -92,8 +152,77 @@ class GLCASAdmin {
$wasyum = true;
} else if($_REQUEST["repotype"] == "apt") {
$glt = $myRep->getRepoDetailsApt($_REQUEST["repourl"]);
+ $wasapt = true;
}
+ if($wasapt) {
+ error_log("in wasapt");
+ $repourl = $_REQUEST["repourl"];
+
+ if($glt === false) {
+ echo "Could not find any apt repository at $repourl
";
+ return;
+ }
+
+ $extratext = "";
+ $provides = "";
+ if($glt["nrepos"] > 0) {
+
+ foreach($glt["knownrepo"] as $key => $val) {
+ $reponame = $kos["apt"][$val];
+ //echo "Fount a repo, $val which is $reponame
";
+ $provides .= "$reponame\n";
+ }
+ $extratext = " for ".$glt["distros"];
+ } else {
+ //echo "Looks like an apt repo, but I cant find any known distro's
";
+ }
+ //$existing_repos["distros"] = "Ubuntu, Debian";
+ //$existing_repos["versions"] = "8.04LTS, 9.10, 10.04LTS, 10.10, 11.04, 11.10";
+ //$existing_repos["arch"] = "x86_64, i386";
+
+
+ $distros = $glt["distros"];
+ $version = $glt["versions"];
+ $archs = $glt["arch"];
+
+ //echo "
"; + //print_r($glt); + //echo ""; + + echo "The joy of apt is that there could be a million distro's under the root of an apt mirror"; + echo "if it doesn't list here, but you know its there, its still usable for glcas"; + echo ""; + return true; + } if($wasyum) { $os = $glt["OS"]; @@ -111,14 +240,53 @@ class GLCASAdmin { echo "
"; + //print_r($_REQUEST); + //echo ""; + + //exit(0); + + $repo->addRepo($desc, $OS, $version, $arch, "-", $shorturl, $prefix, $repurl, "APT", $init, $expiretime, $blocklist); + + // next we need to deal with that "blocked" bit + + global $WEB_ROOT_FS, $URL_HANDLERS, $BASE_URL; + header("Location: $BASE_URL/admin/"); + } function doAddRepoYum($url) { @@ -132,12 +300,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/"); @@ -146,6 +315,8 @@ class GLCASAdmin { function doUpdateRepo($url) { $rkey = $_REQUEST["repo"]; + + error_log("would update for repo"); $repo = new GLCASRepo($this->config); @@ -176,9 +347,18 @@ class GLCASAdmin { $repotype = $rval["repotype"]; $prefix = $rval["prefix"]; $shorturl = $rval["shorturl"]; + if(isset($rval["frozen"])) $frozen = $rval["frozen"]; + else $frozen = false; if($prefix == "") $prefix = "-"; if($shorturl == "") $shorturl = "-"; - echo "
";
+ echo "
"; + echo " | ";
+
+ // now for mirror lists
+ echo "Via Mirrolist - not implemented"; + echo ""; + + + echo " |