From 21d7b28a9a4ba14abf2daa71e424da39f28766e8 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Mon, 30 Nov 2015 15:23:42 +0000 Subject: [PATCH 01/37] moved assumed path management to detect_switch as *_vdir --- core/install/app_languages.php | 11 +++++ .../resources/classes/detect_switch.php | 41 +++++++++++++++---- .../resources/classes/install_fusionpbx.php | 16 +++++--- .../page_parts/install_event_socket.php | 23 +++++++++-- 4 files changed, 73 insertions(+), 18 deletions(-) diff --git a/core/install/app_languages.php b/core/install/app_languages.php index 7dcfb2145f..22ead46f1e 100644 --- a/core/install/app_languages.php +++ b/core/install/app_languages.php @@ -22,6 +22,17 @@ $text['title-detected_configuration']['uk'] = ""; $text['title-detected_configuration']['de-at'] = ""; $text['title-detected_configuration']['ar-eg'] = ""; +$text['title-assumed_configuration']['en-us'] = "Assumed Configuration"; +$text['title-assumed_configuration']['es-cl'] = ""; +$text['title-assumed_configuration']['pt-pt'] = ""; +$text['title-assumed_configuration']['fr-fr'] = ""; +$text['title-assumed_configuration']['pt-br'] = ""; +$text['title-assumed_configuration']['pl'] = ""; +$text['title-assumed_configuration']['sv-se'] = ""; +$text['title-assumed_configuration']['uk'] = ""; +$text['title-assumed_configuration']['de-at'] = ""; +$text['title-assumed_configuration']['ar-eg'] = ""; + $text['message-update']['en-us'] = "Update Completed"; $text['message-update']['es-cl'] = "Actualización Completada"; $text['message-update']['pt-pt'] = "Actualização Efectuada"; diff --git a/core/install/resources/classes/detect_switch.php b/core/install/resources/classes/detect_switch.php index 77a552aab9..a0c26c4d3c 100644 --- a/core/install/resources/classes/detect_switch.php +++ b/core/install/resources/classes/detect_switch.php @@ -36,7 +36,7 @@ require_once "resources/classes/EventSocket.php"; protected $_major; protected $_minor; - // folders + // dirs - detected by from the switch protected $_base_dir = ''; protected $_cache_dir = ''; protected $_certs_dir = ''; @@ -54,7 +54,7 @@ require_once "resources/classes/EventSocket.php"; protected $_sounds_dir = ''; protected $_storage_dir = ''; protected $_temp_dir = ''; - + public function major() { return $this->_major; } public function minor() { return $this->_minor; } public function version() { return $this->_major.".".$this->_minor; } @@ -75,7 +75,23 @@ require_once "resources/classes/EventSocket.php"; public function sounds_dir() { return $this->_sounds_dir; } public function storage_dir() { return $this->_storage_dir; } public function temp_dir() { return $this->_temp_dir; } - public function get_folders() { return $this->_folders; } + public function get_dirs() { return $this->_dirs; } + public function get_vdirs() { return $this->_vdirs; } + + // virtual dirs - assumed based on the detected dirs + protected $_voicemail_vdir = ''; + protected $_phrases_vdir = ''; + protected $_extensions_vdir = ''; + protected $_sip_profiles_vdir = ''; + protected $_dialplan_vdir = ''; + protected $_backup_vdir = ''; + + public function voicemail_vdir() { return $this->_voicemail_vdir; } + public function phrases_vdir() { return $this->_phrases_vdir; } + public function extensions_vdir() { return $this->_extensions_vdir; } + public function sip_profiles_vdir() { return $this->_sip_profiles_vdir; } + public function dialplan_vdir() { return $this->_dialplan_vdir; } + public function backup_vdir() { return $this->_backup_vdir; } // event socket public $event_host = 'localhost'; @@ -91,14 +107,16 @@ require_once "resources/classes/EventSocket.php"; if(!$this->event_socket){ $this->detect_event_socket(); } - $this->_folders = preg_grep ('/.*_dir$/', get_class_methods('detect_switch') ); - sort( $this->_folders ); + $this->_dirs = preg_grep ('/.*_dir$/', get_class_methods('detect_switch') ); + sort( $this->_dirs ); + $this->_vdirs = preg_grep ('/.*_vdir$/', get_class_methods('detect_switch') ); + sort( $this->_vdirs ); } - + protected function detect_event_socket() { //perform searches for user's config here } - + public function detect() { $this->connect_event_socket(); if(!$this->event_socket){ @@ -116,8 +134,13 @@ require_once "resources/classes/EventSocket.php"; $this->$field = $matches[2]; } } - } - + $this->_voicemail_vdir = join( DIRECTORY_SEPARATOR, array($this->_storage_dir, "voicemail")); + $this->_phrases_vdir = join( DIRECTORY_SEPARATOR, array($this->_conf_dir, "lang")); + $this->_extensions_vdir = join( DIRECTORY_SEPARATOR, array($this->_conf_dir, "directory")); + $this->_sip_profiles_vdir = join( DIRECTORY_SEPARATOR, array($this->_conf_dir, "sip_profiles")); + $this->_dialplan_vdir = join( DIRECTORY_SEPARATOR, array($this->_conf_dir, "dialplan")); + $this->_backup_vdir = sys_get_temp_dir(); + } protected function connect_event_socket(){ $esl = new EventSocket; diff --git a/core/install/resources/classes/install_fusionpbx.php b/core/install/resources/classes/install_fusionpbx.php index 6d62060939..b7482fe592 100644 --- a/core/install/resources/classes/install_fusionpbx.php +++ b/core/install/resources/classes/install_fusionpbx.php @@ -637,7 +637,7 @@ include "root.php"; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; - $tmp[$x]['value'] = join( DIRECTORY_SEPARATOR, $this->detect_switch->storage_dir(), 'voicemail'); + $tmp[$x]['value'] = $this->detect_switch->voicemail_vdir(); $tmp[$x]['category'] = 'switch'; $tmp[$x]['subcategory'] = 'voicemail'; $tmp[$x]['enabled'] = 'true'; @@ -655,25 +655,31 @@ include "root.php"; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; + $tmp[$x]['value'] = $this->detect_switch->phrases_vdir(); + $tmp[$x]['category'] = 'switch'; + $tmp[$x]['subcategory'] = 'phrases'; + $tmp[$x]['enabled'] = 'true'; + $x++; + $tmp[$x]['name'] = 'dir'; $tmp[$x]['value'] = ''; $tmp[$x]['category'] = 'switch'; $tmp[$x]['subcategory'] = 'provision'; $tmp[$x]['enabled'] = 'false'; $x++; $tmp[$x]['name'] = 'dir'; - $tmp[$x]['value'] = join( DIRECTORY_SEPARATOR, $this->detect_switch->conf_dir(), "/directory"); + $tmp[$x]['value'] = $this->detect_switch->extensions_vdir(); $tmp[$x]['category'] = 'switch'; $tmp[$x]['subcategory'] = 'extensions'; $tmp[$x]['enabled'] = 'false'; $x++; $tmp[$x]['name'] = 'dir'; - $tmp[$x]['value'] = join( DIRECTORY_SEPARATOR, $this->detect_switch->conf_dir(), "/sip_profiles"); + $tmp[$x]['value'] = $this->detect_switch->sip_profiles_vdir(); $tmp[$x]['category'] = 'switch'; $tmp[$x]['subcategory'] = 'sip_profiles'; $tmp[$x]['enabled'] = 'false'; $x++; $tmp[$x]['name'] = 'dir'; - $tmp[$x]['value'] = join( DIRECTORY_SEPARATOR, $this->detect_switch->conf_dir(), "/dialplan"); + $tmp[$x]['value'] = $this->detect_switch->dialplan_vdir(); $tmp[$x]['category'] = 'switch'; $tmp[$x]['subcategory'] = 'dialplan'; $tmp[$x]['enabled'] = 'false'; @@ -694,7 +700,7 @@ include "root.php"; $tmp[$x]['enabled'] = 'true'; $x++; $tmp[$x]['name'] = 'dir'; - $tmp[$x]['value'] = sys_get_temp_dir(); + $tmp[$x]['value'] = $this->detect_switch->backup_vdir(); $tmp[$x]['category'] = 'server'; $tmp[$x]['subcategory'] = 'backup'; $tmp[$x]['enabled'] = 'true'; diff --git a/core/install/resources/page_parts/install_event_socket.php b/core/install/resources/page_parts/install_event_socket.php index 7122925b4d..928c6e5424 100644 --- a/core/install/resources/page_parts/install_event_socket.php +++ b/core/install/resources/page_parts/install_event_socket.php @@ -91,10 +91,10 @@ echo "\n"; echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; - $id = 0; + $id = 1; echo "\n"; echo "\n"; - echo "\n"; - foreach ($switch_detect->get_folders() as $folder) + foreach ($switch_detect->get_dirs() as $folder) { if($id % 2 == 0){ echo "\n"; } echo "\n"; } + echo "\n"; + echo "\n"; + echo "\n"; + $id=0; + foreach ($switch_detect->get_vdirs() as $folder) + { + if($id % 2 == 0){ echo "\n"; } + echo "\n"; + echo "\n"; + if($id % 2 == 1){ echo "\n"; } + $id++; + } echo "
".$text['title-detected_configuration']."

