浏览代码

Update install.php (#6699)

* Changed If statement to Switch Case. 
* Added Win option
* Created new Var $php_dir and $cache_location
jrmcclean 2 年之前
父节点
当前提交
1f05f84efe
共有 1 个文件被更改,包括 28 次插入5 次删除
  1. 28 5
      core/install/resources/classes/install.php

+ 28 - 5
core/install/resources/classes/install.php

@@ -33,7 +33,9 @@ if (!class_exists('install')) {
 		public function config() {
 
 			//set the default config file location
-			if (stristr(PHP_OS, 'BSD')) {
+			$os = strtoupper(substr(PHP_OS, 0, 3));
+			switch ($os) {
+			case "BSD":
 				$config_path = '/usr/local/etc/fusionpbx';
 				$config_file = $config_path.'/config.conf';
 				$document_root = '/usr/local/www/fusionpbx';
@@ -45,8 +47,10 @@ if (!class_exists('install')) {
 				$storage_dir = '/var/lib/freeswitch/storage';
 				$voicemail_dir = '/var/lib/freeswitch/storage/voicemail';
 				$scripts_dir = '/usr/share/freeswitch/scripts';
-			}
-			if (stristr(PHP_OS, 'Linux')) {
+				$php_dir = PHP_BINDIR;
+				$cache_location = '/var/cache/fusionpbx';
+				break;
+			case "LIN":
 				$config_path = '/etc/fusionpbx/';
 				$config_file = $config_path.'/config.conf';
 				$document_root = '/var/www/fusionpbx';
@@ -58,6 +62,25 @@ if (!class_exists('install')) {
 				$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":
+				$config_path = $_SERVER["DOCUMENT_ROOT"].DIRECTORY_SEPARATOR.'resources';
+				$config_file = $config_path.DIRECTORY_SEPARATOR.'config.conf';
+				$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;
 			}
 
 			//end the script if the config path is not set
@@ -98,12 +121,12 @@ if (!class_exists('install')) {
 			$conf .= "document.root = ".$document_root."\n";
 			$conf .= "project.path =\n";
 			$conf .= "temp.dir = /tmp\n";
-			$conf .= "php.dir = ".PHP_BINDIR."\n";
+			$conf .= "php.dir = ".$php_dir."\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.location = ".$cache_location."\n";
 			$conf .= "cache.settings = true\n";
 			$conf .= "\n";
 			$conf .= "#switch settings\n";