X-Git-Url: http://git.pjr.cc/?a=blobdiff_plain;f=plugins%2Fadmin.php;h=56d86ddb8aae653e9126cfd85ec49d4f63c54dec;hb=c9cd2c7a60256b5d5d82610424c48706695bad5d;hp=4a99fb74a15a4b0c173f9170e6a562ceb8322baa;hpb=fc40a152c4238a9208086bb1203add8322861675;p=glcas.git
diff --git a/plugins/admin.php b/plugins/admin.php
index 4a99fb7..56d86dd 100644
--- a/plugins/admin.php
+++ b/plugins/admin.php
@@ -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)
@@ -28,6 +30,9 @@ class GLCASAdmin {
GLCASpageBuilder($this,"doRepoNextForm");
return;
break;
+ case "addrepoapt":
+ GLCASpageBuilder($this,"doAddRepoApt");
+ return;
case "addrepoyum":
GLCASpageBuilder($this,"doAddRepoYum");
return;
@@ -39,6 +44,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 +55,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 +97,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 +136,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 +148,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"]; @@ -112,14 +237,52 @@ 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) { @@ -148,6 +311,8 @@ class GLCASAdmin { function doUpdateRepo($url) { $rkey = $_REQUEST["repo"]; + + error_log("would update for repo"); $repo = new GLCASRepo($this->config); @@ -178,9 +343,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 " |