Merge remote-tracking branch 'remotes/fusionpbx/master' into Enhance_Install

This commit is contained in:
Matthew Vale
2015-11-30 15:51:18 +00:00
46 changed files with 1283 additions and 607 deletions

View File

@@ -1,8 +1,8 @@
<?php
$text['title-install_first_time']['en-us'] = "First Time Install";
$text['title-install_first_time']['es-cl'] = "";
$text['title-install_first_time']['pt-pt'] = "";
$text['title-install_first_time']['es-cl'] = "Instale Primera Vez";
$text['title-install_first_time']['pt-pt'] = "Première installation";
$text['title-install_first_time']['fr-fr'] = "";
$text['title-install_first_time']['pt-br'] = "";
$text['title-install_first_time']['pl'] = "";
@@ -78,10 +78,37 @@ $text['message-delete']['de-at'] = "Erfolgreich gelöscht";
$text['message-delete']['ar-eg'] = "تم المسح";
$text['label-ft-install']['en-us'] = "First Time Install";
$text['label-ft-install']['es-cl'] = "";
$text['label-ft-install']['pt-pt'] = "";
$text['label-ft-install']['fr-fr'] = "";
$text['label-ft-install']['pt-br'] = "";
$text['label-ft-install']['pl'] = "";
$text['label-ft-install']['sv-se'] = "";
$text['label-ft-install']['uk'] = "";
$text['label-ft-install']['de-at'] = "";
$text['label-ft-install']['ar-eg'] = "";
$text['description-ft-install']['en-us'] = "Perform all actions for a First Time Install";
$text['description-ft-install']['es-cl'] = "";
$text['description-ft-install']['pt-pt'] = "";
$text['description-ft-install']['fr-fr'] = "";
$text['description-ft-install']['pt-br'] = "";
$text['description-ft-install']['pl'] = "";
$text['description-ft-install']['sv-se'] = "";
$text['description-ft-install']['uk'] = "";
$text['description-ft-install']['de-at'] = "";
$text['description-ft-install']['ar-eg'] = "";
$text['label-add-switch']['en-us'] = "Add a new switch";
$text['description-add-switch']['en-us'] = "Add a new switch";
$text['label-add-switch']['es-cl'] = "";
$text['label-add-switch']['pt-pt'] = "";
$text['label-add-switch']['fr-fr'] = "";
$text['label-add-switch']['pt-br'] = "";
$text['label-add-switch']['pl'] = "";
$text['label-add-switch']['sv-se'] = "";
$text['label-add-switch']['uk'] = "";
$text['label-add-switch']['de-at'] = "";
$text['label-add-switch']['ar-eg'] = "";
$text['label-select_language']['en-us'] = "Language";
$text['label-select_language']['es-cl'] = "";

View File

@@ -78,21 +78,6 @@ if (!if_group("superadmin")) {
echo "</table>\n";
echo "</form>\n";
echo "<form name='frm' method='post' action='/core/install/install_add_switch.php'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo " <td width='30%' class='vncell'>\n";
echo " <input id='do_add-switch' type='submit' class='btn' value='".$text['label-add-switch']."'/>";
echo " </td>\n";
echo " <td width='70%' class='vtable' style='height: 50px;'>\n";
echo " <label for='do_add-switch'>";
echo " ".$text['description-add-switch'];
echo " </label>\n";
echo " </td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</form>\n";
echo "<br><br>";
echo "<p>WiP</p>";

View File

@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
Portions created by the Initial Developer are Copyright (C) 2008-2015
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -28,7 +28,7 @@ require_once "root.php";
require_once "resources/functions.php";
require_once "resources/classes/text.php";
//initialize varibles we are going to use
//initialize variables we are going to use
$event_host = '';
$event_port = '';
$event_password = '';
@@ -63,7 +63,7 @@ if (is_link('/etc/localtime')) {
// Ubuntu / Debian.
$data = file_get_contents('/etc/timezone');
if ($data) {
$timezone = $data;
$timezone = rtrim($data);
}
} elseif (file_exists('/etc/sysconfig/clock')) {
// RHEL / CentOS
@@ -80,7 +80,6 @@ $first_time_install = true;
if (file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH."/resources/config.php")) {
$first_time_install = false;
} elseif (file_exists("/etc/fusionpbx/config.php")) {
//linux
$first_time_install = false;
} elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) {
$first_time_install = false;
@@ -98,7 +97,7 @@ if(!$first_time_install) {
$install_step = '';
$return_install_step = '';
if (count($_POST)>0) {
if (count($_POST) > 0) {
$install_language = check_str($_POST["install_language"]);
$install_step = check_str($_POST["install_step"]);
$return_install_step = check_str($_POST["return_install_step"]);
@@ -130,7 +129,7 @@ if(!$install_step) { $install_step = 'select_language'; }
if (isset($_SESSION['domain']['template']['name']) and strlen($_SESSION['domain']['template']['name']) != 0) {
$default_template = $_SESSION['domain']['template']['name'];
}
//set a default enviroment if first_time
if($first_time_install){
//initialize some varibles to cut down on warnings
@@ -147,7 +146,7 @@ if(!$install_step) { $install_step = 'select_language'; }
//buffer the content
ob_end_clean(); //clean the buffer
ob_start();
$messages = array();
if (!extension_loaded('PDO')) {
$messages[] = "<b>PHP PDO was not detected</b>. Please install it before proceeding";
@@ -168,7 +167,7 @@ if(!$install_step) { $install_step = 'select_language'; }
"<sm>You can use the following to find what ports are allowed<pre>semanage port -l | grep '^http_port_t'</pre></sm>";
}
}
//action code
if($return_install_step == 'config_detail'){
//check for all required data
@@ -185,11 +184,8 @@ if(!$install_step) { $install_step = 'select_language'; }
//set the max execution time to 1 hour
ini_set('max_execution_time',3600);
}
//display messages
if (count($messages)>0) {
echo "<br />\n";
@@ -224,6 +220,9 @@ if(!$install_step) { $install_step = 'select_language'; }
echo " </div>\n";
echo "</form>\n";
}elseif($install_step == 'detect_config'){
if(!($event_host == '' || $event_host == 'localhost' || $event_host == '::1' || $event_host == '127.0.0.1' )){
echo "<p><b>Warning</b> you have choosen a value other than localhost for event_host, this is unsoported at present</p>\n";
}
include "resources/page_parts/install_event_socket.php";
if($detect_ok){
echo "<form method='post' name='frm' action=''>\n";
@@ -238,6 +237,12 @@ if(!$install_step) { $install_step = 'select_language'; }
echo " <button type='submit' id='next'>".$text['button-next']."</button>\n";
echo " </div>\n";
echo "</form>\n";
}else{
echo "<form method='post' name='frm' action=''>\n";
echo " <div style='text-align:right'>\n";
echo " <button type='button' onclick=\"history.go(-1);\">".$text['button-back']."</button>\n";
echo " </div>\n";
echo "</form>\n";
}
}
elseif($install_step == 'config_detail'){
@@ -262,7 +267,7 @@ if(!$install_step) { $install_step = 'select_language'; }
try {
$switch_detect->detect();
} catch(Exception $e){
echo "<p>Failed to detect confgiuration detect_switch reported: " . $e->getMessage() . "</p>\n";
echo "<p>Failed to detect configuration detect_switch reported: " . $e->getMessage() . "</p>\n";
$detect_ok = false;
}
if($detect_ok){
@@ -285,32 +290,34 @@ if(!$install_step) { $install_step = 'select_language'; }
#set_error_handler("error_handler");
try {
require_once "resources/classes/install_fusionpbx.php";
$fusionPBX = new install_fusionpbx($domain_name, null, $switch_detect);
$domain_uuid = $fusionPBX->domain_uuid();
//$fusionPBX->debug = true;
$fusionPBX->admin_username = $admin_username;
$fusionPBX->admin_password = $admin_password;
$fusionPBX->default_country = $install_default_country;
$fusionPBX->install_language = $install_language;
$fusionPBX->template_name = $install_template_name;
$system = new install_fusionpbx($domain_name, null, $switch_detect);
$domain_uuid = $system->domain_uuid();
$system->admin_username = $admin_username;
$system->admin_password = $admin_password;
$system->default_country = $install_default_country;
$system->install_language = $install_language;
$system->template_name = $install_template_name;
foreach($_POST as $key=>$value){
if(substr($key,0,3) == "db_"){
$fusionPBX->$key = $value;
$system->$key = $value;
}
}
$fusionPBX->install();
require_once "resources/classes/install_switch.php";
$switch = new install_switch($domain_name, $domain_uuid, $switch_detect);
//$switch->debug = true;
//$system->debug = true;
$system->install();
$switch->install();
$system->app_defaults();
$switch_detect->restart_switch();
}catch(Exception $e){
echo "</pre>\n";
echo "<p><b>Failed to install</b><br/>" . $e->getMessage() . "</p>\n";
try {
require_once "resources/classes/install_fusionpbx.php";
$fusionPBX = new install_fusionpbx($domain_name, $domain_uuid, $switch_detect);
$fusionPBX->remove_config();
$system = new install_fusionpbx($domain_name, $domain_uuid, $switch_detect);
$system->remove_config();
}catch(Exception $e){
echo "<p><b>Failed to remove config:</b> " . $e->getMessage() . "</p>\n";
}
@@ -345,6 +352,7 @@ if($first_time_install){
$_SESSION['permissions'][]['permission_name'] = 'superadmin';
$_SESSION['menu'] = '';
}
// add the content to the template and then send output
$body = ob_get_contents(); //get the output from the buffer
ob_end_clean(); //clean the buffer

View File

@@ -35,11 +35,11 @@ include "root.php";
protected $config_php;
protected $menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286';
protected $dbh;
public function domain_uuid() { return $this->_domain_uuid; }
public $debug = false;
public $install_msg;
public $install_language = 'en-us';
public $admin_username;
@@ -54,7 +54,7 @@ include "root.php";
public $db_name;
public $db_username;
public $db_password;
function __construct($domain_name, $domain_uuid, $detect_switch) {
if(!is_a($detect_switch, 'detect_switch')){
throw new Exception('The parameter $detect_switch must be a detect_switch object (or a subclass of)');
@@ -94,9 +94,8 @@ include "root.php";
$this->create_superuser();
require "resources/require.php";
$this->create_menus();
$this->app_defaults();
}
protected function create_config_php() {
$tmp_config = "<?php\n";
$tmp_config .= "/* \$Id\$ */\n";
@@ -184,10 +183,11 @@ include "root.php";
$tmp_config .= " error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ); //hide notices and warnings";
$tmp_config .= "\n";
$tmp_config .= "?>";
if((file_exists($this->config_php) and !is_writable($this->config_php))
or !is_writable(dirname($this->config_php))
){
if((file_exists($this->config_php)
and !is_writable($this->config_php))
or !is_writable(dirname($this->config_php))
) {
throw new Exception("cannot write to '" . $this->config_php . "'" );
}
$this->write_progress("Creating " . $this->config_php);
@@ -196,7 +196,7 @@ include "root.php";
unset($tmp_config);
fclose($fout);
}
protected function create_database() {
require $this->config_php;
$this->write_progress("Creating database as " . $this->db_type);
@@ -205,6 +205,7 @@ include "root.php";
global $db;
$db = $this->dbh;
}
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
try {
@@ -268,7 +269,7 @@ 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) {
try {
@@ -281,16 +282,16 @@ include "root.php";
} catch (PDOException $error) {
throw new Exception("error connecting to database: " . $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"; }
@@ -303,7 +304,7 @@ include "root.php";
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;
@@ -311,7 +312,7 @@ include "root.php";
$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";
@@ -320,10 +321,10 @@ include "root.php";
$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;
@@ -340,7 +341,7 @@ include "root.php";
}
unset ($file_contents, $sql);
}
protected function create_database_mysql() {
//database connection
try {
@@ -377,7 +378,7 @@ include "root.php";
catch (PDOException $error) {
throw new Exception("error creating 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) {
//select the mysql database
@@ -389,7 +390,7 @@ include "root.php";
throw new Exception("error conencting to database: " . $error->getMessage());
}
}
//create user and set the permissions
try {
$tmp_sql = "CREATE USER '".$this->db_username."'@'%' IDENTIFIED BY '".$this->db_password."'; ";
@@ -400,7 +401,7 @@ include "root.php";
print "error: " . $error->getMessage() . "<br/>";
}
}
//set account to unlimited use
try {
if ($this->db_host == "localhost" || $this->db_host == "127.0.0.1") {
@@ -408,7 +409,7 @@ include "root.php";
$tmp_sql .= "IDENTIFIED BY '".$this->db_password."' ";
$tmp_sql .= "WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0; ";
$this->dbh->query($tmp_sql);
$tmp_sql = "GRANT USAGE ON * . * TO '".$this->db_username."'@'127.0.0.1' ";
$tmp_sql .= "IDENTIFIED BY '".$this->db_password."' ";
$tmp_sql .= "WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0; ";
@@ -426,7 +427,7 @@ include "root.php";
print "error: " . $error->getMessage() . "<br/>";
}
}
//create the database and set the create user with permissions
try {
$tmp_sql = "CREATE DATABASE IF NOT EXISTS ".$this->db_name."; ";
@@ -437,7 +438,7 @@ include "root.php";
print "error: " . $error->getMessage() . "<br/>";
}
}
//set user permissions
try {
$this->dbh->query("GRANT ALL PRIVILEGES ON ".$this->db_name.".* TO '".$this->db_username."'@'%'; ");
@@ -447,7 +448,7 @@ include "root.php";
print "error: " . $error->getMessage() . "<br/>";
}
}
//make the changes active
try {
$tmp_sql = "FLUSH PRIVILEGES; ";
@@ -458,9 +459,9 @@ include "root.php";
print "error: " . $error->getMessage() . "<br/>";
}
}
} //if (strlen($this->db_create_username) > 0)
//select the database
try {
$this->dbh->query("USE ".$this->db_name.";");
@@ -470,7 +471,7 @@ include "root.php";
print "error: " . $error->getMessage() . "<br/>";
}
}
//add the database structure
require_once "resources/classes/schema.php";
$schema = new schema;
@@ -478,7 +479,7 @@ include "root.php";
$schema->db_type = $this->db_type;
$schema->sql();
$schema->exec();
//add the defaults data into the database
//get the contents of the sql file
if (file_exists('/usr/share/examples/fusionpbx/resources/install/sql/mysql.sql')){
@@ -488,10 +489,10 @@ include "root.php";
$filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/sql/mysql.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;
@@ -513,7 +514,6 @@ include "root.php";
unset ($file_contents, $sql);
}
protected function create_domain() {
$this->write_progress("Checking if domain exists '" . $this->domain_name . "'");
$sql = "select * from v_domains ";
@@ -530,7 +530,7 @@ include "root.php";
if($result['domain_enabled'] != 'true'){
throw new Exception("Domain already exists but is disabled, this is unexpected");
}
}else{
} else {
$this->write_progress("... creating domain");
$sql = "insert into v_domains ";
$sql .= "(";
@@ -544,11 +544,11 @@ include "root.php";
$sql .= "'".$this->domain_name."', ";
$sql .= "'' ";
$sql .= ");";
$this->write_debug($sql);
$this->dbh->exec(check_sql($sql));
unset($sql);
//domain settings
$x = 0;
$tmp[$x]['name'] = 'uuid';
@@ -580,7 +580,7 @@ include "root.php";
$tmp[$x]['subcategory'] = 'template';
$tmp[$x]['enabled'] = 'true';
$x++;
//switch settings
$tmp[$x]['name'] = 'dir';
$tmp[$x]['value'] = $switch_bin_dir;
@@ -684,7 +684,7 @@ include "root.php";
$tmp[$x]['subcategory'] = 'dialplan';
$tmp[$x]['enabled'] = 'false';
$x++;
//server settings
$tmp[$x]['name'] = 'dir';
$tmp[$x]['value'] = $this->detect_switch->temp_dir();
@@ -705,7 +705,7 @@ include "root.php";
$tmp[$x]['subcategory'] = 'backup';
$tmp[$x]['enabled'] = 'true';
$x++;
$this->dbh->beginTransaction();
foreach($tmp as $row) {
$sql = "insert into v_default_settings ";
@@ -732,7 +732,7 @@ include "root.php";
}
$this->dbh->commit();
unset($tmp);
//get the list of installed apps from the core and mod directories
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
$x=0;
@@ -740,7 +740,7 @@ include "root.php";
include($config_path);
$x++;
}
//add the groups
$x = 0;
$tmp[$x]['group_name'] = 'superadmin';
@@ -814,7 +814,7 @@ include "root.php";
$this->dbh->commit();
}
}
protected function create_superuser() {
$this->write_progress("Checking if superuser exists '" . $this->domain_name . "'");
$sql = "select * from v_users ";
@@ -933,14 +933,14 @@ include "root.php";
unset($sql);
}
}
protected function create_menus() {
$this->write_progress("Creating menus");
//set the defaults
$menu_name = 'default';
$menu_language = 'en-us';
$menu_description = 'Default Menu Set';
$this->write_progress("Checking if menu exists");
$sql = "select count(*) from v_menus ";
$sql .= "where menu_uuid = '".$this->menu_uuid."' ";
@@ -971,7 +971,7 @@ include "root.php";
}
$this->dbh->exec(check_sql($sql));
unset($sql);
//add the menu items
require_once "resources/classes/menu.php";
$menu = new menu;
@@ -981,16 +981,19 @@ include "root.php";
unset($menu);
}
}
protected function app_defaults() {
public function app_defaults() {
$this->write_progress("Running app_defaults");
//set needed session settings
$_SESSION["username"] = $this->admin_username;
$_SESSION["domain_uuid"] = $this->_domain_uuid;
require $this->config_php;
require "resources/require.php";
$_SESSION['event_socket_ip_address'] = $this->detect_switch->event_host;
$_SESSION['event_socket_port'] = $this->detect_switch->event_port;
$_SESSION['event_socket_password'] = $this->detect_switch->event_password;
//get the groups assigned to the user and then set the groups in $_SESSION["groups"]
$sql = "SELECT * FROM v_group_users ";
$sql .= "where domain_uuid=:domain_uuid ";
@@ -1002,7 +1005,7 @@ include "root.php";
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$_SESSION["groups"] = $result;
unset($sql, $row_count, $prep_statement);
//get the permissions assigned to the groups that the user is a member of set the permissions in $_SESSION['permissions']
$x = 0;
$sql = "select distinct(permission_name) from v_group_permissions ";
@@ -1017,37 +1020,41 @@ include "root.php";
$x++;
}
}
$prep_statementsub = $this->dbh->prepare($sql);
$prep_statementsub->execute();
$_SESSION['permissions'] = $prep_statementsub->fetchAll(PDO::FETCH_NAMED);
unset($sql, $prep_statementsub);
$prep_statement_sub = $this->dbh->prepare($sql);
$prep_statement_sub->execute();
$_SESSION['permissions'] = $prep_statement_sub->fetchAll(PDO::FETCH_NAMED);
unset($sql, $prep_statement_sub);
//include the config.php
$db_type = $this->db_type;
$db_path = $this->db_path;
$db_host = $this->db_host;
$db_port = $this->db_port;
$db_name = $this->db_name;
$db_username = $this->db_username;
$db_password = $this->db_password;
//add the database structure
require_once "resources/classes/schema.php";
global $db, $db_type, $db_name, $db_username, $db_password, $db_host, $db_path, $db_port;
$schema = new schema;
echo $schema->schema();
//run all app_defaults.php files
$default_language = $this->install_language;
$domain = new domains;
$domain->upgrade();
//synchronize the config with the saved settings
save_switch_xml();
//do not show the apply settings reminder on the login page
$_SESSION["reload_xml"] = false;
//clear the menu
$_SESSION["menu"] = "";
}
public function remove_config() {
if (file_exists('/bin/rm')) {
$this->write_debug('rm -f ' . $this->config_php);
@@ -1064,4 +1071,5 @@ include "root.php";
clearstatcache();
}
}
?>

View File

@@ -35,7 +35,14 @@ include "root.php";
public $debug = false;
function __construct($domain_name, $domain_uuid, $detect_switch) {
if(!is_a($detect_switch, 'detect_switch')){
if($detect_switch == null){
if(strlen($_SESSION['event_socket_ip_address']) == 0 or strlen($_SESSION['event_socket_port']) == 0 or strlen($_SESSION['event_socket_password']) == 0 ){
throw new Exception('The parameter $detect_switch was empty and i could not find the event socket details from the session');
}
$detect_switch = new detect_switch($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
$domain_name = $_SESSION['domain_name'];
$domain_uuid = $_SESSION['domain_uuid'];
}elseif(!is_a($detect_switch, 'detect_switch')){
throw new Exception('The parameter $detect_switch must be a detect_switch object (or a subclass of)');
}
$this->domain_uuid = $domain_uuid;
@@ -166,13 +173,9 @@ include "root.php";
}
}
function install() {
$this->copy_conf();
$this->copy_scripts();
//tell freeswitch to restart
$this->write_progress("Restarting switch");
$this->detect_switch->restart_switch();
}
function upgrade() {
@@ -182,10 +185,10 @@ include "root.php";
function copy_conf() {
$this->write_progress("Copying Config");
//make a backup of the config
if (file_exists($this->detect_switch->conf_dir())) {
$this->backup_dir($this->detect_switch->conf_dir(), 'fusionpbx_switch_config');
$this->recursive_delete($this->detect_switch->conf_dir());
}
if (file_exists($this->detect_switch->conf_dir())) {
$this->backup_dir($this->detect_switch->conf_dir(), 'fusionpbx_switch_config');
$this->recursive_delete($this->detect_switch->conf_dir());
}
//make sure the conf directory exists
if (!is_dir($this->detect_switch->conf_dir())) {
if (!mkdir($this->detect_switch->conf_dir(), 0774, true)) {
@@ -236,15 +239,21 @@ include "root.php";
function copy_scripts() {
$this->write_progress("Copying Scripts");
if (file_exists($this->detect_switch->script_dir())) {
if (strlen($_SESSION['switch']['scripts']['dir']) > 0) {
$script_dir = $_SESSION['switch']['scripts']['dir'];
}
else {
$script_dir = $this->detect_switch->script_dir();
}
if (file_exists($script_dir)) {
if (file_exists('/usr/share/examples/fusionpbx/resources/install/scripts')){
$src_dir = '/usr/share/examples/fusionpbx/resources/install/scripts';
}
else {
$src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/scripts';
}
$dst_dir = $this->detect_switch->script_dir();
if (is_readable($this->detect_switch->script_dir())) {
$dst_dir = $script_dir;
if (is_readable($script_dir)) {
$this->recursive_copy($src_dir, $dst_dir, $_SESSION['scripts']['options']['text']);
unset($src_dir, $dst_dir);
}

View File

@@ -31,7 +31,7 @@
echo "<input type='hidden' name='install_step' value='execute'/>\n";
echo "<input type='hidden' name='event_host' value='$event_host'/>\n";
echo "<input type='hidden' name='event_port' value='$event_host'/>\n";
echo "<input type='hidden' name='event_port' value='$event_port'/>\n";
echo "<input type='hidden' name='event_password' value='$event_password'/>\n";
echo "<input type='hidden' name='db_type' value='$db_type'/>\n";
echo "<input type='hidden' name='admin_username' value='$admin_username'/>\n";

View File

@@ -31,7 +31,7 @@
echo "<input type='hidden' name='install_step' value='config_database'/>\n";
echo "<input type='hidden' name='event_host' value='$event_host'/>\n";
echo "<input type='hidden' name='event_port' value='$event_host'/>\n";
echo "<input type='hidden' name='event_port' value='$event_port'/>\n";
echo "<input type='hidden' name='event_password' value='$event_password'/>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";

View File

@@ -31,10 +31,10 @@
try {
$switch_detect->detect();
} catch(Exception $e){
$messages[] = "Failed to detect confgiuration detect_switch reported: " . $e->getMessage();
echo "<p><b>Failed to detect configuration</b> detect_switch reported: " . $e->getMessage() ."</p>\n";
$detect_ok = false;
}
echo "<form method='post' name='frm' action=''>\n";
echo "<form method='post' name='detect_switch' action=''>\n";
echo "<input type='hidden' name='install_language' value='".$_SESSION['domain']['language']['code']."'/>\n";
echo "<input type='hidden' name='install_step' value='detect_config'/>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";