From 7721e7a8a0dda50337254fa615a90dcea33a9220 Mon Sep 17 00:00:00 2001
From: steve-lad <72376554+steve-lad@users.noreply.github.com>
Date: Sun, 27 Jun 2021 12:48:24 +0200
Subject: [PATCH] Tidy up installer
Clean SQL statements
Solidify dbsettings management
---
install.php | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/install.php b/install.php
index 137cbbb..21e78b4 100644
--- a/install.php
+++ b/install.php
@@ -468,13 +468,13 @@ function InstallDB_updateSchema($db_config)
try {
$check = $db->query($sql_create);
} catch (\Exception $e) {
- die_freepbx("Can not modify {$tabl_name}. SQL: {$sql_create} \n");
+ die_freepbx("Can add column to {$tabl_name}. SQL: {$sql_create} \n");
}
}
if (!empty($sql_modify)) {
outn("
" . _("Modifying table ") . $tabl_name ."");
- $sql_modify = "ALTER TABLE `" . $tabl_name . "` " . substr($sql_modify, 0, -2) . ';';
+ $sql_modify = "ALTER TABLE {$tabl_name} " . substr($sql_modify, 0, -2);
try {
$check = $db->query($sql_modify);
} catch (\Exception $e) {
@@ -851,16 +851,16 @@ function Setup_RealTime()
$cnf_wr->writeConfig('res_mysql.conf', $res_conf);
outn("" . _("Updating res_mysql.conf file ...") . "");
}
- }
- if (file_exists($dir . '/res_config_mysql.conf')) {
+ } elseif (file_exists($dir . '/res_config_mysql.conf')) {
$res_conf = $cnf_read->getConfig('res_config_mysql.conf');
if (empty($res_conf[$def_bd_section])) {
$res_conf[$def_bd_section] = $def_bd_config;
$cnf_wr->writeConfig('res_config_mysql.conf', $res_conf);
outn("" . _("Updating res_config_mysql.conf file ...") . "");
}
- }
- if (empty($res_conf)) {
+ } else {
+ // Have not found either res_mysql.conf or res_config_mysql.config
+ // So create the latter
$res_conf[$def_bd_section] = $def_bd_config;
$cnf_wr->writeConfig('res_config_mysql.conf', $res_conf, false);
}
@@ -868,7 +868,7 @@ function Setup_RealTime()
function addDriver($sccp_compatible) {
outn("" . _("Adding driver ...") . "");
- $file = "/var/www/html/admin/modules/core/functions.inc/drivers/Sccp.class.php";
+ $file = "{$_SERVER['DOCUMENT_ROOT']}/admin/modules/core/functions.inc/drivers/Sccp.class.php";
$contents = "";
file_put_contents($file, $contents);
@@ -876,7 +876,7 @@ function addDriver($sccp_compatible) {
$dir = $cnf_int->get('ASTETCDIR');
if (!file_exists("{$dir}/sccp.conf")) { // System re Config
outn("" . _("Adding default configuration file ...") . "");
- $sccpfile = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/sccp.conf');
+ $sccpfile = file_get_contents("{$_SERVER['DOCUMENT_ROOT']}/admin/modules/sccp_manager/conf/sccp.conf");
file_put_contents("{$dir}/sccp.conf", $sccpfile);
}
}