+++ /dev/null
-<?php
-
-class GLCASConfig {
-
- function __construct()
- {
- $this->configPath = "";
- $this->config = "";
- }
-
- function loadConfig($configpath)
- {
- error_log("loadConfig $configpath");
- $this->configPath = $configpath;
- $flt = file_get_contents($configpath);
- $this->config = unserialize(base64_decode($flt));
-
-
- }
-
- function getConfigVar($var)
- {
- if(isset($this->config["$var"])) {
- return $this->config["$var"];
- } else return false;
- }
-
- function setConfigVar($var, $value)
- {
- if(is_array($this->config)) {
- foreach($this->config as $vkey => $val) {
- if($vkey == "$var") {
- error_log("reset config of $var to $value");
- $this->config[$var] = $value;
- return true;
- }
- }
- } else error_log("config isnt array");
-
- // otherwise, set it
- error_log("set config of $var to $value");
- $this->config[$var] = $value;
-
- }
-
- function delConfigVar($var)
- {
- if(is_array($this->config)) {
- foreach($this->config as $vkey => $val) {
- if($vkey == "$var") {
- error_log("remove config of $var to $value");
- unset($this->config[$var]);
- return true;
- }
- }
- } else error_log("config isnt array");
- }
-
- function saveConfig()
- {
- file_put_contents($this->configPath, base64_encode(serialize($this->config)));
- }
-
- function debug()
- {
- echo "<pre>";
- echo "path: ".$this->configPath."\n";
- print_r($this->config);
- echo "</pre>";
- }
-
- private $configPath;
- private $config;
-
-}
-
-function glcas_getWebConfigPath()
-{
- global $WEB_ROOT_FS, $URL_HANDLERS, $BASE_URL;
-
- // if you wish to add more places to find webconfig, add them here.
- $configpath = false;
- if(file_exists($WEB_ROOT_FS."/../var/glcas/webconfig")) return realpath($WEB_ROOT_FS."/../var/glcas/webconfig");
- if(file_exists("/var/lib/glcas/webconfig")) return realpath("/var/lib/glcas/webconfig");
- if(file_exists("/var/run/glcas/webconfig")) return realpath("/var/run/glcas/webconfig");
-
- return $configpath;
- //return false;
-}
-
-
-?>
\ No newline at end of file