X-Git-Url: http://git.pjr.cc/?a=blobdiff_plain;f=plugins%2Fadmin.php;h=56d86ddb8aae653e9126cfd85ec49d4f63c54dec;hb=c9cd2c7a60256b5d5d82610424c48706695bad5d;hp=e6dea41268f81c3485a393b97b1be8e43201f3ed;hpb=b0651723ae8487b4791b01cfbdcebf2d76907bed;p=glcas.git
diff --git a/plugins/admin.php b/plugins/admin.php
index e6dea41..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"]; @@ -111,14 +236,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 +296,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 +311,8 @@ class GLCASAdmin { function doUpdateRepo($url) { $rkey = $_REQUEST["repo"]; + + error_log("would update for repo"); $repo = new GLCASRepo($this->config); @@ -156,6 +323,8 @@ class GLCASAdmin { function mainBody($url) { + global $WEB_ROOT_FS, $URL_HANDLERS, $BASE_URL; + // first, list available repos echo "
$desc | $repotype | $os | $version | $arch | $other | $prefix | $shorturl | "; + if($frozen) { + $bgcol = "bgcolor=\"#bbbbff\""; + $frotext = "Unfreeze"; + } else { + $frotext = "Freeze"; + $bgcol = ""; + } + echo "|||||||
$desc | $repotype | $os | $version | $arch | $other | $prefix | $shorturl | "; // get url - echo "Browse | "; + $browseurl = "$BASE_URL/repo/$rkey"; + if($shorturl!="-") { + $brurl = $shorturl; + if($prefix != "-") $brurl = "$prefix/$shorturl"; + $browseurl = "$BASE_URL/$brurl/"; + } + + echo " | Browse | ";
// Edit
echo "Edit ";
// update
- echo "Update ";
+ if(!$frozen) echo "Update ";
// freeze
- echo "Freeze ";
+ echo "$frotext ";
// deactivate
echo "Disable ";
// clean
@@ -204,14 +389,13 @@ class GLCASAdmin {
//echo "";
// wrap all this in a table
- echo "
Storage";
}
"; echo " |