From: paulr Date: Mon, 8 Aug 2011 06:47:03 +0000 (+1000) Subject: kinda stubb'ed the old config out for now and tacked it onto the new X-Git-Url: http://git.pjr.cc/?a=commitdiff_plain;h=37b5d51a06265cba25c1c92418223837c6d3ad2b;p=glcas.git kinda stubb'ed the old config out for now and tacked it onto the new config. its going to be a bitch to deal with later. --- diff --git a/libglcas/config.php b/libglcas/config.php index 6498046..499c97b 100644 --- a/libglcas/config.php +++ b/libglcas/config.php @@ -15,7 +15,7 @@ class GLCASConfig { $this->configPath = $configpath; try { - $this->dbobject = new PDO("sqlite:".$this->configPath); + $this->dbobject = new PDO("sqlite:$configpath"); } catch(PDOException $exep) { error_log("execpt on db open"); return false; @@ -36,7 +36,7 @@ class GLCASConfig { { $sql = "select configvar from config where configname='$configname'"; $res = $this->dbobject->query($sql); - $val = null; + $val = false; foreach($res as $row) { $val = $row[0]; error_log("foreach, $val\n"); @@ -53,27 +53,43 @@ class GLCASConfig { return true; } - function addData($configType, $configName, $configVal) + function addData($configType, $configCat, $configName, $configVal) { - $sql = "insert into datatable values (NULL, '$configType', '$configName', '$configVal')"; + $sql = "insert into datatable values (NULL, '$configType', '$configCat', $configName', '$configVal')"; $this->dbobject->query($sql); } - function getData($configType, $configName="") + function saveConfig() + { + // stub function for old config method reverse compatability + } + + function getData($configType, $configCat="", $configName="") { $ret = null; $nret = 0; - if($configName == "") { - $sql = "select data_val,data_name from datatable where data_type='$configType'"; - } else { - $sql = "select data_val from datatable where data_type='$configType' and data_name='$configName'"; + $haveWhere = false; + if($configCat != "") { + $haveWhere = true; + $wheredata = "where data_category='$configCat'"; } + + if($configName != "") { + if($haveWhere) { + $wheredata .= " and data_name='$configName'"; + } else { + $wheredata = "where data_name='$configName'"; + } + } + + $sql = "select data_val,data_category,data_name from datatable $wheredata"; $res = $this->dbobject->query($sql); foreach($res as $row) { $ret[$nret]["val"] = $row[0]; - if($configName == "") $ret[$nret]["name"] = $row[1]; + $ret[$nret]["cat"] = $row[1]; + $ret[$nret]["name"] = $row[2]; $nret++; } @@ -86,7 +102,7 @@ class GLCASConfig { $this->dbobject->query($sql); } - function delAllDAta($configType, $configName) + function delAllDAta($configType, $configCat) { $sql = "delete from datatable where data_type='$configType' and data_name='$configName'"; //echo "sql is $sql\n"; @@ -100,7 +116,7 @@ class GLCASConfig { foreach($res as $row) { if($row[0] > 0) { - echo "Tables exist\n"; + //echo "Tables exist\n"; return; } } @@ -109,7 +125,7 @@ class GLCASConfig { $sql = 'CREATE TABLE "config" ( "configname" TEXT,"configvar" TEXT);'; $this->dbobject->query($sql); - $sql = 'CREATE TABLE "datatable" ("data_id" INTEGER PRIMARY KEY AUTOINCREMENT,"data_type" TEXT,"data_name" TEXT,"data_val" TEXT);'; + $sql = 'CREATE TABLE "datatable" ("data_id" INTEGER PRIMARY KEY AUTOINCREMENT,"data_category" TEXT,"data_type" TEXT,"data_name" TEXT,"data_val" TEXT);'; $this->dbobject->query($sql); $sql = 'CREATE TABLE sqlite_sequence(name,seq);'; diff --git a/libglcas/web.php b/libglcas/web.php index 5dd6f91..96b787e 100644 --- a/libglcas/web.php +++ b/libglcas/web.php @@ -179,6 +179,16 @@ function glcas_startInstaller() $gid = $gid_a["name"]; error_log("user id is $uid, group id is $gid"); + if(isset($_REQUEST["installdir"])) { + $c = new GLCASConfig(); + touch($_REQUEST["installdir"]."/webconfig"); + $c->loadConfig($_REQUEST["installdir"]."/webconfig"); + header("Location: index.php"); + return; + } + + $underroot = realpath($WEB_ROOT_FS."/../"); + ?>

Welcome to GLCAS

@@ -190,7 +200,7 @@ now is a place where i can store my config. I search the following directories f configuration (webconfig)
  • /var/run/glcas/
  • /var/lib/glcas/ -
  • /var/glcas/ +
  • /var/glcas/

    As root, you must now create one of these directories and change the ownership of the directory to the web owner. @@ -201,7 +211,7 @@ Now, tell me where you want me to create the webconfig file:
    diff --git a/plugins/adhoc.php b/plugins/adhoc.php index 6df9241..9bfbb65 100644 --- a/plugins/adhoc.php +++ b/plugins/adhoc.php @@ -15,7 +15,7 @@ class GLCASAdhoc { $this->config = $config; error_log("constructor for GLCASAdhoc"); - $repostore = $this->config->getConfigVar("storagelocation"); + $repostore = $this->config->getConfig("storagelocation"); if(!is_dir("$repostore/adhoc")) { error_log("Creating dir for adhoc component"); mkdir("$repostore/adhoc"); @@ -45,15 +45,15 @@ class GLCASAdhoc { function delPackage($url) { - $repostore = $this->config->getConfigVar("storagelocation"); + $repostore = $this->config->getConfig("storagelocation"); $pkgid = $_REQUEST["pkgid"]; - $pkgs = unserialize($this->config->getConfigVar("adhocpackages")); + $pkgs = unserialize($this->config->getConfig("adhocpackages")); if(isset($pkgs[$pkgid])) { unset($pkgs[$pkgid]); - $this->config->setConfigVar("adhocpackages", serialize($pkgs)); + $this->config->setConfig("adhocpackages", serialize($pkgs)); $this->config->saveConfig(); } @@ -64,7 +64,7 @@ class GLCASAdhoc { function addPackage($url) { - $repostore = $this->config->getConfigVar("storagelocation"); + $repostore = $this->config->getConfig("storagelocation"); if(!isset($_REQUEST["pkgname"])) { echo "Error: No package name set
    "; @@ -108,7 +108,7 @@ class GLCASAdhoc { echo "Got a file named $fname, $lname"; } - $pkgs = unserialize($this->config->getConfigVar("adhocpackages")); + $pkgs = unserialize($this->config->getConfig("adhocpackages")); $n = -1; foreach($pkgs as $key => $var) { @@ -129,7 +129,7 @@ class GLCASAdhoc { file_put_contents("$repostore/adhoc/$n", $fetfile); } - $this->config->setConfigVar("adhocpackages", serialize($pkgs)); + $this->config->setConfig("adhocpackages", serialize($pkgs)); $this->config->saveConfig(); echo "Done"; @@ -148,7 +148,7 @@ class GLCASAdhoc { { echo "

    Packages

    "; - $pkgs = unserialize($this->config->getConfigVar("adhocpackages")); + $pkgs = unserialize($this->config->getConfig("adhocpackages")); echo ""; foreach($pkgs as $key => $var) { diff --git a/plugins/admin.php b/plugins/admin.php index c10ce86..e7dcd14 100644 --- a/plugins/admin.php +++ b/plugins/admin.php @@ -442,7 +442,7 @@ class GLCASAdmin { // repo storage location echo "

    Storage


    "; echo ""; - $storloc = $this->config->getConfigVar("storagelocation"); + $storloc = $this->config->getConfig("storagelocation"); echo ""; echo ""; echo ""; @@ -450,9 +450,9 @@ class GLCASAdmin { echo "
    "; echo "

    Proxy Config


    "; echo ""; - $proxyaddress = $this->config->getConfigVar("proxyaddress"); - $proxylogin = $this->config->getConfigVar("proxylogin"); - $proxypass = $this->config->getConfigVar("proxypass"); + $proxyaddress = $this->config->getConfig("proxyaddress"); + $proxylogin = $this->config->getConfig("proxylogin"); + $proxypass = $this->config->getConfig("proxypass"); echo "Proxy Address
    "; echo "Proxy Login
    "; echo "Proxy Password
    "; diff --git a/plugins/repo.php b/plugins/repo.php index 0f32504..1546e61 100644 --- a/plugins/repo.php +++ b/plugins/repo.php @@ -7,21 +7,22 @@ class GLCASRepo { function __construct($config) { $this->config = $config; - if($this->config->getConfigVar("storagelocation") == false) { + if($this->config->getConfig("storagelocation") == false) { global $WEB_ROOT_FS; $storloc = "$WEB_ROOT_FS/../var/glcas/cache/"; if(!file_exists($storloc)) mkdir($storloc); - $this->config->setConfigVar("storagelocation", realpath($storloc)); - $this->config->saveConfig(); + $this->config->setConfig("storagelocation", realpath($storloc)); error_log("set storage location, $storloc"); } } + + // with the move to the sqlite db, this is going to get painful function cron() { //echo "
    ";
    -		$uconf = unserialize($this->config->getConfigVar("repodata"));
    -		$repostore = $this->config->getConfigVar("storagelocation");
    +		$uconf = unserialize($this->config->getConfig("repodata"));
    +		$repostore = $this->config->getConfig("storagelocation");
     		//print_r($uconf);
     		//echo "
    "; @@ -38,14 +39,14 @@ class GLCASRepo { echo " - Expire time not set, setting to 2 days by default
    "; $uconf[$rkey]["expiretime"] = 2; $repo["expiretime"] = 2; - $this->config->setConfigVar("repodata", serialize($uconf)); + $this->config->setConfig("repodata", serialize($uconf)); $this->config->saveConfig(); } if(!isset($repo["repotype"])) { echo "Repo type not set for repo, setting to yum
    "; $uconf[$rkey]["repotype"] = "YUM"; - $this->config->setConfigVar("repodata", serialize($uconf)); + $this->config->setConfig("repodata", serialize($uconf)); $this->config->saveConfig(); } else if($repo["repotype"] == "YUM") { if($repofrozen) { @@ -153,8 +154,8 @@ class GLCASRepo { $xurl = split("[/,]", $url); // first get the config - $uconf = unserialize($this->config->getConfigVar("repodata")); - $repostore = $this->config->getConfigVar("storagelocation"); + $uconf = unserialize($this->config->getConfig("repodata")); + $repostore = $this->config->getConfig("storagelocation"); // preset matched to -1 $matched = -1; @@ -256,8 +257,8 @@ class GLCASRepo { function serveUpFile($actualfile, $repoid) { - $uconf = unserialize($this->config->getConfigVar("repodata")); - $repostore = $this->config->getConfigVar("storagelocation"); + $uconf = unserialize($this->config->getConfig("repodata")); + $repostore = $this->config->getConfig("storagelocation"); // figure out the range header garbage that centos/redhat send if(isset($_SERVER["HTTP_RANGE"])) { @@ -344,8 +345,8 @@ class GLCASRepo { clearstatcache(); // get the configurations we need - $uconf = unserialize($this->config->getConfigVar("repodata")); - $repostore = $this->config->getConfigVar("storagelocation"); + $uconf = unserialize($this->config->getConfig("repodata")); + $repostore = $this->config->getConfig("storagelocation"); @@ -745,8 +746,8 @@ class GLCASRepo { function freezeRepo($rkey) { - $uconf = $this->config->getConfigVar("repodata"); - $repostore = $this->config->getConfigVar("storagelocation"); + $uconf = $this->config->getConfig("repodata"); + $repostore = $this->config->getConfig("storagelocation"); if($uconf !== false) { $conf = unserialize($uconf); @@ -765,7 +766,7 @@ class GLCASRepo { } $nconf = serialize($conf); error_log("freeze repo as $rkey"); - $this->config->setConfigVar("repodata", $nconf); + $this->config->setConfig("repodata", $nconf); $this->config->saveConfig(); } } @@ -774,8 +775,8 @@ class GLCASRepo { function deleteRepo($rkey) { - $uconf = $this->config->getConfigVar("repodata"); - $repostore = $this->config->getConfigVar("storagelocation"); + $uconf = $this->config->getConfig("repodata"); + $repostore = $this->config->getConfig("storagelocation"); if($uconf !== false) { $conf = unserialize($uconf); @@ -785,7 +786,7 @@ class GLCASRepo { $nconf = serialize($conf); system("rm -rf $repostore/$key"); error_log("remove repo as $rkey"); - $this->config->setConfigVar("repodata", $nconf); + $this->config->setConfig("repodata", $nconf); $this->config->saveConfig(); } } @@ -794,7 +795,7 @@ class GLCASRepo { function addRepo($desc, $os, $version, $arch, $other, $shorturl, $prefix, $repurl, $repotype, $init, $expiretime, $blocklist=null) { - $uconf = $this->config->getConfigVar("repodata"); + $uconf = $this->config->getConfig("repodata"); $cs["desc"] = $desc; $cs["os"] = $os; @@ -825,11 +826,11 @@ class GLCASRepo { $nconf = serialize($conf); error_log("add repo as $ckey"); - $this->config->setConfigVar("repodata", $nconf); + $this->config->setConfig("repodata", $nconf); $this->config->saveConfig(); // now create the base structure in the repo - $repostore = $this->config->getConfigVar("storagelocation"); + $repostore = $this->config->getConfig("storagelocation"); // now call update repo @@ -853,7 +854,7 @@ class GLCASRepo { function updateRepoApt($repokey) { - $repostore = $this->config->getConfigVar("storagelocation"); + $repostore = $this->config->getConfig("storagelocation"); $repod = $this->getRepo($repokey); @@ -882,7 +883,7 @@ class GLCASRepo { function updateRepoYum($repokey) { - $repostore = $this->config->getConfigVar("storagelocation"); + $repostore = $this->config->getConfig("storagelocation"); $repod = $this->getRepo($repokey); @@ -911,7 +912,7 @@ class GLCASRepo { function getRepo($id) { - $uconf = $this->config->getConfigVar("repodata"); + $uconf = $this->config->getConfig("repodata"); if($uconf !== false) { $lconf = unserialize($uconf); return $lconf[$id]; @@ -921,7 +922,7 @@ class GLCASRepo { function getRepos() { - $uconf = $this->config->getConfigVar("repodata"); + $uconf = $this->config->getConfig("repodata"); if($uconf !== false) { return unserialize($uconf); } else return false;
    NamePackage TypesArchitectureControl