else
$this->bwcfg->Load_Config();
- // Select which catalog to connect
+ // Select which catalog to connect to
if( isset( $_POST['catalog_id'] ) )
$dsn = $this->bwcfg->Get_Dsn( $_POST['catalog_id'] );
else
$dsn = $this->bwcfg->Get_Dsn( 0 );
-
+
// Connect to the database
$this->db_link = $this->connect( $dsn );
class BW_Config {
+ private $config_params;
private $config;
private $catalogs = array();
function __construct()
{
-
+ global $config;
+ $this->config = $config;
}
public function Check_Config_file()
public function Load_Config()
{
- $this->config = parse_ini_file( CONFIG_FILE, true );
+ global $config;
- if( !$this->config == false ) {
+ if( is_array($config) && !empty($config) ) {
// Loading database connection information
- foreach( $this->config as $parameter => $value )
+ foreach( $config as $parameter => $value )
{
if( is_array($value) ) // Parsing database section
array_push( $this->catalogs, $value );
}
return true;
- }else
+ }else {
return false;
+ }
}
public function Get_Config_Param( $param )
{
- if( isset( $this->config[$param] ) )
- return $this->config[$param];
+ if( isset( $config[$param] ) )
+ return $config[$param];
}
public function Count_Catalogs()
$dsn = array();
$dsn['hostspec'] = $this->catalogs[$catalog_id]["host"];
$dsn['username'] = $this->catalogs[$catalog_id]["login"];
- $dsn['password'] = $this->catalogs[$catalog_id]["pass"];
+ $dsn['password'] = $this->catalogs[$catalog_id]["password"];
$dsn['database'] = $this->catalogs[$catalog_id]["db_name"];
$dsn['phptype'] = $this->catalogs[$catalog_id]["db_type"];
return $dsn;
// Global constants
define('CONFIG_DIR', BW_ROOT . "/config/");
- define('CONFIG_FILE', CONFIG_DIR . "bacula.conf");
+ define('CONFIG_FILE', CONFIG_DIR . "config.php");
+ require_once( CONFIG_FILE );
// Time intervals in secondes
define( 'LAST_DAY', 86400 );
+++ /dev/null
-; Language
-; en_EN -> English
-; es_ES -> Spanish, Mantained by Juan Luis Francés Jiménez.
-; it_IT -> Italian, Mantained by Gian Domenico Messina (gianni.messina AT c-ict.it).
-; fr_FR -> Frech, Mantained by Morgan LEFIEUX (comete AT daknet.org).
-; de_DE -> German, Mantained by Florian Heigl.
-lang = en_EN
-
-; Database connection configuration
-
-[.DATABASE]
-host = localhost ; Database host or IP
-login = root ; Database account name
-pass = p@ssw0rd ; Database account password
-db_name = bacula ; Database name
-db_type = mysql ; Database type
-;db_port = 3306 ; Uncomment if not standard port
-
-; Multi-Catalog support
-; If you want to configure more than 1 Bacula catalog in Bacula-Web, simply copy the previous line (See example below)
-; Don't forget the change the name of the section (DATABASE2 in this case)
-
-;[.DATABASE2]
-;host = 192.168.2.55
-;login = bacula
-;pass =
-;db_name = bacula
-;db_type = mysql
--- /dev/null
+<?php
+
+ /* Language
+ en_EN -> English
+ es_ES -> Spanish, Mantained by Juan Luis Francés Jiménez.
+ it_IT -> Italian, Mantained by Gian Domenico Messina (gianni.messina AT c-ict.it).
+ fr_FR -> Frech, Mantained by Morgan LEFIEUX (comete AT daknet.org).
+ de_DE -> German, Mantained by Florian Heigl.
+ */
+
+ $config['language'] = 'en_EN';
+
+ //MySQL bacula catalog
+ $config[0]['label'] = 'Backup Server';
+ $config[0]['host'] = 'localhost';
+ $config[0]['login'] = 'root';
+ $config[0]['password'] = 'p@ssw0rd';
+ $config[0]['db_name'] = 'bacula';
+ $config[0]['db_type'] = 'mysql';
+ $config[0]['db_port'] = '3306';
+
+ //MySQL bacula catalog
+ $config[1]['label'] = 'Backup Server';
+ $config[1]['host'] = 'localhost';
+ $config[1]['login'] = 'bacula';
+ $config[1]['password'] = 'bacula';
+ $config[1]['db_name'] = 'bacula';
+ $config[1]['db_type'] = 'pgsql';
+ $config[1]['db_port'] = '5432';
+
+ /* Catalog(s) connection parameters
+ Just copy/paste and modify regarding your configuration
+
+ Example:
+
+ //MySQL bacula catalog
+ $config[0]['label'] = 'Backup Server';
+ $config[0]['host'] = 'localhost';
+ $config[0]['login'] = 'bacula';
+ $config[0]['password'] = 'verystrongpassword';
+ $config[0]['db_name'] = 'bacula';
+ $config[0]['db_type'] = 'mysql';
+ $config[0]['db_port'] = '3306';
+
+ // PostgreSQL bacula catalog
+ $config[0]['label'] = 'Prod Server';
+ $config[0]['host'] = 'db-server.domain.com';
+ $config[0]['login'] = 'bacula';
+ $config[0]['password'] = 'otherstrongpassword';
+ $config[0]['db_name'] = 'bacula';
+ $config[0]['db_type'] = 'pgsql';
+ $config[0]['db_port'] = '5432';
+
+ // SQLite bacula catalog
+ $config[0]['label'] = 'Dev backup server';
+ $config[0]['db_path'] = '/path/to/database/db.sdb';
+
+ If you want to configure more than one catalog in Bacula-Web, just copy the first parameters and increment by one the index
+
+ //MySQL bacula catalog
+ $config[1]['label'] = 'Dev backup server';
+ $config[1]['host'] = 'mysql-server.domain.net';
+ $config[1]['login'] = 'bacula';
+ $config[1]['password'] = 'verystrongpassword';
+ $config[1]['db_name'] = 'bacula';
+ $config[1]['db_type'] = 'mysql';
+ $config[1]['db_port'] = '3306';
+ */
+?>
$mode = "";
// Assign to template catalogs number
-// $dbSql->tpl->assign( "dbs", $dbSql->Get_Nb_Catalogs() );
+//$dbSql->tpl->assign( "dbs", $dbSql->bwcfg->Count_Catalogs() );
// Assign dbs
/*
if ( count($dbSql->dbs) >1 ) {