config. its going to be a bitch to deal with later.
$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;
{
$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");
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++;
}
$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";
foreach($res as $row) {
if($row[0] > 0) {
- echo "Tables exist\n";
+ //echo "Tables exist\n";
return;
}
}
$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);';
$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."/../");
+
?>
<html>
<h1>Welcome to GLCAS</h1>
configuration (webconfig)<br>
<li> /var/run/glcas/
<li> /var/lib/glcas/
-<li> <?php echo $WEB_ROOT_FS?>/var/glcas/
+<li> <?php echo $underroot?>/var/glcas/
<br><br>
As root, you must now create one of these directories and change the ownership of the directory to the web owner.
<select name="installdir">
<option value="/var/run/glcas">/var/run/glcas</option>
<option value="/var/lib/glcas">/var/lib/glcas</option>
-<option value="<?php echo $WEB_ROOT_FS?>/var/glcas/"><?php echo $WEB_ROOT_FS?>/var/glcas/</option>
+<option value="<?php echo $underroot?>/var/glcas/"><?php echo $underroot?>/var/glcas/</option>
</select>
<input type="submit" name="Go" value="Go">
$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");
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();
}
function addPackage($url)
{
- $repostore = $this->config->getConfigVar("storagelocation");
+ $repostore = $this->config->getConfig("storagelocation");
if(!isset($_REQUEST["pkgname"])) {
echo "<font color=\"red\">Error: No package name set</font><br>";
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) {
file_put_contents("$repostore/adhoc/$n", $fetfile);
}
- $this->config->setConfigVar("adhocpackages", serialize($pkgs));
+ $this->config->setConfig("adhocpackages", serialize($pkgs));
$this->config->saveConfig();
echo "Done";
{
echo "<h2>Packages</h2>";
- $pkgs = unserialize($this->config->getConfigVar("adhocpackages"));
+ $pkgs = unserialize($this->config->getConfig("adhocpackages"));
echo "<table border=\"1\"><tr><th>Name</th><th>Package Types</th><th>Architecture</th><th>Control</th></tr>";
foreach($pkgs as $key => $var) {
// repo storage location
echo "<h3>Storage</h3><br>";
echo "<form method=\"post\" action=\"?action=setstorage\">";
- $storloc = $this->config->getConfigVar("storagelocation");
+ $storloc = $this->config->getConfig("storagelocation");
echo "<input class=\"storage\" type=\"text\" name=\"storageloc\" value=\"$storloc\" size=\"100\">";
echo "<input type=\"submit\" name=\"Set\" value=\"Set\">";
echo "</form>";
echo "<hr>";
echo "<h3>Proxy Config</h3><br>";
echo "<form method=\"post\" action=\"?action=setproxy\">";
- $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 <input type=\"text\" name=\"proxyaddress\" value=\"$proxyaddress\" size=\"100\"><br>";
echo "Proxy Login <input type=\"text\" name=\"proxylogin\" value=\"$proxylogin\" size=\"100\"><br>";
echo "Proxy Password <input type=\"text\" name=\"proxypassword\" value=\"$proxypass\" size=\"100\"><br>";
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 "<pre>";
- $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 "</pre>";
echo " - Expire time not set, setting to 2 days by default<br>";
$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 "<font color=\"red\">Repo type not set for repo, setting to yum</font><br>";
$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) {
$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;
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"])) {
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");
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);
}
$nconf = serialize($conf);
error_log("freeze repo as $rkey");
- $this->config->setConfigVar("repodata", $nconf);
+ $this->config->setConfig("repodata", $nconf);
$this->config->saveConfig();
}
}
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);
$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();
}
}
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;
$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
function updateRepoApt($repokey)
{
- $repostore = $this->config->getConfigVar("storagelocation");
+ $repostore = $this->config->getConfig("storagelocation");
$repod = $this->getRepo($repokey);
function updateRepoYum($repokey)
{
- $repostore = $this->config->getConfigVar("storagelocation");
+ $repostore = $this->config->getConfig("storagelocation");
$repod = $this->getRepo($repokey);
function getRepo($id)
{
- $uconf = $this->config->getConfigVar("repodata");
+ $uconf = $this->config->getConfig("repodata");
if($uconf !== false) {
$lconf = unserialize($uconf);
return $lconf[$id];
function getRepos()
{
- $uconf = $this->config->getConfigVar("repodata");
+ $uconf = $this->config->getConfig("repodata");
if($uconf !== false) {
return unserialize($uconf);
} else return false;