|
@@ -35,11 +35,11 @@ include "root.php";
|
|
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 function domain_uuid() { return $this->_domain_uuid; }
|
|
|
|
|
|
public $debug = false;
|
|
public $debug = false;
|
|
-
|
|
|
|
|
|
+
|
|
public $install_msg;
|
|
public $install_msg;
|
|
public $install_language = 'en-us';
|
|
public $install_language = 'en-us';
|
|
public $admin_username;
|
|
public $admin_username;
|
|
@@ -54,7 +54,7 @@ include "root.php";
|
|
public $db_name;
|
|
public $db_name;
|
|
public $db_username;
|
|
public $db_username;
|
|
public $db_password;
|
|
public $db_password;
|
|
-
|
|
|
|
|
|
+
|
|
function __construct($domain_name, $domain_uuid, $detect_switch) {
|
|
function __construct($domain_name, $domain_uuid, $detect_switch) {
|
|
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)');
|
|
@@ -94,9 +94,8 @@ include "root.php";
|
|
$this->create_superuser();
|
|
$this->create_superuser();
|
|
require "resources/require.php";
|
|
require "resources/require.php";
|
|
$this->create_menus();
|
|
$this->create_menus();
|
|
- $this->app_defaults();
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
protected function create_config_php() {
|
|
protected function create_config_php() {
|
|
$tmp_config = "<?php\n";
|
|
$tmp_config = "<?php\n";
|
|
$tmp_config .= "/* \$Id\$ */\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 .= " error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ); //hide notices and warnings";
|
|
$tmp_config .= "\n";
|
|
$tmp_config .= "\n";
|
|
$tmp_config .= "?>";
|
|
$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 . "'" );
|
|
throw new Exception("cannot write to '" . $this->config_php . "'" );
|
|
}
|
|
}
|
|
$this->write_progress("Creating " . $this->config_php);
|
|
$this->write_progress("Creating " . $this->config_php);
|
|
@@ -196,7 +196,7 @@ include "root.php";
|
|
unset($tmp_config);
|
|
unset($tmp_config);
|
|
fclose($fout);
|
|
fclose($fout);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
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);
|
|
@@ -205,6 +205,7 @@ include "root.php";
|
|
global $db;
|
|
global $db;
|
|
$db = $this->dbh;
|
|
$db = $this->dbh;
|
|
}
|
|
}
|
|
|
|
+
|
|
protected function create_database_sqlite() {
|
|
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 {
|
|
try {
|
|
@@ -268,7 +269,7 @@ include "root.php";
|
|
}
|
|
}
|
|
|
|
|
|
protected function create_database_pgsql() {
|
|
protected function create_database_pgsql() {
|
|
-
|
|
|
|
|
|
+
|
|
//if $this->db_create_username provided, attempt to create new PG role and database
|
|
//if $this->db_create_username provided, attempt to create new PG role and database
|
|
if (strlen($this->db_create_username) > 0) {
|
|
if (strlen($this->db_create_username) > 0) {
|
|
try {
|
|
try {
|
|
@@ -281,16 +282,16 @@ include "root.php";
|
|
} catch (PDOException $error) {
|
|
} catch (PDOException $error) {
|
|
throw new Exception("error connecting to database: " . $error->getMessage());
|
|
throw new Exception("error connecting to database: " . $error->getMessage());
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
//create the database, user, grant perms
|
|
//create the database, user, grant perms
|
|
$this->dbh->exec("CREATE DATABASE {$this->db_name}");
|
|
$this->dbh->exec("CREATE DATABASE {$this->db_name}");
|
|
$this->dbh->exec("CREATE USER {$this->db_username} WITH PASSWORD '{$this->db_password}'");
|
|
$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}");
|
|
$this->dbh->exec("GRANT ALL ON {$this->db_name} TO {$this->db_username}");
|
|
-
|
|
|
|
|
|
+
|
|
//close database connection_aborted
|
|
//close database connection_aborted
|
|
$this->dbh = null;
|
|
$this->dbh = null;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
//open database connection with $this->db_name
|
|
//open database connection with $this->db_name
|
|
try {
|
|
try {
|
|
if (strlen($this->db_port) == 0) { $this->db_port = "5432"; }
|
|
if (strlen($this->db_port) == 0) { $this->db_port = "5432"; }
|
|
@@ -303,7 +304,7 @@ include "root.php";
|
|
catch (PDOException $error) {
|
|
catch (PDOException $error) {
|
|
throw new Exception("error connecting to database: " . $error->getMessage());
|
|
throw new Exception("error connecting to database: " . $error->getMessage());
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
//add the database structure
|
|
//add the database structure
|
|
require_once "resources/classes/schema.php";
|
|
require_once "resources/classes/schema.php";
|
|
$schema = new schema;
|
|
$schema = new schema;
|
|
@@ -311,7 +312,7 @@ include "root.php";
|
|
$schema->db_type = $this->db_type;
|
|
$schema->db_type = $this->db_type;
|
|
$schema->sql();
|
|
$schema->sql();
|
|
$schema->exec();
|
|
$schema->exec();
|
|
-
|
|
|
|
|
|
+
|
|
//get the contents of the sql file
|
|
//get the contents of the sql file
|
|
if (file_exists('/usr/share/examples/fusionpbx/resources/install/sql/pgsql.sql')){
|
|
if (file_exists('/usr/share/examples/fusionpbx/resources/install/sql/pgsql.sql')){
|
|
$filename = "/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';
|
|
$filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/sql/pgsql.sql';
|
|
}
|
|
}
|
|
$file_contents = file_get_contents($filename);
|
|
$file_contents = file_get_contents($filename);
|
|
-
|
|
|
|
|
|
+
|
|
//replace \r\n with \n then explode on \n
|
|
//replace \r\n with \n then explode on \n
|
|
$file_contents = str_replace("\r\n", "\n", $file_contents);
|
|
$file_contents = str_replace("\r\n", "\n", $file_contents);
|
|
-
|
|
|
|
|
|
+
|
|
//loop line by line through all the lines of sql code
|
|
//loop line by line through all the lines of sql code
|
|
$string_array = explode("\n", $file_contents);
|
|
$string_array = explode("\n", $file_contents);
|
|
$x = 0;
|
|
$x = 0;
|
|
@@ -340,7 +341,7 @@ include "root.php";
|
|
}
|
|
}
|
|
unset ($file_contents, $sql);
|
|
unset ($file_contents, $sql);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
protected function create_database_mysql() {
|
|
protected function create_database_mysql() {
|
|
//database connection
|
|
//database connection
|
|
try {
|
|
try {
|
|
@@ -377,7 +378,7 @@ include "root.php";
|
|
catch (PDOException $error) {
|
|
catch (PDOException $error) {
|
|
throw new Exception("error creating database: " . $error->getMessage() . "\n" . $sql );
|
|
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
|
|
//create the table, user and set the permissions only if the db_create_username was provided
|
|
if (strlen($this->db_create_username) > 0) {
|
|
if (strlen($this->db_create_username) > 0) {
|
|
//select the mysql database
|
|
//select the mysql database
|
|
@@ -389,7 +390,7 @@ include "root.php";
|
|
throw new Exception("error conencting to database: " . $error->getMessage());
|
|
throw new Exception("error conencting to database: " . $error->getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
//create user and set the permissions
|
|
//create user and set the permissions
|
|
try {
|
|
try {
|
|
$tmp_sql = "CREATE USER '".$this->db_username."'@'%' IDENTIFIED BY '".$this->db_password."'; ";
|
|
$tmp_sql = "CREATE USER '".$this->db_username."'@'%' IDENTIFIED BY '".$this->db_password."'; ";
|
|
@@ -400,7 +401,7 @@ include "root.php";
|
|
print "error: " . $error->getMessage() . "<br/>";
|
|
print "error: " . $error->getMessage() . "<br/>";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
//set account to unlimited use
|
|
//set account to unlimited use
|
|
try {
|
|
try {
|
|
if ($this->db_host == "localhost" || $this->db_host == "127.0.0.1") {
|
|
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 .= "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; ";
|
|
$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);
|
|
$this->dbh->query($tmp_sql);
|
|
-
|
|
|
|
|
|
+
|
|
$tmp_sql = "GRANT USAGE ON * . * TO '".$this->db_username."'@'127.0.0.1' ";
|
|
$tmp_sql = "GRANT USAGE ON * . * TO '".$this->db_username."'@'127.0.0.1' ";
|
|
$tmp_sql .= "IDENTIFIED BY '".$this->db_password."' ";
|
|
$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; ";
|
|
$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/>";
|
|
print "error: " . $error->getMessage() . "<br/>";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
//create the database and set the create user with permissions
|
|
//create the database and set the create user with permissions
|
|
try {
|
|
try {
|
|
$tmp_sql = "CREATE DATABASE IF NOT EXISTS ".$this->db_name."; ";
|
|
$tmp_sql = "CREATE DATABASE IF NOT EXISTS ".$this->db_name."; ";
|
|
@@ -437,7 +438,7 @@ include "root.php";
|
|
print "error: " . $error->getMessage() . "<br/>";
|
|
print "error: " . $error->getMessage() . "<br/>";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
//set user permissions
|
|
//set user permissions
|
|
try {
|
|
try {
|
|
$this->dbh->query("GRANT ALL PRIVILEGES ON ".$this->db_name.".* TO '".$this->db_username."'@'%'; ");
|
|
$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/>";
|
|
print "error: " . $error->getMessage() . "<br/>";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
//make the changes active
|
|
//make the changes active
|
|
try {
|
|
try {
|
|
$tmp_sql = "FLUSH PRIVILEGES; ";
|
|
$tmp_sql = "FLUSH PRIVILEGES; ";
|
|
@@ -458,9 +459,9 @@ include "root.php";
|
|
print "error: " . $error->getMessage() . "<br/>";
|
|
print "error: " . $error->getMessage() . "<br/>";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
} //if (strlen($this->db_create_username) > 0)
|
|
} //if (strlen($this->db_create_username) > 0)
|
|
-
|
|
|
|
|
|
+
|
|
//select the database
|
|
//select the database
|
|
try {
|
|
try {
|
|
$this->dbh->query("USE ".$this->db_name.";");
|
|
$this->dbh->query("USE ".$this->db_name.";");
|
|
@@ -470,7 +471,7 @@ include "root.php";
|
|
print "error: " . $error->getMessage() . "<br/>";
|
|
print "error: " . $error->getMessage() . "<br/>";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
//add the database structure
|
|
//add the database structure
|
|
require_once "resources/classes/schema.php";
|
|
require_once "resources/classes/schema.php";
|
|
$schema = new schema;
|
|
$schema = new schema;
|
|
@@ -478,7 +479,7 @@ include "root.php";
|
|
$schema->db_type = $this->db_type;
|
|
$schema->db_type = $this->db_type;
|
|
$schema->sql();
|
|
$schema->sql();
|
|
$schema->exec();
|
|
$schema->exec();
|
|
-
|
|
|
|
|
|
+
|
|
//add the defaults data into the database
|
|
//add the defaults data into the database
|
|
//get the contents of the sql file
|
|
//get the contents of the sql file
|
|
if (file_exists('/usr/share/examples/fusionpbx/resources/install/sql/mysql.sql')){
|
|
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';
|
|
$filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/sql/mysql.sql';
|
|
}
|
|
}
|
|
$file_contents = file_get_contents($filename);
|
|
$file_contents = file_get_contents($filename);
|
|
-
|
|
|
|
|
|
+
|
|
//replace \r\n with \n then explode on \n
|
|
//replace \r\n with \n then explode on \n
|
|
$file_contents = str_replace("\r\n", "\n", $file_contents);
|
|
$file_contents = str_replace("\r\n", "\n", $file_contents);
|
|
-
|
|
|
|
|
|
+
|
|
//loop line by line through all the lines of sql code
|
|
//loop line by line through all the lines of sql code
|
|
$string_array = explode("\n", $file_contents);
|
|
$string_array = explode("\n", $file_contents);
|
|
$x = 0;
|
|
$x = 0;
|
|
@@ -513,7 +514,6 @@ include "root.php";
|
|
unset ($file_contents, $sql);
|
|
unset ($file_contents, $sql);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
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 * from v_domains ";
|
|
$sql = "select * from v_domains ";
|
|
@@ -530,7 +530,7 @@ include "root.php";
|
|
if($result['domain_enabled'] != 'true'){
|
|
if($result['domain_enabled'] != 'true'){
|
|
throw new Exception("Domain already exists but is disabled, this is unexpected");
|
|
throw new Exception("Domain already exists but is disabled, this is unexpected");
|
|
}
|
|
}
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
$this->write_progress("... creating domain");
|
|
$this->write_progress("... creating domain");
|
|
$sql = "insert into v_domains ";
|
|
$sql = "insert into v_domains ";
|
|
$sql .= "(";
|
|
$sql .= "(";
|
|
@@ -544,11 +544,11 @@ include "root.php";
|
|
$sql .= "'".$this->domain_name."', ";
|
|
$sql .= "'".$this->domain_name."', ";
|
|
$sql .= "'' ";
|
|
$sql .= "'' ";
|
|
$sql .= ");";
|
|
$sql .= ");";
|
|
-
|
|
|
|
|
|
+
|
|
$this->write_debug($sql);
|
|
$this->write_debug($sql);
|
|
$this->dbh->exec(check_sql($sql));
|
|
$this->dbh->exec(check_sql($sql));
|
|
unset($sql);
|
|
unset($sql);
|
|
-
|
|
|
|
|
|
+
|
|
//domain settings
|
|
//domain settings
|
|
$x = 0;
|
|
$x = 0;
|
|
$tmp[$x]['name'] = 'uuid';
|
|
$tmp[$x]['name'] = 'uuid';
|
|
@@ -580,7 +580,7 @@ include "root.php";
|
|
$tmp[$x]['subcategory'] = 'template';
|
|
$tmp[$x]['subcategory'] = 'template';
|
|
$tmp[$x]['enabled'] = 'true';
|
|
$tmp[$x]['enabled'] = 'true';
|
|
$x++;
|
|
$x++;
|
|
-
|
|
|
|
|
|
+
|
|
//switch settings
|
|
//switch settings
|
|
$tmp[$x]['name'] = 'dir';
|
|
$tmp[$x]['name'] = 'dir';
|
|
$tmp[$x]['value'] = $switch_bin_dir;
|
|
$tmp[$x]['value'] = $switch_bin_dir;
|
|
@@ -684,7 +684,7 @@ include "root.php";
|
|
$tmp[$x]['subcategory'] = 'dialplan';
|
|
$tmp[$x]['subcategory'] = 'dialplan';
|
|
$tmp[$x]['enabled'] = 'false';
|
|
$tmp[$x]['enabled'] = 'false';
|
|
$x++;
|
|
$x++;
|
|
-
|
|
|
|
|
|
+
|
|
//server settings
|
|
//server settings
|
|
$tmp[$x]['name'] = 'dir';
|
|
$tmp[$x]['name'] = 'dir';
|
|
$tmp[$x]['value'] = $this->detect_switch->temp_dir();
|
|
$tmp[$x]['value'] = $this->detect_switch->temp_dir();
|
|
@@ -705,7 +705,7 @@ include "root.php";
|
|
$tmp[$x]['subcategory'] = 'backup';
|
|
$tmp[$x]['subcategory'] = 'backup';
|
|
$tmp[$x]['enabled'] = 'true';
|
|
$tmp[$x]['enabled'] = 'true';
|
|
$x++;
|
|
$x++;
|
|
-
|
|
|
|
|
|
+
|
|
$this->dbh->beginTransaction();
|
|
$this->dbh->beginTransaction();
|
|
foreach($tmp as $row) {
|
|
foreach($tmp as $row) {
|
|
$sql = "insert into v_default_settings ";
|
|
$sql = "insert into v_default_settings ";
|
|
@@ -732,7 +732,7 @@ include "root.php";
|
|
}
|
|
}
|
|
$this->dbh->commit();
|
|
$this->dbh->commit();
|
|
unset($tmp);
|
|
unset($tmp);
|
|
-
|
|
|
|
|
|
+
|
|
//get the list of installed apps from the core and mod directories
|
|
//get the list of installed apps from the core and mod directories
|
|
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
|
|
$config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
|
|
$x=0;
|
|
$x=0;
|
|
@@ -740,7 +740,7 @@ include "root.php";
|
|
include($config_path);
|
|
include($config_path);
|
|
$x++;
|
|
$x++;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
//add the groups
|
|
//add the groups
|
|
$x = 0;
|
|
$x = 0;
|
|
$tmp[$x]['group_name'] = 'superadmin';
|
|
$tmp[$x]['group_name'] = 'superadmin';
|
|
@@ -814,7 +814,7 @@ include "root.php";
|
|
$this->dbh->commit();
|
|
$this->dbh->commit();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
protected function create_superuser() {
|
|
protected function create_superuser() {
|
|
$this->write_progress("Checking if superuser exists '" . $this->domain_name . "'");
|
|
$this->write_progress("Checking if superuser exists '" . $this->domain_name . "'");
|
|
$sql = "select * from v_users ";
|
|
$sql = "select * from v_users ";
|
|
@@ -933,14 +933,14 @@ include "root.php";
|
|
unset($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';
|
|
-
|
|
|
|
|
|
+
|
|
$this->write_progress("Checking if menu exists");
|
|
$this->write_progress("Checking if menu exists");
|
|
$sql = "select count(*) from v_menus ";
|
|
$sql = "select count(*) from v_menus ";
|
|
$sql .= "where menu_uuid = '".$this->menu_uuid."' ";
|
|
$sql .= "where menu_uuid = '".$this->menu_uuid."' ";
|
|
@@ -971,7 +971,7 @@ include "root.php";
|
|
}
|
|
}
|
|
$this->dbh->exec(check_sql($sql));
|
|
$this->dbh->exec(check_sql($sql));
|
|
unset($sql);
|
|
unset($sql);
|
|
-
|
|
|
|
|
|
+
|
|
//add the menu items
|
|
//add the menu items
|
|
require_once "resources/classes/menu.php";
|
|
require_once "resources/classes/menu.php";
|
|
$menu = new menu;
|
|
$menu = new menu;
|
|
@@ -981,16 +981,19 @@ include "root.php";
|
|
unset($menu);
|
|
unset($menu);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- protected function app_defaults() {
|
|
|
|
|
|
+
|
|
|
|
+ public function app_defaults() {
|
|
$this->write_progress("Running app_defaults");
|
|
$this->write_progress("Running app_defaults");
|
|
-
|
|
|
|
|
|
+
|
|
//set needed session settings
|
|
//set needed session settings
|
|
$_SESSION["username"] = $this->admin_username;
|
|
$_SESSION["username"] = $this->admin_username;
|
|
$_SESSION["domain_uuid"] = $this->_domain_uuid;
|
|
$_SESSION["domain_uuid"] = $this->_domain_uuid;
|
|
require $this->config_php;
|
|
require $this->config_php;
|
|
require "resources/require.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"]
|
|
//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 ";
|
|
$sql .= "where domain_uuid=:domain_uuid ";
|
|
$sql .= "where domain_uuid=:domain_uuid ";
|
|
@@ -1002,7 +1005,7 @@ include "root.php";
|
|
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
|
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
|
$_SESSION["groups"] = $result;
|
|
$_SESSION["groups"] = $result;
|
|
unset($sql, $row_count, $prep_statement);
|
|
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']
|
|
//get the permissions assigned to the groups that the user is a member of set the permissions in $_SESSION['permissions']
|
|
$x = 0;
|
|
$x = 0;
|
|
$sql = "select distinct(permission_name) from v_group_permissions ";
|
|
$sql = "select distinct(permission_name) from v_group_permissions ";
|
|
@@ -1017,37 +1020,41 @@ include "root.php";
|
|
$x++;
|
|
$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";
|
|
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;
|
|
$schema = new schema;
|
|
echo $schema->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;
|
|
$domain = new domains;
|
|
$domain = new domains;
|
|
$domain->upgrade();
|
|
$domain->upgrade();
|
|
-
|
|
|
|
|
|
+
|
|
//synchronize the config with the saved settings
|
|
//synchronize the config with the saved settings
|
|
save_switch_xml();
|
|
save_switch_xml();
|
|
-
|
|
|
|
|
|
+
|
|
//do not show the apply settings reminder on the login page
|
|
//do not show the apply settings reminder on the login page
|
|
$_SESSION["reload_xml"] = false;
|
|
$_SESSION["reload_xml"] = false;
|
|
-
|
|
|
|
|
|
+
|
|
//clear the menu
|
|
//clear the menu
|
|
$_SESSION["menu"] = "";
|
|
$_SESSION["menu"] = "";
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public function remove_config() {
|
|
public function remove_config() {
|
|
if (file_exists('/bin/rm')) {
|
|
if (file_exists('/bin/rm')) {
|
|
$this->write_debug('rm -f ' . $this->config_php);
|
|
$this->write_debug('rm -f ' . $this->config_php);
|
|
@@ -1064,4 +1071,5 @@ include "root.php";
|
|
clearstatcache();
|
|
clearstatcache();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
?>
|
|
?>
|