some config work
[CBFWR.git] / libcbfwr / config.php
index 67c94a5..c0873b5 100644 (file)
@@ -1,2 +1,43 @@
 <?php
+
+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()
+       {
+               global $AM_DAEMON;
+               
+               if($AM_DAEMON) {
+                       $this->config_file = null;
+                       if(file_exists("../var/fw.conf")) {
+                               $this->config_file = realpath("../var/fw.conf");
+                       }
+                       if(file_exists("/var/lib/fwd/fw.conf")) {
+                               $this->config_file = "/var/lib/fwd/fw.conf";
+                       }
+                       
+                       if($this->config_file == null) {
+                               $this->config["status"] = "noconf";
+                               if(is_dir("/var/lib/fwd/")) {
+                                       echo "no config file found. Will use ../var/fw.conf for now\n";
+                                       $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/";
+                               } else {
+                                       echo "No directory where i can create a config, bailing\n";
+                                       exit(0);
+                               }
+                       }
+               } else {
+                       // config comes from shm... we'll get there
+               }       
+       }
+       
+       
+       private $config_file;
+       private $config;
+};
+
 ?>
\ No newline at end of file