".$text['title-detected_configuration']."
\n"; echo "Switch version\n"; @@ -102,9 +102,8 @@ echo "\n"; echo " ".$switch_detect->version()."\n"; echo "
\n"; @@ -117,6 +116,22 @@ $id++; } if($id % 2 == 1){ echo "

".$text['title-assumed_configuration']."
\n"; + echo $folder."\n"; + echo "\n"; + echo " ".$switch_detect->$folder()."\n"; + echo "
"; } From e76645401dce938f3c88ac4f40af7d26dd86783b Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Mon, 30 Nov 2015 16:25:36 +0000 Subject: [PATCH 02/37] Added the better create database support --- core/install/install_first_time.php | 1 + .../resources/classes/install_fusionpbx.php | 60 +++++++++---------- .../page_parts/install_config_database.php | 38 ++++++++++++ 3 files changed, 69 insertions(+), 30 deletions(-) diff --git a/core/install/install_first_time.php b/core/install/install_first_time.php index ad08a3faeb..e47bb700bd 100644 --- a/core/install/install_first_time.php +++ b/core/install/install_first_time.php @@ -45,6 +45,7 @@ require_once "resources/classes/text.php"; $db_name = ''; $db_username = ''; $db_password = ''; + $db_create_option = 'none'; $db_create_username = ''; $db_create_password = ''; diff --git a/core/install/resources/classes/install_fusionpbx.php b/core/install/resources/classes/install_fusionpbx.php index b38860fb10..2a680efd2d 100644 --- a/core/install/resources/classes/install_fusionpbx.php +++ b/core/install/resources/classes/install_fusionpbx.php @@ -54,6 +54,9 @@ include "root.php"; public $db_name; public $db_username; public $db_password; + public $db_create_option = 'none'; + public $db_create_username; + public $db_create_password; function __construct($domain_name, $domain_uuid, $detect_switch) { if(!is_a($detect_switch, 'detect_switch')){ @@ -200,6 +203,12 @@ include "root.php"; protected function create_database() { require $this->config_php; $this->write_progress("Creating database as " . $this->db_type); + if($this->create_db_option == 'same') + { + $this->create_db_option = 'user'; + $this->create_db_username = $this->db_username; + $this->create_db_password = $this->db_username_password; + } $function = "create_database_" . $this->db_type; $this->$function(); global $db; @@ -270,17 +279,17 @@ include "root.php"; protected function create_database_pgsql() { - //if $this->db_create_username provided, attempt to create new PG role and database - if (strlen($this->db_create_username) > 0) { + if ($this->db_create_option == 'user') { + //Attempt to create new PG role and database try { if (strlen($this->db_port) == 0) { $this->db_port = "5432"; } if (strlen($this->db_host) > 0) { - $this->dbh = new PDO("pgsql:host={$this->db_host} port={$this->db_port} user={".$this->db_create_username."} password={".$this->db_create_password."} dbname=template1"); + $this->dbh = new PDO("pgsql:host={$this->db_host} port={$this->db_port} user={$this->db_create_username} password={$this->db_create_password} dbname=template1"); } else { - $this->dbh = new PDO("pgsql:host=localhost port={$this->db_port} user={".$this->db_create_username."} password={".$this->db_create_password."} dbname=template1"); + $this->dbh = new PDO("pgsql:host=localhost port={$this->db_port} user={$this->db_create_username} password={$this->db_create_password} dbname=template1"); } } catch (PDOException $error) { - throw new Exception("error connecting to database: " . $error->getMessage()); + throw new Exception("error connecting to database in order to create: " . $error->getMessage()); } //create the database, user, grant perms @@ -344,50 +353,41 @@ include "root.php"; protected function create_database_mysql() { //database connection + $connect_string = ''; + $connect_username = $this->db_username; + $connect_password = $this->db_password; + if ($this->db_create_option == 'user') { + $connect_username = $this->db_create_username; + $connect_password = $this->db_create_password; + } try { if (strlen($this->db_host) == 0 && strlen($this->db_port) == 0) { //if both host and port are empty use the unix socket - if (strlen($this->db_create_username) == 0) { - $this->dbh = new PDO("mysql:host=$this->db_host;unix_socket=/var/run/mysqld/mysqld.sock;", $this->db_username, $this->db_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); - } - else { - $this->dbh = new PDO("mysql:host=$this->db_host;unix_socket=/var/run/mysqld/mysqld.sock;", $this->db_create_username, $this->db_create_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); - } + $this->dbh = new PDO("mysql:host=$this->db_host;unix_socket=/var/run/mysqld/mysqld.sock;", $connect_username, $connect_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); + } + elseif (strlen($this->db_port) == 0) { + //leave out port if it is empty + $this->dbh = new PDO("mysql:host=$this->db_host;", $connect_username, $connect_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); } } else { - if (strlen($this->db_port) == 0) { - //leave out port if it is empty - if (strlen($this->db_create_username) == 0) { - $this->dbh = new PDO("mysql:host=$this->db_host;", $this->db_username, $this->db_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); - } - else { - $this->dbh = new PDO("mysql:host=$this->db_host;", $this->db_create_username, $this->db_create_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); } - } - else { - if (strlen($this->db_create_username) == 0) { - $this->dbh = new PDO("mysql:host=$this->db_host;port=$this->db_port;", $this->db_username, $this->db_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); - } - else { - $this->dbh = new PDO("mysql:host=$this->db_host;port=$this->db_port;", $this->db_create_username, $this->db_create_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); - } - } + $this->dbh = new PDO("mysql:host=$this->db_host;port=$this->db_port;", $connect_username, $connect_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); } $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); } catch (PDOException $error) { - throw new Exception("error creating database: " . $error->getMessage() . "\n" . $sql ); + throw new Exception("error connecting to database: " . $error->getMessage() . "\n" . $sql ); } //create the table, user and set the permissions only if the db_create_username was provided - if (strlen($this->db_create_username) > 0) { + if ($this->db_create_option == 'user') { //select the mysql database try { $this->dbh->query("USE mysql;"); } catch (PDOException $error) { if ($this->debug) { - throw new Exception("error conencting to database: " . $error->getMessage()); + throw new Exception("error connecting to database in order to create: " . $error->getMessage()); } } diff --git a/core/install/resources/page_parts/install_config_database.php b/core/install/resources/page_parts/install_config_database.php index 371a726b98..f5198fc5a3 100644 --- a/core/install/resources/page_parts/install_config_database.php +++ b/core/install/resources/page_parts/install_config_database.php @@ -134,6 +134,25 @@ echo "\n"; echo "\n"; + echo "\n"; + echo "\n"; + echo " Create Database Options\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "Choose whether to create the database\n"; + echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo " Create Database Username\n"; @@ -218,6 +237,25 @@ echo "\n"; echo "\n"; + echo "\n"; + echo "\n"; + echo " Create Database Options\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "Choose whether to create the database\n"; + echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo " Create Database Username\n"; From f5d31ca6ce94d28c1bc53f901587035364fdf5e6 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Tue, 1 Dec 2015 09:53:18 +0000 Subject: [PATCH 03/37] pipe paths though realpath to normalize fixed extra } --- .../resources/classes/detect_switch.php | 21 +++++++++++-------- .../resources/classes/install_fusionpbx.php | 18 +++++++++++++++- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/core/install/resources/classes/detect_switch.php b/core/install/resources/classes/detect_switch.php index a0c26c4d3c..d07603f431 100644 --- a/core/install/resources/classes/detect_switch.php +++ b/core/install/resources/classes/detect_switch.php @@ -35,6 +35,7 @@ require_once "resources/classes/EventSocket.php"; // version information protected $_major; protected $_minor; + protected $_build; // dirs - detected by from the switch protected $_base_dir = ''; @@ -57,7 +58,8 @@ require_once "resources/classes/EventSocket.php"; public function major() { return $this->_major; } public function minor() { return $this->_minor; } - public function version() { return $this->_major.".".$this->_minor; } + public function build() { return $this->_build; } + public function version() { return $this->_major.".".$this->_minor.".".$this->_build; } public function base_dir() { return $this->_base_dir; } public function cache_dir() { return $this->_cache_dir; } public function certs_dir() { return $this->_certs_dir; } @@ -123,23 +125,24 @@ require_once "resources/classes/EventSocket.php"; throw new Exception('Failed to use event socket'); } $FS_Version = $this->event_socket_request('api version'); - preg_match("/FreeSWITCH Version (\d+)\.(\d(?:\.\d+)?)/", $FS_Version, $matches); + preg_match("/FreeSWITCH Version (\d+)\.(\d+)\.(\d(?:\.\d+)?)/", $FS_Version, $matches); $this->_major = $matches[1]; $this->_minor = $matches[2]; + $this->_build = $matches[3]; $FS_Vars = $this->event_socket_request('api global_getvar'); foreach (explode("\n",$FS_Vars) as $FS_Var){ preg_match("/(\w+_dir)=(.*)/", $FS_Var, $matches); if(count($matches) > 0 and property_exists($this, "_" . $matches[1])){ $field = "_" . $matches[1]; - $this->$field = $matches[2]; + $this->$field = realpath($matches[2]); } } - $this->_voicemail_vdir = join( DIRECTORY_SEPARATOR, array($this->_storage_dir, "voicemail")); - $this->_phrases_vdir = join( DIRECTORY_SEPARATOR, array($this->_conf_dir, "lang")); - $this->_extensions_vdir = join( DIRECTORY_SEPARATOR, array($this->_conf_dir, "directory")); - $this->_sip_profiles_vdir = join( DIRECTORY_SEPARATOR, array($this->_conf_dir, "sip_profiles")); - $this->_dialplan_vdir = join( DIRECTORY_SEPARATOR, array($this->_conf_dir, "dialplan")); - $this->_backup_vdir = sys_get_temp_dir(); + $this->_voicemail_vdir = realpath(join( DIRECTORY_SEPARATOR, array($this->_storage_dir, "voicemail"))); + $this->_phrases_vdir = realpath(join( DIRECTORY_SEPARATOR, array($this->_conf_dir, "lang"))); + $this->_extensions_vdir = realpath(join( DIRECTORY_SEPARATOR, array($this->_conf_dir, "directory"))); + $this->_sip_profiles_vdir = realpath(join( DIRECTORY_SEPARATOR, array($this->_conf_dir, "sip_profiles"))); + $this->_dialplan_vdir = realpath(join( DIRECTORY_SEPARATOR, array($this->_conf_dir, "dialplan"))); + $this->_backup_vdir = realpath(sys_get_temp_dir()); } protected function connect_event_socket(){ diff --git a/core/install/resources/classes/install_fusionpbx.php b/core/install/resources/classes/install_fusionpbx.php index 2a680efd2d..4e59d5f2a9 100644 --- a/core/install/resources/classes/install_fusionpbx.php +++ b/core/install/resources/classes/install_fusionpbx.php @@ -213,6 +213,22 @@ include "root.php"; $this->$function(); global $db; $db = $this->dbh; + + //sqlite is natively supported under all known OS'es + if($this->db_type != 'sqlite'){ + if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'){ + //non sqlite database support only uses ODBC under windows + $this->create_odbc_database_connection(); + }elseif($this->db_type != 'pgsql'){ + //switch supports postgresql natively + $this->create_odbc_database_connection(); + } + } + } + + protected function create_odbc_database_connection { + //needed for non native database support + } protected function create_database_sqlite() { @@ -367,7 +383,7 @@ include "root.php"; } elseif (strlen($this->db_port) == 0) { //leave out port if it is empty - $this->dbh = new PDO("mysql:host=$this->db_host;", $connect_username, $connect_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); } + $this->dbh = new PDO("mysql:host=$this->db_host;", $connect_username, $connect_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); } else { $this->dbh = new PDO("mysql:host=$this->db_host;port=$this->db_port;", $connect_username, $connect_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); From bcc181ce706b90c75e198e32872e50fde36a9583 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Tue, 1 Dec 2015 10:10:58 +0000 Subject: [PATCH 04/37] bug fixes for path normalization --- core/install/resources/classes/detect_switch.php | 16 ++++++++-------- .../resources/classes/install_fusionpbx.php | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/install/resources/classes/detect_switch.php b/core/install/resources/classes/detect_switch.php index d07603f431..974e2844dc 100644 --- a/core/install/resources/classes/detect_switch.php +++ b/core/install/resources/classes/detect_switch.php @@ -125,7 +125,7 @@ require_once "resources/classes/EventSocket.php"; throw new Exception('Failed to use event socket'); } $FS_Version = $this->event_socket_request('api version'); - preg_match("/FreeSWITCH Version (\d+)\.(\d+)\.(\d(?:\.\d+)?)/", $FS_Version, $matches); + preg_match("/FreeSWITCH Version (\d+)\.(\d+)\.(\d(?:\.\d+)?)$/", $FS_Version, $matches); $this->_major = $matches[1]; $this->_minor = $matches[2]; $this->_build = $matches[3]; @@ -134,15 +134,15 @@ require_once "resources/classes/EventSocket.php"; preg_match("/(\w+_dir)=(.*)/", $FS_Var, $matches); if(count($matches) > 0 and property_exists($this, "_" . $matches[1])){ $field = "_" . $matches[1]; - $this->$field = realpath($matches[2]); + $this->$field = normalize_path($matches[2]); } } - $this->_voicemail_vdir = realpath(join( DIRECTORY_SEPARATOR, array($this->_storage_dir, "voicemail"))); - $this->_phrases_vdir = realpath(join( DIRECTORY_SEPARATOR, array($this->_conf_dir, "lang"))); - $this->_extensions_vdir = realpath(join( DIRECTORY_SEPARATOR, array($this->_conf_dir, "directory"))); - $this->_sip_profiles_vdir = realpath(join( DIRECTORY_SEPARATOR, array($this->_conf_dir, "sip_profiles"))); - $this->_dialplan_vdir = realpath(join( DIRECTORY_SEPARATOR, array($this->_conf_dir, "dialplan"))); - $this->_backup_vdir = realpath(sys_get_temp_dir()); + $this->_voicemail_vdir = normalize_path(join( DIRECTORY_SEPARATOR, array($this->_storage_dir, "voicemail"))); + $this->_phrases_vdir = normalize_path(join( DIRECTORY_SEPARATOR, array($this->_conf_dir, "lang"))); + $this->_extensions_vdir = normalize_path(join( DIRECTORY_SEPARATOR, array($this->_conf_dir, "directory"))); + $this->_sip_profiles_vdir = normalize_path(join( DIRECTORY_SEPARATOR, array($this->_conf_dir, "sip_profiles"))); + $this->_dialplan_vdir = normalize_path(join( DIRECTORY_SEPARATOR, array($this->_conf_dir, "dialplan"))); + $this->_backup_vdir = normalize_path(sys_get_temp_dir()); } protected function connect_event_socket(){ diff --git a/core/install/resources/classes/install_fusionpbx.php b/core/install/resources/classes/install_fusionpbx.php index 4e59d5f2a9..e27e66ac9f 100644 --- a/core/install/resources/classes/install_fusionpbx.php +++ b/core/install/resources/classes/install_fusionpbx.php @@ -226,7 +226,7 @@ include "root.php"; } } - protected function create_odbc_database_connection { + protected function create_odbc_database_connection() { //needed for non native database support } From 87658251d6b7684a71e121f177b5fc12327c9690 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Tue, 1 Dec 2015 10:11:39 +0000 Subject: [PATCH 05/37] added normalize_path --- resources/functions.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resources/functions.php b/resources/functions.php index c1bd498810..dda3d3a2d6 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -600,6 +600,12 @@ } //echo realpath(sys_get_temp_dir()); + if ( !function_exists('normalize_path')) { + function normalize_path($path) { + return str_replace(DIRECTORY_SEPERATOR, '\\', $path); + } + } + if (!function_exists('username_exists')) { function username_exists($username) { global $db, $domain_uuid; From 2a82c3ca7070505f092b0aac428a52a86cde4caf Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Tue, 1 Dec 2015 10:23:24 +0000 Subject: [PATCH 06/37] db_create not create_db corrected version detection corrected constant --- .../resources/classes/detect_switch.php | 2 +- .../resources/classes/install_fusionpbx.php | 229 +++++++++--------- .../page_parts/install_config_database.php | 6 +- resources/functions.php | 2 +- 4 files changed, 119 insertions(+), 120 deletions(-) diff --git a/core/install/resources/classes/detect_switch.php b/core/install/resources/classes/detect_switch.php index 974e2844dc..b85ef4600b 100644 --- a/core/install/resources/classes/detect_switch.php +++ b/core/install/resources/classes/detect_switch.php @@ -125,7 +125,7 @@ require_once "resources/classes/EventSocket.php"; throw new Exception('Failed to use event socket'); } $FS_Version = $this->event_socket_request('api version'); - preg_match("/FreeSWITCH Version (\d+)\.(\d+)\.(\d(?:\.\d+)?)$/", $FS_Version, $matches); + preg_match("/FreeSWITCH Version (\d+)\.(\d+)\.(\d+(?:\.\d+)?)/", $FS_Version, $matches); $this->_major = $matches[1]; $this->_minor = $matches[2]; $this->_build = $matches[3]; diff --git a/core/install/resources/classes/install_fusionpbx.php b/core/install/resources/classes/install_fusionpbx.php index e27e66ac9f..64881301b5 100644 --- a/core/install/resources/classes/install_fusionpbx.php +++ b/core/install/resources/classes/install_fusionpbx.php @@ -232,140 +232,139 @@ include "root.php"; } protected function create_database_sqlite() { - //sqlite database will be created when the config.php is loaded and only if the database file does not exist + //sqlite database will be created when the config.php is loaded and only if the database file does not exist + try { + $this->dbh = new PDO('sqlite:'.$this->db_path.'/'.$this->db_name); //sqlite 3 + //$this->dbh = new PDO('sqlite::memory:'); //sqlite 3 + } + catch (PDOException $error) { + throw Exception("Failed to create database: " . $error->getMessage()); + } + + //add additional functions to SQLite - bool PDO::sqliteCreateFunction ( string function_name, callback callback [, int num_args] ) + if (!function_exists('php_now')) { + function php_now() { + if(function_exists("date_default_timezone_set") and function_exists("date_default_timezone_get")) { + @date_default_timezone_set(@date_default_timezone_get()); + } + return date("Y-m-d H:i:s"); + } + } + $this->dbh->sqliteCreateFunction('now', 'php_now', 0); + + //add the database structure + require_once "resources/classes/schema.php"; + $schema = new schema; + $schema->db = $this->dbh; + $schema->db_type = $this->db_type; + $schema->sql(); + $schema->exec(); + + //get the contents of the sql file + if (file_exists('/usr/share/examples/fusionpbx/resources/install/sql/sqlite.sql')){ + $filename = "/usr/share/examples/fusionpbx/resources/install/sql/sqlite.sql"; + } + else { + $filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/sql/sqlite.sql'; + } + $file_contents = file_get_contents($filename); + unset($filename); + + //replace \r\n with \n then explode on \n + $file_contents = str_replace("\r\n", "\n", $file_contents); + + //loop line by line through all the lines of sql code + $this->dbh->beginTransaction(); + $string_array = explode("\n", $file_contents); + $x = 0; + foreach($string_array as $sql) { try { - $this->dbh = new PDO('sqlite:'.$this->db_path.'/'.$this->db_name); //sqlite 3 - //$this->dbh = new PDO('sqlite::memory:'); //sqlite 3 + $this->dbh->query($sql); } catch (PDOException $error) { - throw Exception("Failed to create database: " . $error->getMessage()); + throw new Exception("error creating database: " . $error->getMessage() . "\n" . $sql ); } + $x++; + } + unset ($file_contents, $sql); + $this->dbh->commit(); - //add additional functions to SQLite - bool PDO::sqliteCreateFunction ( string function_name, callback callback [, int num_args] ) - if (!function_exists('php_now')) { - function php_now() { - if(function_exists("date_default_timezone_set") and function_exists("date_default_timezone_get")) { - @date_default_timezone_set(@date_default_timezone_get()); - } - return date("Y-m-d H:i:s"); + //set the file permissions + chmod($this->db_path.'/'.$this->db_name, 0777); + } + + protected function create_database_pgsql() { + if ($this->db_create_option == 'user') { + //Attempt to create new PG role and database + try { + if (strlen($this->db_port) == 0) { $this->db_port = "5432"; } + if (strlen($this->db_host) > 0) { + $this->dbh = new PDO("pgsql:host={$this->db_host} port={$this->db_port} user={$this->db_create_username} password={$this->db_create_password} dbname=template1"); + } else { + $this->dbh = new PDO("pgsql:host=localhost port={$this->db_port} user={$this->db_create_username} password={$this->db_create_password} dbname=template1"); } + } catch (PDOException $error) { + throw new Exception("error connecting to database in order to create: " . $error->getMessage()); } - $this->dbh->sqliteCreateFunction('now', 'php_now', 0); - //add the database structure - require_once "resources/classes/schema.php"; - $schema = new schema; - $schema->db = $this->dbh; - $schema->db_type = $this->db_type; - $schema->sql(); - $schema->exec(); + //create the database, user, grant perms + $this->dbh->exec("CREATE DATABASE {$this->db_name}"); + $this->dbh->exec("CREATE USER {$this->db_username} WITH PASSWORD '{$this->db_password}'"); + $this->dbh->exec("GRANT ALL ON {$this->db_name} TO {$this->db_username}"); - //get the contents of the sql file - if (file_exists('/usr/share/examples/fusionpbx/resources/install/sql/sqlite.sql')){ - $filename = "/usr/share/examples/fusionpbx/resources/install/sql/sqlite.sql"; + //close database connection_aborted + $this->dbh = null; + } + + //open database connection with $this->db_name + try { + if (strlen($this->db_port) == 0) { $this->db_port = "5432"; } + if (strlen($this->db_host) > 0) { + $this->dbh = new PDO("pgsql:host={$this->db_host} port={$this->db_port} dbname={$this->db_name} user={$this->db_username} password={$this->db_password}"); + } else { + $this->dbh = new PDO("pgsql:host=localhost port={$this->db_port} user={$this->db_username} password={$this->db_password} dbname={$this->db_name}"); } - else { - $filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/sql/sqlite.sql'; - } - $file_contents = file_get_contents($filename); - unset($filename); + } + catch (PDOException $error) { + throw new Exception("error connecting to database: " . $error->getMessage()); + } - //replace \r\n with \n then explode on \n - $file_contents = str_replace("\r\n", "\n", $file_contents); + //add the database structure + require_once "resources/classes/schema.php"; + $schema = new schema; + $schema->db = $this->dbh; + $schema->db_type = $this->db_type; + $schema->sql(); + $schema->exec(); - //loop line by line through all the lines of sql code - $this->dbh->beginTransaction(); - $string_array = explode("\n", $file_contents); - $x = 0; - foreach($string_array as $sql) { + //get the contents of the sql file + if (file_exists('/usr/share/examples/fusionpbx/resources/install/sql/pgsql.sql')){ + $filename = "/usr/share/examples/fusionpbx/resources/install/sql/pgsql.sql"; + } + else { + $filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/sql/pgsql.sql'; + } + $file_contents = file_get_contents($filename); + + //replace \r\n with \n then explode on \n + $file_contents = str_replace("\r\n", "\n", $file_contents); + + //loop line by line through all the lines of sql code + $string_array = explode("\n", $file_contents); + $x = 0; + foreach($string_array as $sql) { + if (strlen($sql) > 3) { try { $this->dbh->query($sql); } catch (PDOException $error) { - throw new Exception("error creating database: " . $error->getMessage() . "\n" . $sql ); + throw new Exception("error creating database: " . $error->getMessage() . "\n" . $sql ); } - $x++; } - unset ($file_contents, $sql); - $this->dbh->commit(); - - //set the file permissions - chmod($this->db_path.'/'.$this->db_name, 0777); - } - - protected function create_database_pgsql() { - - if ($this->db_create_option == 'user') { - //Attempt to create new PG role and database - try { - if (strlen($this->db_port) == 0) { $this->db_port = "5432"; } - if (strlen($this->db_host) > 0) { - $this->dbh = new PDO("pgsql:host={$this->db_host} port={$this->db_port} user={$this->db_create_username} password={$this->db_create_password} dbname=template1"); - } else { - $this->dbh = new PDO("pgsql:host=localhost port={$this->db_port} user={$this->db_create_username} password={$this->db_create_password} dbname=template1"); - } - } catch (PDOException $error) { - throw new Exception("error connecting to database in order to create: " . $error->getMessage()); - } - - //create the database, user, grant perms - $this->dbh->exec("CREATE DATABASE {$this->db_name}"); - $this->dbh->exec("CREATE USER {$this->db_username} WITH PASSWORD '{$this->db_password}'"); - $this->dbh->exec("GRANT ALL ON {$this->db_name} TO {$this->db_username}"); - - //close database connection_aborted - $this->dbh = null; - } - - //open database connection with $this->db_name - try { - if (strlen($this->db_port) == 0) { $this->db_port = "5432"; } - if (strlen($this->db_host) > 0) { - $this->dbh = new PDO("pgsql:host={$this->db_host} port={$this->db_port} dbname={$this->db_name} user={$this->db_username} password={$this->db_password}"); - } else { - $this->dbh = new PDO("pgsql:host=localhost port={$this->db_port} user={$this->db_username} password={$this->db_password} dbname={$this->db_name}"); - } - } - catch (PDOException $error) { - throw new Exception("error connecting to database: " . $error->getMessage()); - } - - //add the database structure - require_once "resources/classes/schema.php"; - $schema = new schema; - $schema->db = $this->dbh; - $schema->db_type = $this->db_type; - $schema->sql(); - $schema->exec(); - - //get the contents of the sql file - if (file_exists('/usr/share/examples/fusionpbx/resources/install/sql/pgsql.sql')){ - $filename = "/usr/share/examples/fusionpbx/resources/install/sql/pgsql.sql"; - } - else { - $filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/sql/pgsql.sql'; - } - $file_contents = file_get_contents($filename); - - //replace \r\n with \n then explode on \n - $file_contents = str_replace("\r\n", "\n", $file_contents); - - //loop line by line through all the lines of sql code - $string_array = explode("\n", $file_contents); - $x = 0; - foreach($string_array as $sql) { - if (strlen($sql) > 3) { - try { - $this->dbh->query($sql); - } - catch (PDOException $error) { - throw new Exception("error creating database: " . $error->getMessage() . "\n" . $sql ); - } - } - $x++; - } - unset ($file_contents, $sql); + $x++; } + unset ($file_contents, $sql); + } protected function create_database_mysql() { //database connection diff --git a/core/install/resources/page_parts/install_config_database.php b/core/install/resources/page_parts/install_config_database.php index f5198fc5a3..0d41078d9d 100644 --- a/core/install/resources/page_parts/install_config_database.php +++ b/core/install/resources/page_parts/install_config_database.php @@ -242,13 +242,13 @@ echo " Create Database Options\n"; echo "\n"; echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; echo "
\n"; diff --git a/resources/functions.php b/resources/functions.php index dda3d3a2d6..ac3b793f2b 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -602,7 +602,7 @@ if ( !function_exists('normalize_path')) { function normalize_path($path) { - return str_replace(DIRECTORY_SEPERATOR, '\\', $path); + return str_replace(DIRECTORY_SEPARATOR, '\\', $path); } } From ec1588c5e192702de1ae443c02dfc6bb4da0960d Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Tue, 1 Dec 2015 10:33:51 +0000 Subject: [PATCH 07/37] simplified the create database options --- .../resources/classes/install_fusionpbx.php | 16 ++++++++-------- .../page_parts/install_config_database.php | 17 ++++++----------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/core/install/resources/classes/install_fusionpbx.php b/core/install/resources/classes/install_fusionpbx.php index 64881301b5..fc1fb850f4 100644 --- a/core/install/resources/classes/install_fusionpbx.php +++ b/core/install/resources/classes/install_fusionpbx.php @@ -54,7 +54,8 @@ include "root.php"; public $db_name; public $db_username; public $db_password; - public $db_create_option = 'none'; + public $db_create; + public $db_create_reuse_auth; public $db_create_username; public $db_create_password; @@ -203,11 +204,10 @@ include "root.php"; protected function create_database() { require $this->config_php; $this->write_progress("Creating database as " . $this->db_type); - if($this->create_db_option == 'same') + if($this->db_create_reuse_auth) { - $this->create_db_option = 'user'; - $this->create_db_username = $this->db_username; - $this->create_db_password = $this->db_username_password; + $this->db_create_username = $this->db_username; + $this->db_create_password = $this->db_username_password; } $function = "create_database_" . $this->db_type; $this->$function(); @@ -294,7 +294,7 @@ include "root.php"; } protected function create_database_pgsql() { - if ($this->db_create_option == 'user') { + if ($this->db_create) { //Attempt to create new PG role and database try { if (strlen($this->db_port) == 0) { $this->db_port = "5432"; } @@ -371,7 +371,7 @@ include "root.php"; $connect_string = ''; $connect_username = $this->db_username; $connect_password = $this->db_password; - if ($this->db_create_option == 'user') { + if ($this->db_create) { $connect_username = $this->db_create_username; $connect_password = $this->db_create_password; } @@ -395,7 +395,7 @@ include "root.php"; } //create the table, user and set the permissions only if the db_create_username was provided - if ($this->db_create_option == 'user') { + if ($this->db_create) { //select the mysql database try { $this->dbh->query("USE mysql;"); diff --git a/core/install/resources/page_parts/install_config_database.php b/core/install/resources/page_parts/install_config_database.php index 0d41078d9d..e091d4cfbe 100644 --- a/core/install/resources/page_parts/install_config_database.php +++ b/core/install/resources/page_parts/install_config_database.php @@ -242,17 +242,12 @@ echo " Create Database Options\n"; echo "\n"; echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo "Choose whether to create the database\n"; + echo " \n"; + echo " \n"; echo "\n"; echo "\n"; From e7ff440ec8130d3f96f8a402c975f9516c1ec3c9 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Tue, 1 Dec 2015 10:56:18 +0000 Subject: [PATCH 08/37] removed reuse stuff, it was confusing fixed mysql databse create to make more logical sense inside code removed many if($debug) and replaced with throws --- .../resources/classes/install_fusionpbx.php | 82 ++++++++----------- .../page_parts/install_config_database.php | 4 +- 2 files changed, 36 insertions(+), 50 deletions(-) diff --git a/core/install/resources/classes/install_fusionpbx.php b/core/install/resources/classes/install_fusionpbx.php index fc1fb850f4..1253f3da60 100644 --- a/core/install/resources/classes/install_fusionpbx.php +++ b/core/install/resources/classes/install_fusionpbx.php @@ -55,7 +55,6 @@ include "root.php"; public $db_username; public $db_password; public $db_create; - public $db_create_reuse_auth; public $db_create_username; public $db_create_password; @@ -204,10 +203,10 @@ include "root.php"; protected function create_database() { require $this->config_php; $this->write_progress("Creating database as " . $this->db_type); - if($this->db_create_reuse_auth) + if($this->db_create and strlen($this->db_create_username) > 0) { $this->db_create_username = $this->db_username; - $this->db_create_password = $this->db_username_password; + $this->db_create_password = $this->db_password; } $function = "create_database_" . $this->db_type; $this->$function(); @@ -368,42 +367,35 @@ include "root.php"; protected function create_database_mysql() { //database connection - $connect_string = ''; - $connect_username = $this->db_username; - $connect_password = $this->db_password; - if ($this->db_create) { - $connect_username = $this->db_create_username; - $connect_password = $this->db_create_password; + $connect_string; + if (strlen($this->db_host) == 0 && strlen($this->db_port) == 0) { + //if both host and port are empty use the unix socket + $connect_string = "mysql:host=$this->db_host;unix_socket=/var/run/mysqld/mysqld.sock;"; } - try { - if (strlen($this->db_host) == 0 && strlen($this->db_port) == 0) { - //if both host and port are empty use the unix socket - $this->dbh = new PDO("mysql:host=$this->db_host;unix_socket=/var/run/mysqld/mysqld.sock;", $connect_username, $connect_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); - } - elseif (strlen($this->db_port) == 0) { - //leave out port if it is empty - $this->dbh = new PDO("mysql:host=$this->db_host;", $connect_username, $connect_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); - } - else { - $this->dbh = new PDO("mysql:host=$this->db_host;port=$this->db_port;", $connect_username, $connect_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); - } - $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $this->dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); + elseif (strlen($this->db_port) == 0) { + //leave out port if it is empty + $connect_string = "mysql:host=$this->db_host;"; } - catch (PDOException $error) { - throw new Exception("error connecting to database: " . $error->getMessage() . "\n" . $sql ); + else { + $connect_string = "mysql:host=$this->db_host;port=$this->db_port;"; } //create the table, user and set the permissions only if the db_create_username was provided if ($this->db_create) { + try { + $this->dbh = new PDO($connect_string, $this->db_create_username, db_create_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); + $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $this->dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); + } + catch (PDOException $error) { + throw new Exception("error connecting to database for ccreate: " . $error->getMessage() . "\n" . $sql ); + } //select the mysql database try { $this->dbh->query("USE mysql;"); } catch (PDOException $error) { - if ($this->debug) { - throw new Exception("error connecting to database in order to create: " . $error->getMessage()); - } + throw new Exception("error in database: " . $error->getMessage() . "\n" . $sql ); } //create user and set the permissions @@ -412,9 +404,7 @@ include "root.php"; $this->dbh->query($tmp_sql); } catch (PDOException $error) { - if ($this->debug) { - print "error: " . $error->getMessage() . "
"; - } + throw new Exception("error in database: " . $error->getMessage() . "\n" . $sql ); } //set account to unlimited use @@ -438,9 +428,7 @@ include "root.php"; } } catch (PDOException $error) { - if ($this->debug) { - print "error: " . $error->getMessage() . "
"; - } + throw new Exception("error in database: " . $error->getMessage() . "\n" . $sql ); } //create the database and set the create user with permissions @@ -449,9 +437,7 @@ include "root.php"; $this->dbh->query($tmp_sql); } catch (PDOException $error) { - if ($this->debug) { - print "error: " . $error->getMessage() . "
"; - } + throw new Exception("error in database: " . $error->getMessage() . "\n" . $sql ); } //set user permissions @@ -459,9 +445,7 @@ include "root.php"; $this->dbh->query("GRANT ALL PRIVILEGES ON ".$this->db_name.".* TO '".$this->db_username."'@'%'; "); } catch (PDOException $error) { - if ($this->debug) { - print "error: " . $error->getMessage() . "
"; - } + throw new Exception("error in database: " . $error->getMessage() . "\n" . $sql ); } //make the changes active @@ -470,21 +454,25 @@ include "root.php"; $this->dbh->query($tmp_sql); } catch (PDOException $error) { - if ($this->debug) { - print "error: " . $error->getMessage() . "
"; - } + throw new Exception("error in database: " . $error->getMessage() . "\n" . $sql ); } - + $this->dbh = null; } //if (strlen($this->db_create_username) > 0) //select the database + try { + $this->dbh = new PDO($connect_string, $this->db_username, db_password, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); + $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $this->dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); + } + catch (PDOException $error) { + throw new Exception("error connecting to database: " . $error->getMessage() . "\n" . $sql ); + } try { $this->dbh->query("USE ".$this->db_name.";"); } catch (PDOException $error) { - if ($this->debug) { - print "error: " . $error->getMessage() . "
"; - } + throw new Exception("error in database: " . $error->getMessage() . "\n" . $sql ); } //add the database structure diff --git a/core/install/resources/page_parts/install_config_database.php b/core/install/resources/page_parts/install_config_database.php index e091d4cfbe..cf782d498b 100644 --- a/core/install/resources/page_parts/install_config_database.php +++ b/core/install/resources/page_parts/install_config_database.php @@ -246,8 +246,6 @@ if($db_create=='1') { echo " checked='checked'"; } echo "/>Create the database\n"; echo " \n"; echo "\n"; echo "\n"; @@ -259,7 +257,7 @@ echo "
\n"; echo " Optional, this username is used to create the database, a database user and set the permissions. \n"; echo " By default this username is 'pgsql' however it can be any account with permission to add a database, user, and grant permissions. \n"; - echo " Leave blank if the user and empty database already exist and you do not want them created. \n"; + echo " Leave blank to use the details above. \n"; echo "\n"; echo "\n"; From 4efec3ac0ba0c7d82f40eeae2f6c4f8fac37abf7 Mon Sep 17 00:00:00 2001 From: Matthew Vale Date: Tue, 1 Dec 2015 11:02:32 +0000 Subject: [PATCH 09/37] removed redundant radio override when length is 0, not visa versa --- core/install/resources/classes/install_fusionpbx.php | 2 +- core/install/resources/page_parts/install_config_database.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/core/install/resources/classes/install_fusionpbx.php b/core/install/resources/classes/install_fusionpbx.php index 1253f3da60..cc15ecdf8a 100644 --- a/core/install/resources/classes/install_fusionpbx.php +++ b/core/install/resources/classes/install_fusionpbx.php @@ -203,7 +203,7 @@ include "root.php"; protected function create_database() { require $this->config_php; $this->write_progress("Creating database as " . $this->db_type); - if($this->db_create and strlen($this->db_create_username) > 0) + if($this->db_create and strlen($this->db_create_username) == 0) { $this->db_create_username = $this->db_username; $this->db_create_password = $this->db_password; diff --git a/core/install/resources/page_parts/install_config_database.php b/core/install/resources/page_parts/install_config_database.php index cf782d498b..054059e742 100644 --- a/core/install/resources/page_parts/install_config_database.php +++ b/core/install/resources/page_parts/install_config_database.php @@ -245,7 +245,6 @@ echo " \n"; - echo "