X-Git-Url: http://git.pjr.cc/?p=CBFWR.git;a=blobdiff_plain;f=libcbfwr%2Fconfig.php;h=3c7a54fb5a91cd84042b613254ab0123d6ab7058;hp=7bffc1d886e00aa1647397e9269ca2e46d7c2c68;hb=c184472f1c4206a3bcd76ff8e9d27dc2eb1a4c4c;hpb=9a9f233c40bf09834402491bf657fffa446eeada diff --git a/libcbfwr/config.php b/libcbfwr/config.php index 7bffc1d..3c7a54f 100644 --- a/libcbfwr/config.php +++ b/libcbfwr/config.php @@ -4,11 +4,10 @@ class Config { // here we load a config if we can find it // there are two sides to every class, the fwd side // and the web page site (command line is web for all intents) - function __construct() + function __construct($look_for_config = false) { - global $AM_DAEMON; - if($AM_DAEMON) { + if($look_for_config) { $this->config_file = null; if(file_exists("../var/fw.conf")) { $this->config_file = realpath("../var/fw.conf"); @@ -28,47 +27,18 @@ class Config { $this->config_file = "/var/lib/fwd/fw.conf"; } else if(is_dir("../var/")) { echo "no config file found. Will use ../var/fw.conf for now\n"; - $this->config_file = "../var/"; + $this->config_file = "../var/fw.conf"; } else { echo "No directory where i can create a config, bailing\n"; $this->config["status"] = "nodir"; } } - - - } } - function bootHardware() + function loadConfig($config) { - $this->findHardware(); - - $mycomm = new Comms(); - $mycomm->putConfig($this->config, 1); - - } - - function loadConfig() - { - global $AM_DAEMON; - - if($AM_DAEMON) { - if($this->config["status"] == "conf") { - $this->loadConfigFile($this->config_file); - $this->applyConfig(); - $this->findHardware(); - - $mycomm = new Comms(); - $mycomm->putConfig($this->config); - $this->boot_config = $mycomm->getConfig(1); - } - } else { - $mycomm = new Comms(); - $this->config = $mycomm->getConfig(0); - $this->boot_config = $mycomm->getConfig(1); - - } + $this->config = $config; } function findHardware() @@ -105,11 +75,6 @@ class Config { return $this->config; } - function getBootConfig() - { - return $this->boot_config; - } - function applyConfig() { global $AM_DAEMON; @@ -119,10 +84,21 @@ class Config { return true; } - function loadConfigFile($file) + function mergeConfig($configone, $configtwo) { - global $AM_DAEMON; - if(!$AM_DAEMON) return true; + // yep + } + + function loadConfigFile($file=null) + { + + if($file == null) { + if($this->config["status"] == "nodir") { + return "nodir"; + } else $file = $this->config_file; + } + + if(!file_exists($file)) return "noconf"; $fp = fopen($file, "r"); @@ -351,7 +327,6 @@ class Config { private $config_file; private $config; - private $boot_config; }; ?> \ No newline at end of file