]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: New classe BW_Config in config.classe.php
authorDavide Franco <bacula-dev@dflc.ch>
Tue, 22 Mar 2011 14:53:47 +0000 (15:53 +0100)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:49:09 +0000 (14:49 +0200)
gui/bacula-web/classes/cfg/config.classe.php

index 4ee62fae70a2701f0c108ac36615d51f06bc2038..eeab16c0b89a1322b685e5bce0642a335fef29b5 100644 (file)
@@ -1,29 +1,49 @@
 <?php
 
  class BW_Config {
+       private $config;
+       private $catalogs = array();
+       
        function __construct()
        {
-               
+                       if( !$this->Check_Config_file() )
+                               return true;
        }
        
        public function Check_Config_file()
        {
-       
+               // Check if config file exist and is readable
+               return is_readable( CONFIG_FILE );
        }
        
        public function Get_Config()
        {
+               $this->config = parse_ini_file( $this->config_file, true );
                
+               if( !$this->config == false ) {
+                       // Loading database connection information
+                       foreach( $this->config as $parameter => $value )
+                       {
+                               if( is_array($value) )          // Parsing database section
+                                       array_push( $this->catalogs, $value );
+                       }
+                       return true;
+               }else
+                       return false;           
        }
        
        public function Get_Config_Params( $params = array() )
        {
-       
+               if( isset( $this->config[$param] ) )
+                       return $this->config[$param];
+               else
+                       return false;
        }
        
        public function Count_Catalogs()
        {
-       
+               return count( $this->catalogs );
        }
        
        public function Get_Dsn( $catalog_id )
@@ -33,7 +53,7 @@
                
        function __destruct()
        {
-       
+               
        }
        
  } // end classe BW_Config