Update the database class to find the require.php

This commit is contained in:
markjcrane
2023-06-17 22:29:15 -06:00
parent 38150d25aa
commit 1452bde1ac
2 changed files with 26 additions and 17 deletions

View File

@@ -392,22 +392,15 @@
public function connect() {
//includes files
//require dirname(__DIR__, 2) . "/resources/require.php";
//set the include path
$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
set_include_path(parse_ini_file($conf[0])['document.root']);
//parset the config.conf file
$conf = parse_ini_file($conf[0]);
require dirname(__DIR__, 2) . "/resources/require.php";
//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'];
//$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'];
//debug info
//echo "db type:".$db_type."\n";
@@ -645,6 +638,13 @@
$this->connect();
}
//if unable to connect to the database
if (!$this->db) {
echo "Connection Failed<br />\n";
echo "line number ".__line__."<br />\n";
exit;
}
//query table store to see if the table exists
$sql = "";
if ($this->type == "sqlite") {
@@ -1477,11 +1477,20 @@
$this->connect();
}
//unable to connect to the database
if (!$this->db) {
echo "Connection Failed<br />\n";
echo "line number ".__line__."<br />\n";
exit;
}
//set the error mode
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if ($this->db) {
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
//reduce prepared statement latency
if (defined('PDO::PGSQL_ATTR_DISABLE_PREPARES')) {
if ($this->db && defined('PDO::PGSQL_ATTR_DISABLE_PREPARES')) {
$this->db->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES, true);
}

View File

@@ -102,7 +102,7 @@
require_once "resources/php.php";
require_once "resources/functions.php";
if (is_array($conf) && count($conf) > 0) {
require "resources/pdo.php";
require_once "resources/pdo.php";
require_once "resources/cidr.php";
if (file_exists($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/resources/switch.php")) {
require_once "resources/switch.php";