Update database method connect to use config.conf
This commit is contained in:
parent
e3b782e7cb
commit
878e5a10eb
|
|
@ -404,38 +404,30 @@
|
||||||
*/
|
*/
|
||||||
public function connect() {
|
public function connect() {
|
||||||
|
|
||||||
if (strlen($this->db_name) == 0) {
|
|
||||||
|
|
||||||
//set the include path
|
//set the include path
|
||||||
$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
|
$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
|
||||||
set_include_path(parse_ini_file($conf[0])['document.root']);
|
set_include_path(parse_ini_file($conf[0])['document.root']);
|
||||||
|
|
||||||
//includes files
|
//parset the config.conf file
|
||||||
require_once "resources/require.php";
|
$conf = parse_ini_file($conf[0]);
|
||||||
|
|
||||||
|
//get the database connection settings
|
||||||
|
$db_type = $conf['database.0.type'];
|
||||||
|
$db_host = $conf['database.0.host'];
|
||||||
|
$db_port = $conf['database.0.port'];
|
||||||
|
$db_name = $conf['database.0.name'];
|
||||||
|
$db_username = $conf['database.0.username'];
|
||||||
|
$db_password = $conf['database.0.password'];
|
||||||
|
|
||||||
//include config.php
|
//debug info
|
||||||
if (file_exists($_SERVER["PROJECT_ROOT"]."/resources/config.php")) {
|
//echo "db type:".$db_type."\n";
|
||||||
include $_SERVER["PROJECT_ROOT"]."/resources/config.php";
|
//echo "db host:".$db_host."\n";
|
||||||
} elseif (file_exists($_SERVER["PROJECT_ROOT"]."/resources/config.php")) {
|
//echo "db port:".$db_port."\n";
|
||||||
include $_SERVER["PROJECT_ROOT"]."/resources/config.php";
|
//echo "db name:".$db_name."\n";
|
||||||
} elseif (file_exists("/etc/fusionpbx/config.php")){
|
//echo "db username:".$db_username."\n";
|
||||||
//linux
|
//echo "db password:".$db_password."\n";
|
||||||
include "/etc/fusionpbx/config.php";
|
//echo "db path:".$db_path."\n";
|
||||||
} elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) {
|
//echo "</pre>\n";
|
||||||
//bsd
|
|
||||||
include "/usr/local/etc/fusionpbx/config.php";
|
|
||||||
}
|
|
||||||
|
|
||||||
//backwards compatibility
|
|
||||||
if (isset($dbtype)) { $db_type = $dbtype; }
|
|
||||||
if (isset($dbhost)) { $db_host = $dbhost; }
|
|
||||||
if (isset($dbport)) { $db_port = $dbport; }
|
|
||||||
if (isset($dbname)) { $db_name = $dbname; }
|
|
||||||
if (isset($dbusername)) { $db_username = $dbusername; }
|
|
||||||
if (isset($dbpassword)) { $db_password = $dbpassword; }
|
|
||||||
if (isset($dbfilepath)) { $db_path = $db_file_path; }
|
|
||||||
if (isset($dbfilename)) { $db_name = $dbfilename; }
|
|
||||||
|
|
||||||
//set defaults
|
//set defaults
|
||||||
if (!isset($this->driver) && isset($db_type)) { $this->driver = $db_type; }
|
if (!isset($this->driver) && isset($db_type)) { $this->driver = $db_type; }
|
||||||
|
|
@ -452,7 +444,6 @@
|
||||||
if (!isset($this->username) && isset($db_username)) { $this->username = $db_username; }
|
if (!isset($this->username) && isset($db_username)) { $this->username = $db_username; }
|
||||||
if (!isset($this->password) && isset($db_password)) { $this->password = $db_password; }
|
if (!isset($this->password) && isset($db_password)) { $this->password = $db_password; }
|
||||||
if (!isset($this->path) && isset($db_path)) { $this->path = $db_path; }
|
if (!isset($this->path) && isset($db_path)) { $this->path = $db_path; }
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->driver == "sqlite") {
|
if ($this->driver == "sqlite") {
|
||||||
if (strlen($this->db_name) == 0) {
|
if (strlen($this->db_name) == 0) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue