mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
Resolved install issues, environment now in tact enough to run app_defaults
This commit is contained in:
@@ -133,15 +133,6 @@ if(!$install_step) { $install_step = 'select_language'; }
|
|||||||
|
|
||||||
//set a default enviroment if first_time
|
//set a default enviroment if first_time
|
||||||
if($first_time_install){
|
if($first_time_install){
|
||||||
//grab the default theme
|
|
||||||
$set_session_theme = 1;
|
|
||||||
$domains_processed = 1;
|
|
||||||
include "themes/enhanced/app_defaults.php";
|
|
||||||
unset($set_session_theme, $domains_processed);
|
|
||||||
//initialize some defaults so we can be 'logged in'
|
|
||||||
$_SESSION['username'] = 'first_time_install';
|
|
||||||
$_SESSION['permissions'][]['permission_name'] = 'superadmin';
|
|
||||||
$_SESSION['menu'] = '';
|
|
||||||
//initialize some varibles to cut down on warnings
|
//initialize some varibles to cut down on warnings
|
||||||
$_SESSION['message'] = '';
|
$_SESSION['message'] = '';
|
||||||
$v_link_label_play = '';
|
$v_link_label_play = '';
|
||||||
@@ -277,7 +268,7 @@ if(!$install_step) { $install_step = 'select_language'; }
|
|||||||
}
|
}
|
||||||
if($detect_ok){
|
if($detect_ok){
|
||||||
$install_ok = true;
|
$install_ok = true;
|
||||||
echo "<pre>\n";
|
echo "<pre style='text-align:left;'>\n";
|
||||||
function error_handler($err_severity, $errstr, $errfile, $errline ) {
|
function error_handler($err_severity, $errstr, $errfile, $errline ) {
|
||||||
if (0 === error_reporting()) { return false;}
|
if (0 === error_reporting()) { return false;}
|
||||||
switch($err_severity)
|
switch($err_severity)
|
||||||
@@ -292,12 +283,12 @@ if(!$install_step) { $install_step = 'select_language'; }
|
|||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set_error_handler("error_handler");
|
#set_error_handler("error_handler");
|
||||||
try {
|
try {
|
||||||
$domain_uuid = uuid();
|
|
||||||
require_once "resources/classes/install_fusionpbx.php";
|
require_once "resources/classes/install_fusionpbx.php";
|
||||||
$fusionPBX = new install_fusionpbx($domain_name, $domain_uuid, $switch_detect);
|
$fusionPBX = new install_fusionpbx($domain_name, null, $switch_detect);
|
||||||
$fusionPBX->debug = true;
|
$domain_uuid = $fusionPBX->domain_uuid();
|
||||||
|
//$fusionPBX->debug = true;
|
||||||
$fusionPBX->admin_username = $admin_username;
|
$fusionPBX->admin_username = $admin_username;
|
||||||
$fusionPBX->admin_password = $admin_password;
|
$fusionPBX->admin_password = $admin_password;
|
||||||
$fusionPBX->default_country = $install_default_country;
|
$fusionPBX->default_country = $install_default_country;
|
||||||
@@ -312,7 +303,7 @@ if(!$install_step) { $install_step = 'select_language'; }
|
|||||||
|
|
||||||
require_once "resources/classes/install_switch.php";
|
require_once "resources/classes/install_switch.php";
|
||||||
$switch = new install_switch($domain_name, $domain_uuid, $switch_detect);
|
$switch = new install_switch($domain_name, $domain_uuid, $switch_detect);
|
||||||
$switch->debug = true;
|
//$switch->debug = true;
|
||||||
$switch->install();
|
$switch->install();
|
||||||
}catch(Exception $e){
|
}catch(Exception $e){
|
||||||
echo "</pre>\n";
|
echo "</pre>\n";
|
||||||
@@ -344,6 +335,17 @@ if(!$install_step) { $install_step = 'select_language'; }
|
|||||||
echo "<p>Unkown install_step '$install_step'</p>\n";
|
echo "<p>Unkown install_step '$install_step'</p>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($first_time_install){
|
||||||
|
//grab the default theme
|
||||||
|
$set_session_theme = 1;
|
||||||
|
$domains_processed = 1;
|
||||||
|
include "themes/enhanced/app_defaults.php";
|
||||||
|
unset($set_session_theme, $domains_processed);
|
||||||
|
//initialize some defaults so we can be 'logged in'
|
||||||
|
$_SESSION['username'] = 'first_time_install';
|
||||||
|
$_SESSION['permissions'][]['permission_name'] = 'superadmin';
|
||||||
|
$_SESSION['menu'] = '';
|
||||||
|
}
|
||||||
// add the content to the template and then send output
|
// add the content to the template and then send output
|
||||||
$body = ob_get_contents(); //get the output from the buffer
|
$body = ob_get_contents(); //get the output from the buffer
|
||||||
ob_end_clean(); //clean the buffer
|
ob_end_clean(); //clean the buffer
|
||||||
|
|||||||
@@ -150,6 +150,13 @@ require_once "resources/classes/EventSocket.php";
|
|||||||
$esl->reset_fp();
|
$esl->reset_fp();
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function restart_switch() {
|
||||||
|
$this->connect_event_socket();
|
||||||
|
if(!$this->event_socket){
|
||||||
|
throw new Exception('Failed to use event socket');
|
||||||
|
}
|
||||||
|
$this->event_socket_request('api fsctl shutdown restart elegant');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -29,12 +29,14 @@ include "root.php";
|
|||||||
//define the install class
|
//define the install class
|
||||||
class install_fusionpbx {
|
class install_fusionpbx {
|
||||||
|
|
||||||
protected $domain_uuid;
|
protected $_domain_uuid;
|
||||||
protected $domain_name;
|
protected $domain_name;
|
||||||
protected $detect_switch;
|
protected $detect_switch;
|
||||||
protected $config_php;
|
protected $config_php;
|
||||||
protected $menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286';
|
protected $menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286';
|
||||||
protected $dbh;
|
protected $dbh;
|
||||||
|
|
||||||
|
public function domain_uuid() { return $this->_domain_uuid; }
|
||||||
|
|
||||||
public $debug = false;
|
public $debug = false;
|
||||||
|
|
||||||
@@ -57,7 +59,8 @@ include "root.php";
|
|||||||
if(!is_a($detect_switch, '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)');
|
throw new Exception('The parameter $detect_switch must be a detect_switch object (or a subclass of)');
|
||||||
}
|
}
|
||||||
$this->domain_uuid = $domain_uuid;
|
if($domain_uuid == null){ $domain_uuid = uuid(); }
|
||||||
|
$this->_domain_uuid = $domain_uuid;
|
||||||
$this->domain_name = $domain_name;
|
$this->domain_name = $domain_name;
|
||||||
$this->detect_switch = $detect_switch;
|
$this->detect_switch = $detect_switch;
|
||||||
if (is_dir("/etc/fusionpbx")){
|
if (is_dir("/etc/fusionpbx")){
|
||||||
@@ -91,7 +94,7 @@ include "root.php";
|
|||||||
$this->create_superuser();
|
$this->create_superuser();
|
||||||
require "resources/require.php";
|
require "resources/require.php";
|
||||||
$this->create_menus();
|
$this->create_menus();
|
||||||
$this->post_create();
|
$this->app_defaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function create_config_php() {
|
protected function create_config_php() {
|
||||||
@@ -196,7 +199,7 @@ include "root.php";
|
|||||||
|
|
||||||
protected function create_database() {
|
protected function create_database() {
|
||||||
require $this->config_php;
|
require $this->config_php;
|
||||||
$this->write_progress("creating database as " . $this->db_type);
|
$this->write_progress("Creating database as " . $this->db_type);
|
||||||
$function = "create_database_" . $this->db_type;
|
$function = "create_database_" . $this->db_type;
|
||||||
$this->$function();
|
$this->$function();
|
||||||
global $db;
|
global $db;
|
||||||
@@ -512,17 +515,23 @@ include "root.php";
|
|||||||
|
|
||||||
|
|
||||||
protected function create_domain() {
|
protected function create_domain() {
|
||||||
$this->write_progress("checking if domain exists '" . $this->domain_name . "'");
|
$this->write_progress("Checking if domain exists '" . $this->domain_name . "'");
|
||||||
$sql = "select count(*) from v_domains ";
|
$sql = "select * from v_domains ";
|
||||||
$sql .= "where domain_name = '".$this->domain_name."' ";
|
$sql .= "where domain_name = '".$this->domain_name."' ";
|
||||||
|
$sql .= "limit 1";
|
||||||
$this->write_debug($sql);
|
$this->write_debug($sql);
|
||||||
$prep_statement = $this->dbh->prepare(check_sql($sql));
|
$prep_statement = $this->dbh->prepare(check_sql($sql));
|
||||||
$prep_statement->execute();
|
$prep_statement->execute();
|
||||||
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
$result = $prep_statement->fetch(PDO::FETCH_NAMED);
|
||||||
unset($sql, $prep_statement);
|
unset($sql, $prep_statement);
|
||||||
if ($row['num_rows'] == 0) {
|
if ($result) {
|
||||||
$this->write_progress("creating domain '" . $this->domain_name . "'");
|
$this->_domain_uuid = $result['domain_uuid'];
|
||||||
|
$this->write_progress("... domain exists as '" . $this->_domain_uuid . "'");
|
||||||
|
if($result['domain_enabled'] != 'true'){
|
||||||
|
throw new Exception("Domain already exists but is disabled, this is unexpected");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$this->write_progress("... creating domain");
|
||||||
$sql = "insert into v_domains ";
|
$sql = "insert into v_domains ";
|
||||||
$sql .= "(";
|
$sql .= "(";
|
||||||
$sql .= "domain_uuid, ";
|
$sql .= "domain_uuid, ";
|
||||||
@@ -531,7 +540,7 @@ include "root.php";
|
|||||||
$sql .= ") ";
|
$sql .= ") ";
|
||||||
$sql .= "values ";
|
$sql .= "values ";
|
||||||
$sql .= "(";
|
$sql .= "(";
|
||||||
$sql .= "'".$this->domain_uuid."', ";
|
$sql .= "'".$this->_domain_uuid."', ";
|
||||||
$sql .= "'".$this->domain_name."', ";
|
$sql .= "'".$this->domain_name."', ";
|
||||||
$sql .= "'' ";
|
$sql .= "'' ";
|
||||||
$sql .= ");";
|
$sql .= ");";
|
||||||
@@ -801,123 +810,180 @@ include "root.php";
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function create_superuser() {
|
protected function create_superuser() {
|
||||||
//check if it exists first?
|
$this->write_progress("Checking if superuser exists '" . $this->domain_name . "'");
|
||||||
$this->write_progress("creating super user '" . $this->admin_username . "'");
|
$sql = "select * from v_users ";
|
||||||
//add a user and then add the user to the superadmin group
|
$sql .= "where domain_uuid = '".$this->_domain_uuid."' ";
|
||||||
//prepare the values
|
$sql .= "and username = '".$this->admin_username."' ";
|
||||||
$this->admin_uuid = uuid();
|
$sql .= "limit 1 ";
|
||||||
$contact_uuid = uuid();
|
$this->write_debug($sql);
|
||||||
//set a sessiong variable
|
$prep_statement = $this->dbh->prepare(check_sql($sql));
|
||||||
$_SESSION["user_uuid"] = $user_uuid;
|
$prep_statement->execute();
|
||||||
//salt used with the password to create a one way hash
|
$result = $prep_statement->fetch(PDO::FETCH_NAMED);
|
||||||
|
unset($sql, $prep_statement);
|
||||||
$salt = generate_password('20', '4');
|
$salt = generate_password('20', '4');
|
||||||
//add the user account
|
if ($result) {
|
||||||
$sql = "insert into v_users ";
|
$this->admin_uuid = $result['user_uuid'];
|
||||||
$sql .= "(";
|
$this->write_progress("... superuser exists as '" . $this->admin_uuid . "', updating password");
|
||||||
$sql .= "domain_uuid, ";
|
$sql = "update v_users ";
|
||||||
$sql .= "user_uuid, ";
|
$sql .= "set password = '".md5($salt.$this->admin_password)."' ";
|
||||||
$sql .= "contact_uuid, ";
|
$sql .= "set salt = '$salt' ";
|
||||||
$sql .= "username, ";
|
$sql .= "where USER_uuid = '".$this->admin_uuid."' ";
|
||||||
$sql .= "password, ";
|
$this->write_debug($sql);
|
||||||
$sql .= "salt, ";
|
$this->dbh->exec(check_sql($sql));
|
||||||
$sql .= "add_date, ";
|
}else{
|
||||||
$sql .= "add_user ";
|
$this->write_progress("... creating super user '" . $this->admin_username . "'");
|
||||||
$sql .= ") ";
|
//add a user and then add the user to the superadmin group
|
||||||
$sql .= "values ";
|
//prepare the values
|
||||||
$sql .= "(";
|
$this->admin_uuid = uuid();
|
||||||
$sql .= "'".$this->domain_uuid."', ";
|
$contact_uuid = uuid();
|
||||||
$sql .= "'".$this->admin_uuid."', ";
|
//set a sessiong variable
|
||||||
$sql .= "'$contact_uuid', ";
|
$_SESSION["user_uuid"] = $user_uuid;
|
||||||
$sql .= "'".$this->admin_username."', ";
|
//salt used with the password to create a one way hash
|
||||||
$sql .= "'".md5($salt.$this->admin_password)."', ";
|
//add the user account
|
||||||
$sql .= "'$salt', ";
|
$sql = "insert into v_users ";
|
||||||
$sql .= "now(), ";
|
$sql .= "(";
|
||||||
$sql .= "'".$this->admin_username."' ";
|
$sql .= "domain_uuid, ";
|
||||||
$sql .= ");";
|
$sql .= "user_uuid, ";
|
||||||
$this->write_debug( $sql."\n");
|
$sql .= "contact_uuid, ";
|
||||||
$this->dbh->exec(check_sql($sql));
|
$sql .= "username, ";
|
||||||
unset($sql);
|
$sql .= "password, ";
|
||||||
|
$sql .= "salt, ";
|
||||||
//add to contacts
|
$sql .= "add_date, ";
|
||||||
$sql = "insert into v_contacts ";
|
$sql .= "add_user ";
|
||||||
$sql .= "(";
|
$sql .= ") ";
|
||||||
$sql .= "domain_uuid, ";
|
$sql .= "values ";
|
||||||
$sql .= "contact_uuid, ";
|
$sql .= "(";
|
||||||
$sql .= "contact_type, ";
|
$sql .= "'".$this->_domain_uuid."', ";
|
||||||
$sql .= "contact_name_given, ";
|
$sql .= "'".$this->admin_uuid."', ";
|
||||||
$sql .= "contact_nickname ";
|
$sql .= "'$contact_uuid', ";
|
||||||
$sql .= ") ";
|
$sql .= "'".$this->admin_username."', ";
|
||||||
$sql .= "values ";
|
$sql .= "'".md5($salt.$this->admin_password)."', ";
|
||||||
$sql .= "(";
|
$sql .= "'$salt', ";
|
||||||
$sql .= "'".$this->domain_uuid."', ";
|
$sql .= "now(), ";
|
||||||
$sql .= "'$contact_uuid', ";
|
$sql .= "'".$this->admin_username."' ";
|
||||||
$sql .= "'user', ";
|
$sql .= ");";
|
||||||
$sql .= "'".$this->admin_username."', ";
|
$this->write_debug( $sql."\n");
|
||||||
$sql .= "'".$this->admin_username."' ";
|
$this->dbh->exec(check_sql($sql));
|
||||||
$sql .= ")";
|
unset($sql);
|
||||||
$this->dbh->exec(check_sql($sql));
|
}
|
||||||
unset($sql);
|
$this->write_progress("Checking if superuser contact exists");
|
||||||
|
$sql = "select count(*) from v_contacts ";
|
||||||
//add the user to the superadmin group
|
$sql .= "where domain_uuid = '".$this->_domain_uuid."' ";
|
||||||
$sql = "insert into v_group_users ";
|
$sql .= "and contact_name_given = '".$this->admin_username."' ";
|
||||||
$sql .= "(";
|
$sql .= "and contact_nickname = '".$this->admin_username."' ";
|
||||||
$sql .= "group_user_uuid, ";
|
$sql .= "limit 1 ";
|
||||||
$sql .= "domain_uuid, ";
|
$this->write_debug($sql);
|
||||||
$sql .= "user_uuid, ";
|
$prep_statement = $this->dbh->prepare(check_sql($sql));
|
||||||
$sql .= "group_name ";
|
$prep_statement->execute();
|
||||||
$sql .= ") ";
|
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
||||||
$sql .= "values ";
|
if ($row['count'] == 0) {
|
||||||
$sql .= "(";
|
$sql = "insert into v_contacts ";
|
||||||
$sql .= "'".uuid()."', ";
|
$sql .= "(";
|
||||||
$sql .= "'".$this->domain_uuid."', ";
|
$sql .= "domain_uuid, ";
|
||||||
$sql .= "'".$this->admin_uuid."', ";
|
$sql .= "contact_uuid, ";
|
||||||
$sql .= "'superadmin' ";
|
$sql .= "contact_type, ";
|
||||||
$sql .= ");";
|
$sql .= "contact_name_given, ";
|
||||||
$this->write_debug( $sql."\n");
|
$sql .= "contact_nickname ";
|
||||||
$this->dbh->exec(check_sql($sql));
|
$sql .= ") ";
|
||||||
unset($sql);
|
$sql .= "values ";
|
||||||
|
$sql .= "(";
|
||||||
|
$sql .= "'".$this->_domain_uuid."', ";
|
||||||
|
$sql .= "'$contact_uuid', ";
|
||||||
|
$sql .= "'user', ";
|
||||||
|
$sql .= "'".$this->admin_username."', ";
|
||||||
|
$sql .= "'".$this->admin_username."' ";
|
||||||
|
$sql .= ")";
|
||||||
|
$this->dbh->exec(check_sql($sql));
|
||||||
|
unset($sql);
|
||||||
|
}
|
||||||
|
$this->write_progress("Checking if superuser is in the correct group");
|
||||||
|
$sql = "select count(*) from v_group_users ";
|
||||||
|
$sql .= "where domain_uuid = '".$this->_domain_uuid."' ";
|
||||||
|
$sql .= "and user_uuid = '".$this->admin_uuid."' ";
|
||||||
|
$sql .= "and group_name = 'superadmin' ";
|
||||||
|
$sql .= "limit 1 ";
|
||||||
|
$this->write_debug($sql);
|
||||||
|
$prep_statement = $this->dbh->prepare(check_sql($sql));
|
||||||
|
$prep_statement->execute();
|
||||||
|
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
||||||
|
if ($row['count'] == 0) {
|
||||||
|
//add the user to the superadmin group
|
||||||
|
$sql = "insert into v_group_users ";
|
||||||
|
$sql .= "(";
|
||||||
|
$sql .= "group_user_uuid, ";
|
||||||
|
$sql .= "domain_uuid, ";
|
||||||
|
$sql .= "user_uuid, ";
|
||||||
|
$sql .= "group_name ";
|
||||||
|
$sql .= ") ";
|
||||||
|
$sql .= "values ";
|
||||||
|
$sql .= "(";
|
||||||
|
$sql .= "'".uuid()."', ";
|
||||||
|
$sql .= "'".$this->_domain_uuid."', ";
|
||||||
|
$sql .= "'".$this->admin_uuid."', ";
|
||||||
|
$sql .= "'superadmin' ";
|
||||||
|
$sql .= ");";
|
||||||
|
$this->write_debug( $sql."\n");
|
||||||
|
$this->dbh->exec(check_sql($sql));
|
||||||
|
unset($sql);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function create_menus() {
|
protected function create_menus() {
|
||||||
$this->write_progress("creating menus");
|
$this->write_progress("Creating menus");
|
||||||
//set the defaults
|
//set the defaults
|
||||||
$menu_name = 'default';
|
$menu_name = 'default';
|
||||||
$menu_language = 'en-us';
|
$menu_language = 'en-us';
|
||||||
$menu_description = 'Default Menu Set';
|
$menu_description = 'Default Menu Set';
|
||||||
//add the parent menu
|
|
||||||
$sql = "insert into v_menus ";
|
$this->write_progress("Checking if menu exists");
|
||||||
$sql .= "(";
|
$sql = "select count(*) from v_menus ";
|
||||||
$sql .= "menu_uuid, ";
|
$sql .= "where menu_uuid = '".$this->menu_uuid."' ";
|
||||||
$sql .= "menu_name, ";
|
$sql .= "limit 1 ";
|
||||||
$sql .= "menu_language, ";
|
$this->write_debug($sql);
|
||||||
$sql .= "menu_description ";
|
$prep_statement = $this->dbh->prepare(check_sql($sql));
|
||||||
$sql .= ") ";
|
$prep_statement->execute();
|
||||||
$sql .= "values ";
|
$result = $prep_statement->fetch(PDO::FETCH_NAMED);
|
||||||
$sql .= "(";
|
unset($sql, $prep_statement);
|
||||||
$sql .= "'".$this->menu_uuid."', ";
|
if ($result['count'] == 0) {
|
||||||
$sql .= "'$menu_name', ";
|
$this->write_progress("... creating menu '" . $menu_name. "'");
|
||||||
$sql .= "'$menu_language', ";
|
$sql = "insert into v_menus ";
|
||||||
$sql .= "'$menu_description' ";
|
$sql .= "(";
|
||||||
$sql .= ");";
|
$sql .= "menu_uuid, ";
|
||||||
if ($this->debug) {
|
$sql .= "menu_name, ";
|
||||||
$this->write_debug( $sql."\n");
|
$sql .= "menu_language, ";
|
||||||
|
$sql .= "menu_description ";
|
||||||
|
$sql .= ") ";
|
||||||
|
$sql .= "values ";
|
||||||
|
$sql .= "(";
|
||||||
|
$sql .= "'".$this->menu_uuid."', ";
|
||||||
|
$sql .= "'$menu_name', ";
|
||||||
|
$sql .= "'$menu_language', ";
|
||||||
|
$sql .= "'$menu_description' ";
|
||||||
|
$sql .= ");";
|
||||||
|
if ($this->debug) {
|
||||||
|
$this->write_debug( $sql."\n");
|
||||||
|
}
|
||||||
|
$this->dbh->exec(check_sql($sql));
|
||||||
|
unset($sql);
|
||||||
|
|
||||||
|
//add the menu items
|
||||||
|
require_once "resources/classes/menu.php";
|
||||||
|
$menu = new menu;
|
||||||
|
$menu->db = $this->dbh;
|
||||||
|
$menu->menu_uuid = $this->menu_uuid;
|
||||||
|
$menu->restore();
|
||||||
|
unset($menu);
|
||||||
}
|
}
|
||||||
$this->dbh->exec(check_sql($sql));
|
|
||||||
unset($sql);
|
|
||||||
|
|
||||||
//add the menu items
|
|
||||||
require_once "resources/classes/menu.php";
|
|
||||||
$menu = new menu;
|
|
||||||
$menu->db = $this->dbh;
|
|
||||||
$menu->menu_uuid = $this->menu_uuid;
|
|
||||||
$menu->restore();
|
|
||||||
unset($menu);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function post_create() {
|
protected function app_defaults() {
|
||||||
$this->write_progress("running post steps");
|
$this->write_progress("Running app_defaults");
|
||||||
//login the user account
|
|
||||||
|
//set needed session settings
|
||||||
$_SESSION["username"] = $this->admin_username;
|
$_SESSION["username"] = $this->admin_username;
|
||||||
|
$_SESSION["domain_uuid"] = $this->_domain_uuid;
|
||||||
|
require $this->config_php;
|
||||||
|
require "resources/require.php";
|
||||||
|
|
||||||
//get the groups assigned to the user and then set the groups in $_SESSION["groups"]
|
//get the groups assigned to the user and then set the groups in $_SESSION["groups"]
|
||||||
$sql = "SELECT * FROM v_group_users ";
|
$sql = "SELECT * FROM v_group_users ";
|
||||||
@@ -949,17 +1015,19 @@ include "root.php";
|
|||||||
$prep_statementsub->execute();
|
$prep_statementsub->execute();
|
||||||
$_SESSION['permissions'] = $prep_statementsub->fetchAll(PDO::FETCH_NAMED);
|
$_SESSION['permissions'] = $prep_statementsub->fetchAll(PDO::FETCH_NAMED);
|
||||||
unset($sql, $prep_statementsub);
|
unset($sql, $prep_statementsub);
|
||||||
|
|
||||||
//make sure the database schema and installation have performed all necessary tasks
|
|
||||||
$display_results = false;
|
|
||||||
$display_type = 'none';
|
|
||||||
|
|
||||||
require_once "resources/classes/schema.php";
|
require_once "resources/classes/schema.php";
|
||||||
$obj = new schema;
|
global $db, $db_type, $db_name, $db_username, $db_password, $db_host, $db_path, $db_port;
|
||||||
$obj->schema($this->dbh, $this->db_type, $this->db_name, $display_type);
|
|
||||||
|
$schema = new schema;
|
||||||
|
echo $schema->schema();
|
||||||
|
|
||||||
//run all app_defaults.php files
|
//run all app_defaults.php files
|
||||||
$default_language = $this->install_language;
|
$default_language = $this->install_language;
|
||||||
require_once "resources/classes/domains.php";
|
|
||||||
$domain = new domains;
|
$domain = new domains;
|
||||||
$domain->upgrade();
|
$domain->upgrade();
|
||||||
|
|
||||||
@@ -971,6 +1039,7 @@ include "root.php";
|
|||||||
|
|
||||||
//clear the menu
|
//clear the menu
|
||||||
$_SESSION["menu"] = "";
|
$_SESSION["menu"] = "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function remove_config() {
|
public function remove_config() {
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ include "root.php";
|
|||||||
//pharData is the correct ay to do it, but it keeps creating incomplete archives
|
//pharData is the correct ay to do it, but it keeps creating incomplete archives
|
||||||
//$tar = new PharData($dst_tar);
|
//$tar = new PharData($dst_tar);
|
||||||
//$tar->buildFromDirectory($dir);
|
//$tar->buildFromDirectory($dir);
|
||||||
$this->write_debug("backingup to $dst_tar");
|
$this->write_debug("backing up to $dst_tar");
|
||||||
if (file_exists('/bin/tar')) {
|
if (file_exists('/bin/tar')) {
|
||||||
exec('tar -cvf ' .$dst_tar. ' -C '.$dir .' .');
|
exec('tar -cvf ' .$dst_tar. ' -C '.$dir .' .');
|
||||||
}else{
|
}else{
|
||||||
@@ -166,9 +166,13 @@ include "root.php";
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function install() {
|
function install() {
|
||||||
$this->copy_conf();
|
$this->copy_conf();
|
||||||
$this->copy_scripts();
|
$this->copy_scripts();
|
||||||
|
//tell freeswitch to restart
|
||||||
|
$this->write_progress("Restarting switch");
|
||||||
|
$this->detect_switch->restart_switch();
|
||||||
}
|
}
|
||||||
|
|
||||||
function upgrade() {
|
function upgrade() {
|
||||||
|
|||||||
@@ -1,207 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
FusionPBX
|
|
||||||
Version: MPL 1.1
|
|
||||||
|
|
||||||
The contents of this file are subject to the Mozilla Public License Version
|
|
||||||
1.1 (the "License"); you may not use this file except in compliance with
|
|
||||||
the License. You may obtain a copy of the License at
|
|
||||||
http://www.mozilla.org/MPL/
|
|
||||||
|
|
||||||
Software distributed under the License is distributed on an "AS IS" basis,
|
|
||||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
||||||
for the specific language governing rights and limitations under the
|
|
||||||
License.
|
|
||||||
|
|
||||||
The Original Code is FusionPBX
|
|
||||||
|
|
||||||
The Initial Developer of the Original Code is
|
|
||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
|
||||||
Copyright (C) 2010-2015
|
|
||||||
All Rights Reserved.
|
|
||||||
|
|
||||||
Contributor(s):
|
|
||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
|
||||||
*/
|
|
||||||
include "root.php";
|
|
||||||
|
|
||||||
//define the install class
|
|
||||||
class install {
|
|
||||||
|
|
||||||
var $result;
|
|
||||||
var $domain_uuid;
|
|
||||||
var $domain;
|
|
||||||
var $switch_conf_dir;
|
|
||||||
var $switch_scripts_dir;
|
|
||||||
var $switch_sounds_dir;
|
|
||||||
|
|
||||||
//$options '-n' --no-clobber
|
|
||||||
public function recursive_copy($src, $dst, $options = '') {
|
|
||||||
if (file_exists('/bin/cp')) {
|
|
||||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'SUN') {
|
|
||||||
//copy -R recursive, preserve attributes for SUN
|
|
||||||
$cmd = 'cp -Rp '.$src.'/* '.$dst;
|
|
||||||
} else {
|
|
||||||
//copy -R recursive, -L follow symbolic links, -p preserve attributes for other Posix systemss
|
|
||||||
$cmd = 'cp -RLp '.$options.' '.$src.'/* '.$dst;
|
|
||||||
}
|
|
||||||
exec ($cmd);
|
|
||||||
//echo $cmd."\n";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$dir = opendir($src);
|
|
||||||
if (!$dir) {
|
|
||||||
if (!mkdir($src, 0755, true)) {
|
|
||||||
throw new Exception("recursive_copy() source directory '".$src."' does not exist.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!is_dir($dst)) {
|
|
||||||
if (!mkdir($dst, 0755, true)) {
|
|
||||||
throw new Exception("recursive_copy() failed to create destination directory '".$dst."'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$scripts_dir_target = $_SESSION['switch']['scripts']['dir'];
|
|
||||||
$scripts_dir_source = realpath($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/scripts');
|
|
||||||
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($src)) as $file_path_source) {
|
|
||||||
if (
|
|
||||||
substr_count($file_path_source, '/..') == 0 &&
|
|
||||||
substr_count($file_path_source, '/.') == 0 &&
|
|
||||||
substr_count($file_path_source, '/.svn') == 0 &&
|
|
||||||
substr_count($file_path_source, '/.git') == 0
|
|
||||||
) {
|
|
||||||
if ($dst != $src.'/resources/config.lua') {
|
|
||||||
//echo $file_path_source.' ---> '.$dst.'<br>';
|
|
||||||
copy($file_path_source, $dst);
|
|
||||||
chmod($dst, 0755);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while(false !== ($file = readdir($dir))) {
|
|
||||||
if (($file != '.') && ($file != '..')) {
|
|
||||||
if (is_dir($src.'/'.$file)) {
|
|
||||||
$this->recursive_copy($src.'/'.$file, $dst.'/'.$file);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
//copy only missing files -n --no-clobber
|
|
||||||
if (strpos($options,'-n') !== false) {
|
|
||||||
if (!file_exists($dst.'/'.$file)) {
|
|
||||||
copy($src.'/'.$file, $dst.'/'.$file);
|
|
||||||
//echo "copy(".$src."/".$file.", ".$dst."/".$file.");<br />\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
copy($src.'/'.$file, $dst.'/'.$file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
closedir($dir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function recursive_delete($dir) {
|
|
||||||
if (file_exists('/bin/rm')) {
|
|
||||||
exec ('rm -Rf '.$dir.'/*');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach (glob($dir) as $file) {
|
|
||||||
if (is_dir($file)) {
|
|
||||||
$this->recursive_delete("$file/*");
|
|
||||||
rmdir($file);
|
|
||||||
//echo "rm dir: ".$file."\n";
|
|
||||||
} else {
|
|
||||||
//echo "delete file: ".$file."\n";
|
|
||||||
unlink($file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
clearstatcache();
|
|
||||||
}
|
|
||||||
|
|
||||||
function copy() {
|
|
||||||
$this->copy_scripts();
|
|
||||||
//$this->copy_sounds();
|
|
||||||
}
|
|
||||||
|
|
||||||
function copy_conf() {
|
|
||||||
if (file_exists($this->switch_conf_dir)) {
|
|
||||||
//make a backup copy of the conf directory
|
|
||||||
$src_dir = $this->switch_conf_dir;
|
|
||||||
$dst_dir = $this->switch_conf_dir.'.orig';
|
|
||||||
if (is_readable($src_dir)) {
|
|
||||||
$this->recursive_copy($src_dir, $dst_dir);
|
|
||||||
$this->recursive_delete($src_dir);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if ($src_dir != "/conf") {
|
|
||||||
mkdir($src_dir, 0774, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//make sure the conf directory exists
|
|
||||||
if (!is_dir($this->switch_conf_dir)) {
|
|
||||||
if (!mkdir($this->switch_conf_dir, 0774, true)) {
|
|
||||||
throw new Exception("Failed to create the switch conf directory '".$this->switch_conf_dir."'. ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//copy resources/templates/conf to the freeswitch conf dir
|
|
||||||
if (file_exists('/usr/share/examples/fusionpbx/resources/templates/conf')){
|
|
||||||
$src_dir = "/usr/share/examples/fusionpbx/resources/templates/conf";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/conf";
|
|
||||||
}
|
|
||||||
$dst_dir = $this->switch_conf_dir;
|
|
||||||
if (is_readable($dst_dir)) {
|
|
||||||
$this->recursive_copy($src_dir, $dst_dir);
|
|
||||||
}
|
|
||||||
//print_r($install->result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// added /examples/ into the string
|
|
||||||
function copy_scripts() {
|
|
||||||
if (file_exists($this->switch_scripts_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->switch_scripts_dir;
|
|
||||||
if (is_readable($this->switch_scripts_dir)) {
|
|
||||||
$this->recursive_copy($src_dir, $dst_dir, $_SESSION['scripts']['options']['text']);
|
|
||||||
unset($src_dir, $dst_dir);
|
|
||||||
}
|
|
||||||
chmod($dst_dir, 0774);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//function copy_sounds() {
|
|
||||||
// if (file_exists($this->switch_sounds_dir)) {
|
|
||||||
// if (file_exists('/usr/share/examples/fusionpbx/resources/install/sounds/en/us/callie/custom/')){
|
|
||||||
// $src_dir = '/usr/share/examples/fusionpbx/resources/install/sounds/en/us/callie/custom/';
|
|
||||||
// changes the output dir for testing
|
|
||||||
// $dst_dir = $this->switch_sounds_dir.'/en/us/fusionpbx/custom/';
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// $src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/sounds/en/us/callie/custom/';
|
|
||||||
// $dst_dir = $this->switch_sounds_dir.'/en/us/callie/custom/';
|
|
||||||
// }
|
|
||||||
// $this->recursive_copy($src_dir, $dst_dir, "-n");
|
|
||||||
// if (is_readable($this->switch_sounds_dir)) {
|
|
||||||
// $this->recursive_copy($src_dir, $dst_dir);
|
|
||||||
// chmod($dst_dir, 0664);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
//how to use the class
|
|
||||||
//$install = new install;
|
|
||||||
//$install->domain_uuid = $domain_uuid;
|
|
||||||
//$install->switch_conf_dir = $switch_conf_dir;
|
|
||||||
//$install->switch_scripts_dir = $switch_scripts_dir;
|
|
||||||
//$install->switch_sounds_dir = $switch_sounds_dir;
|
|
||||||
//$install->copy();
|
|
||||||
//print_r($install->result);
|
|
||||||
?>
|
|
||||||
Reference in New Issue
Block a user