Forráskód Böngészése

Update upgrade.php

FusionPBX 2 éve
szülő
commit
90d14a02f0
1 módosított fájl, 119 hozzáadás és 12 törlés
  1. 119 12
      core/upgrade/upgrade.php

+ 119 - 12
core/upgrade/upgrade.php

@@ -24,18 +24,125 @@
 	Mark J Crane <[email protected]>
 	Mark J Crane <[email protected]>
 */
 */
 
 
+
+//add the document root to the include path
+	$config_glob = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
+	if (is_array($config_glob) && count($config_glob) > 0) {
+		$config_glob = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
+		$conf = parse_ini_file($config_glob[0]);
+		set_include_path($conf['document.root']);
+	}
+	else {
+		//include the config.php
+		$config_php_glob = glob("{/usr/local/etc,/etc}/fusionpbx/config.php", GLOB_BRACE);
+		include($config_php_glob[0]);
+
+		//set the default config file location
+		if (stristr(PHP_OS, 'BSD')) {
+			$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';
+		}
+		if (stristr(PHP_OS, 'Linux')) {
+			$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';
+		}
+
+		//make the config directory
+		if (isset($config_path)) {
+			system('mkdir -p '.$config_path);
+		}
+		else {
+			echo "config directory not found\n";
+			exit;
+		}
+
+		//build the config file
+		$conf = "\n";
+		$conf .= "#database system settings\n";
+		$conf .= "database.0.type = ".$db_type."\n";
+		$conf .= "database.0.host = ".$db_host."\n";
+		$conf .= "database.0.port = ".$db_port."\n";
+		$conf .= "database.0.sslmode=prefer\n";
+		$conf .= "database.0.name = ".$db_name."\n";
+		$conf .= "database.0.username = ".$db_username."\n";
+		$conf .= "database.0.password = ".$db_password."\n";
+		$conf .= "\n";
+		$conf .= "#database switch settings\n";
+		$conf .= "database.1.type = ".$db_type."\n";
+		$conf .= "database.1.host = ".$db_host."\n";
+		$conf .= "database.1.port = ".$db_port."\n";
+		$conf .= "database.1.sslmode=prefer\n";
+		$conf .= "database.1.name = freeswitch\n";
+		$conf .= "database.1.username = freeswitch\n";
+		$conf .= "database.1.password = ".$db_password."\n";
+		$conf .= "database.1.backend.base64 = \n";
+		$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_BINDIR."\n";
+		$conf .= "php.bin = php\n";
+		$conf .= "\n";
+		$conf .= "#cache settings\n";
+		$conf .= "cache.method = file\n";
+		$conf .= "cache.location = /var/cache/fusionpbx\n";
+		$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 hide show all errors except notices and warnings\n";
+		$conf .= "error.reporting = 'E_ALL ^ E_NOTICE ^ E_WARNING'\n";
+
+		//write the config file
+		$file_handle = fopen($config_file,"w");
+		if(!$file_handle){ return; }
+		fwrite($file_handle, $conf);
+		fclose($file_handle);
+
+		//set the include path
+		$config_glob = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
+		$conf = parse_ini_file($config_glob[0]);
+		set_include_path($conf['document.root']);
+	}
+
 //check the permission
 //check the permission
 	if(defined('STDIN')) {
 	if(defined('STDIN')) {
-		$document_root = str_replace("\\", "/", $_SERVER["PHP_SELF"]);
-		preg_match("/^(.*)\/core\/.*$/", $document_root, $matches);
-		$document_root = $matches[1];
-		set_include_path($document_root);
 		require_once "resources/require.php";
 		require_once "resources/require.php";
 		$_SERVER["DOCUMENT_ROOT"] = $document_root;
 		$_SERVER["DOCUMENT_ROOT"] = $document_root;
 		$display_type = 'text'; //html, text
 		$display_type = 'text'; //html, text
 	}
 	}
 	else {
 	else {
-		require_once "root.php";
 		require_once "resources/require.php";
 		require_once "resources/require.php";
 		require_once "resources/check_auth.php";
 		require_once "resources/check_auth.php";
 		if (permission_exists('upgrade_schema') || permission_exists('upgrade_source') || if_group("superadmin")) {
 		if (permission_exists('upgrade_schema') || permission_exists('upgrade_source') || if_group("superadmin")) {
@@ -108,7 +215,7 @@
 			$included = true;
 			$included = true;
 			require_once("core/menu/menu_restore_default.php");
 			require_once("core/menu/menu_restore_default.php");
 			unset($sel_menu);
 			unset($sel_menu);
-		
+
 			//send message to the console
 			//send message to the console
 			echo $text['message-upgrade_menu']."\n";
 			echo $text['message-upgrade_menu']."\n";
 		}
 		}
@@ -130,7 +237,7 @@
 			require_once "resources/classes/text.php";
 			require_once "resources/classes/text.php";
 			$language = new text;
 			$language = new text;
 			$text = $language->get();
 			$text = $language->get();
-		
+
 		//show the title
 		//show the title
 			if ($display_type == 'text') {
 			if ($display_type == 'text') {
 				echo "\n";
 				echo "\n";
@@ -139,18 +246,18 @@
 				echo "\n";
 				echo "\n";
 				echo $text['label-database']."\n";
 				echo $text['label-database']."\n";
 			}
 			}
-		
+
 		//make sure the database schema and installation have performed all necessary tasks
 		//make sure the database schema and installation have performed all necessary tasks
 			require_once "resources/classes/schema.php";
 			require_once "resources/classes/schema.php";
 			$obj = new schema;
 			$obj = new schema;
 			echo $obj->schema("text");
 			echo $obj->schema("text");
-		
+
 		//run all app_defaults.php files
 		//run all app_defaults.php files
 			require_once "resources/classes/domains.php";
 			require_once "resources/classes/domains.php";
 			$domain = new domains;
 			$domain = new domains;
 			$domain->display_type = $display_type;
 			$domain->display_type = $display_type;
 			$domain->upgrade();
 			$domain->upgrade();
-		
+
 		//show the content
 		//show the content
 			if ($display_type == 'html') {
 			if ($display_type == 'html') {
 				echo "<div align='center'>\n";
 				echo "<div align='center'>\n";
@@ -163,7 +270,7 @@
 				echo "</tr>\n";
 				echo "</tr>\n";
 				echo "</table>\n";
 				echo "</table>\n";
 				echo "</div>\n";
 				echo "</div>\n";
-		
+
 				echo "<br />\n";
 				echo "<br />\n";
 				echo "<br />\n";
 				echo "<br />\n";
 				echo "<br />\n";
 				echo "<br />\n";
@@ -175,7 +282,7 @@
 			elseif ($display_type == 'text') {
 			elseif ($display_type == 'text') {
 				echo "\n";
 				echo "\n";
 			}
 			}
-		
+
 		//include the footer
 		//include the footer
 			if ($display_type == "html") {
 			if ($display_type == "html") {
 				require_once "resources/footer.php";
 				require_once "resources/footer.php";