some config work
[CBFWR.git] / libcbfwr / config.php
1 <?php
2
3 class Config {
4         // here we load a config if we can find it
5         // there are two sides to every class, the fwd side
6         // and the web page site (command line is web for all intents)
7         function __construct()
8         {
9                 global $AM_DAEMON;
10                 
11                 if($AM_DAEMON) {
12                         $this->config_file = null;
13                         if(file_exists("../var/fw.conf")) {
14                                 $this->config_file = realpath("../var/fw.conf");
15                         }
16                         if(file_exists("/var/lib/fwd/fw.conf")) {
17                                 $this->config_file = "/var/lib/fwd/fw.conf";
18                         }
19                         
20                         if($this->config_file == null) {
21                                 $this->config["status"] = "noconf";
22                                 if(is_dir("/var/lib/fwd/")) {
23                                         echo "no config file found. Will use ../var/fw.conf for now\n";
24                                         $this->config_file = "/var/lib/fwd/fw.conf";
25                                 } else if(is_dir("../var/")) {
26                                         echo "no config file found. Will use ../var/fw.conf for now\n";
27                                         $this->config_file = "../var/";
28                                 } else {
29                                         echo "No directory where i can create a config, bailing\n";
30                                         exit(0);
31                                 }
32                         }
33                 } else {
34                         // config comes from shm... we'll get there
35                 }       
36         }
37         
38         
39         private $config_file;
40         private $config;
41 };
42
43 ?>