fusionpbx/core/install/resources/classes/install.php

168 lines
5.7 KiB
PHP
Raw Normal View History

2022-10-22 23:22:47 +02:00
<?php
2022-10-23 03:13:32 +02:00
2022-10-22 23:22:47 +02:00
class install {
/**
* declare the variables
*/
private $app_name;
private $app_uuid;
2022-10-23 03:21:48 +02:00
public $message;
2022-10-23 00:44:19 +02:00
public $database_host;
public $database_port;
public $database_name;
public $database_username;
public $database_password;
2022-10-22 23:22:47 +02:00
/**
* called when the object is created
*/
public function __construct() {
//assign the variables
$this->app_name = 'install';
$this->app_uuid = '75507e6e-891e-11e5-af63-feff819cdc9f';
}
/**
2022-10-23 03:13:32 +02:00
* <p>Used to create the config.conf file.</p>
* <p>BSD /usr/local/etc/fusionpbx</p>
* <p>Linux /etc/fusionpbx</p>
* @return boolean
2022-10-22 23:22:47 +02:00
*/
public function config() {
2022-10-23 00:44:19 +02:00
//set the default config file location
$os = strtoupper(substr(PHP_OS, 0, 3));
switch ($os) {
2024-07-14 17:51:20 +02:00
case "FRE":
case "OPE":
case "NET":
case "BSD":
2022-10-23 00:44:19 +02:00
$config_path = '/usr/local/etc/fusionpbx';
$config_file = $config_path.'/config.conf';
$document_root = '/usr/local/www/fusionpbx';
$conf_dir = '/usr/local/etc/freeswitch';
$sounds_dir = '/usr/share/freeswitch/sounds';
$database_dir = '/var/lib/freeswitch/db';
$recordings_dir = '/var/lib/freeswitch/recordings';
$storage_dir = '/var/lib/freeswitch/storage';
$voicemail_dir = '/var/lib/freeswitch/storage/voicemail';
$scripts_dir = '/usr/share/freeswitch/scripts';
$php_dir = PHP_BINDIR;
$cache_location = '/var/cache/fusionpbx';
break;
case "LIN":
2022-10-23 00:44:19 +02:00
$config_path = '/etc/fusionpbx/';
$config_file = $config_path.'/config.conf';
$document_root = '/var/www/fusionpbx';
$conf_dir = '/etc/freeswitch';
$sounds_dir = '/usr/share/freeswitch/sounds';
$database_dir = '/var/lib/freeswitch/db';
$recordings_dir = '/var/lib/freeswitch/recordings';
$storage_dir = '/var/lib/freeswitch/storage';
$voicemail_dir = '/var/lib/freeswitch/storage/voicemail';
$scripts_dir = '/usr/share/freeswitch/scripts';
$php_dir = PHP_BINDIR;
$cache_location = '/var/cache/fusionpbx';
break;
case "WIN":
$system_drive = getenv('SystemDrive');
$config_path = $system_drive . DIRECTORY_SEPARATOR . 'ProgramData' . DIRECTORY_SEPARATOR . 'fusionpbx' ;
$config_file = $config_path.DIRECTORY_SEPARATOR.'config.conf';
$document_root = $_SERVER["DOCUMENT_ROOT"];
$conf_dir = $_SERVER['ProgramFiles'].DIRECTORY_SEPARATOR.'freeswitch'.DIRECTORY_SEPARATOR.'conf';
$sounds_dir = $_SERVER['ProgramFiles'].DIRECTORY_SEPARATOR.'freeswitch'.DIRECTORY_SEPARATOR.'sounds';
$database_dir = $_SERVER['ProgramFiles'].DIRECTORY_SEPARATOR.'freeswitch'.DIRECTORY_SEPARATOR.'db';
$recordings_dir = $_SERVER['ProgramFiles'].DIRECTORY_SEPARATOR.'freeswitch'.DIRECTORY_SEPARATOR.'recordings';
$storage_dir = $_SERVER['ProgramFiles'].DIRECTORY_SEPARATOR.'freeswitch'.DIRECTORY_SEPARATOR.'storage';
$voicemail_dir = $_SERVER['ProgramFiles'].DIRECTORY_SEPARATOR.'freeswitch'.DIRECTORY_SEPARATOR.'voicemail';
$scripts_dir = $_SERVER['ProgramFiles'].DIRECTORY_SEPARATOR.'freeswitch'.DIRECTORY_SEPARATOR.'scripts';
$php_dir = dirname(PHP_BINARY);
$cache_location = dirname($_SERVER['DOCUMENT_ROOT']).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.'fusionpbx';
break;
2022-10-23 00:44:19 +02:00
}
2022-10-23 03:13:32 +02:00
//end the script if the config path is not set
if (!isset($config_path)) {
2022-10-23 03:21:48 +02:00
$this->message = "Config file path not found\n";
2022-10-23 03:13:32 +02:00
return false;
}
//config directory is not writable
if (!is_writable($config_path)) {
2022-10-23 03:21:48 +02:00
$this->message = "Check permissions ".$config_path." must be writable.\n";
2022-10-23 03:13:32 +02:00
return false;
}
//make the config directory
if (isset($config_path)) {
system('mkdir -p '.$config_path);
}
2022-10-23 00:44:19 +02:00
//build the config file
$conf = "\n";
$conf .= "#database system settings\n";
$conf .= "database.0.type = pgsql\n";
$conf .= "database.0.host = ".$this->database_host."\n";
$conf .= "database.0.port = ".$this->database_port."\n";
$conf .= "database.0.sslmode = prefer\n";
$conf .= "database.0.name = ".$this->database_name."\n";
$conf .= "database.0.username = ".$this->database_username."\n";
$conf .= "database.0.password = ".$this->database_password."\n";
$conf .= "\n";
$conf .= "#database switch settings\n";
2022-10-26 21:52:30 +02:00
$conf .= "database.1.type = sqlite\n";
$conf .= "database.1.path = ".$database_dir."\n";
$conf .= "database.1.name = core.db\n";
//$conf .= "database.1.backend.base64 = \n";
2022-10-23 00:44:19 +02:00
$conf .= "\n";
$conf .= "#general settings\n";
$conf .= "document.root = ".$document_root."\n";
$conf .= "project.path =\n";
$conf .= "temp.dir = /tmp\n";
$conf .= "php.dir = ".$php_dir."\n";
2022-10-23 00:44:19 +02:00
$conf .= "php.bin = php\n";
$conf .= "\n";
$conf .= "#cache settings\n";
$conf .= "cache.method = file\n";
$conf .= "cache.location = ".$cache_location."\n";
2022-10-23 00:44:19 +02:00
$conf .= "cache.settings = true\n";
$conf .= "\n";
$conf .= "#switch settings\n";
$conf .= "switch.conf.dir = ".$conf_dir."\n";
$conf .= "switch.sounds.dir = ".$sounds_dir."\n";
$conf .= "switch.database.dir = ".$database_dir."\n";
$conf .= "switch.recordings.dir = ".$recordings_dir."\n";
$conf .= "switch.storage.dir = ".$storage_dir."\n";
$conf .= "switch.voicemail.dir = ".$voicemail_dir."\n";
$conf .= "switch.scripts.dir = ".$scripts_dir."\n";
$conf .= "\n";
$conf .= "#switch xml handler\n";
$conf .= "xml_handler.fs_path = false\n";
$conf .= "xml_handler.reg_as_number_alias = false\n";
$conf .= "xml_handler.number_as_presence_id = true\n";
$conf .= "\n";
$conf .= "#error reporting options: user,dev,all\n";
$conf .= "error.reporting = user\n";
2022-10-23 00:44:19 +02:00
//write the config file
$file_handle = fopen($config_file,"w");
if(!$file_handle) { return; }
fwrite($file_handle, $conf);
fclose($file_handle);
Allow namespace in auto loader (#7307) * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove class_exists wrapper for class definitions * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove include statement of class file * remove closing tag * remove invalid method params * remove closing tag * remove closing tag * Update auto_loader to load each class file in the project Update the auto_loader class to use an include statement on each file in the project to load the class within the file. This will allow mismatched names within the file to be loaded and mapped according to the declaration instead of the filename. The class is then checked against the parsed classes from the PHP engine so that namespaces are available and mapped to the file they were declared in. An update was also made to the search algorithm used to find a file that was not already loaded by collapsing the array to have only valid matches to increase performance on a cache miss. Logging within the auto_loader has been moved to a function. Multiple files were modified to allow the include statement. When the class has the `if(class_exists())` statement, the auto_loader is called to check for the class. This caused an infinite loop scenario so all wrappers have been removed. The auto_loader will now break the loop by directly modifying the internal classes array instead of trying to restart with the 'reload_classes' method. - APCu is used to cache classes so any loading of the classes is done only once. To clear the APCu cache, restart php-fpm or call the auto_loader::clear_cache() function. - Cache file is used when APCu is not available. To clear the cache remove it from the tmp folder or call the auto_loader::clear_cache() function. - All classes must no longer have a class_exists wrapper to benefit from the performance boost. - Classes should not be directly included when the auto_loader is used. * remove include statement of class file * Update destinations.php
2025-03-12 20:55:47 +01:00
2022-10-23 03:13:32 +02:00
//if the config.conf file was saved return true
if (file_exists($config_file)) {
return true;
}
else {
return false;
}
2022-10-23 00:44:19 +02:00
2022-10-22 23:22:47 +02:00
}
}