Quellcode durchsuchen

Merge branch 'master' of https://github.com/fusionpbx/fusionpbx

markjcrane vor 9 Jahren
Ursprung
Commit
2b8212ee02

+ 3 - 0
core/databases/app_defaults.php

@@ -126,6 +126,9 @@ if ($domains_processed == 1) {
 				$config = $_SESSION['switch']['scripts']['dir']."/resources/config.lua";
 			}
 			$fout = fopen($config,"w");
+			if(!$fout){
+				throw new Exception("Failed to open '$config' for writing");
+			}
 			$tmp = "\n";
 			$tmp .= "--set the variables\n";
 			if (strlen($_SESSION['switch']['sounds']['dir']) > 0) {

+ 2 - 15
core/install/index.php

@@ -78,23 +78,10 @@ if (!if_group("superadmin")) {
 	echo "</table>\n";
 	echo "</form>\n";
 
-	echo "<form name='frm' method='post' action='/core/install/install_add_switch.php'>\n";
-	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
-	echo "<tr>\n";
-	echo "	<td width='30%' class='vncell'>\n";
-	echo "		<input id='do_add-switch' type='submit' class='btn' value='".$text['label-add-switch']."'/>";
-	echo "	</td>\n";
-	echo "	<td width='70%' class='vtable' style='height: 50px;'>\n";
-	echo "		<label for='do_add-switch'>";
-	echo "			".$text['description-add-switch'];
-	echo "		</label>\n";
-	echo "	</td>\n";
-	echo "</tr>\n";
-	echo "</table>\n";
-	echo "</form>\n";
-
 	echo "<br><br>";
 
+	echo "<p>WiP</p>";
+
 //include the footer
 	require_once "resources/footer.php";
 ?>

+ 14 - 3
core/install/install_first_time.php

@@ -63,7 +63,7 @@ if (is_link('/etc/localtime')) {
     // Ubuntu / Debian.
     $data = file_get_contents('/etc/timezone');
     if ($data) {
-        $timezone = $data;
+        $timezone = rtrim($data);
     }
 } elseif (file_exists('/etc/sysconfig/clock')) {
     // RHEL / CentOS
@@ -221,6 +221,9 @@ if(!$install_step) { $install_step = 'select_language'; }
 		echo "	</div>\n";
 		echo "</form>\n";
 	}elseif($install_step == 'detect_config'){
+		if(!($event_host == '' || $event_host == 'localhost' || $event_host == '::1' || $event_host == '127.0.0.1' )){
+			echo "<p><b>Warning</b> you have choosen a value other than localhost for event_host, this is unsoported at present</p>\n";
+		}
 		include "resources/page_parts/install_event_socket.php";
 		if($detect_ok){
 			echo "<form method='post' name='frm' action=''>\n";
@@ -235,6 +238,12 @@ if(!$install_step) { $install_step = 'select_language'; }
 			echo "    <button type='submit' id='next'>".$text['button-next']."</button>\n";
 			echo "	</div>\n";
 			echo "</form>\n";
+		}else{
+			echo "<form method='post' name='frm' action=''>\n";
+			echo "	<div style='text-align:right'>\n";
+			echo "    <button type='button' onclick=\"history.go(-1);\">".$text['button-back']."</button>\n";
+			echo "	</div>\n";
+			echo "</form>\n";
 		}
 	}
 	elseif($install_step == 'config_detail'){
@@ -284,7 +293,6 @@ if(!$install_step) { $install_step = 'select_language'; }
 				require_once "resources/classes/install_fusionpbx.php";
 				$fusionPBX = new install_fusionpbx($domain_name, null, $switch_detect);
 				$domain_uuid = $fusionPBX->domain_uuid();
-				//$fusionPBX->debug = true;
 				$fusionPBX->admin_username = $admin_username;
 				$fusionPBX->admin_password = $admin_password;
 				$fusionPBX->default_country = $install_default_country;
@@ -295,12 +303,15 @@ if(!$install_step) { $install_step = 'select_language'; }
 						$fusionPBX->$key = $value;
 					}
 				}
-				$fusionPBX->install();
 
 				require_once "resources/classes/install_switch.php";
 				$switch = new install_switch($domain_name, $domain_uuid, $switch_detect);
 				//$switch->debug = true;
+				//$fusionPBX->debug = true;
+				$fusionPBX->install();
 				$switch->install();
+				$fusionPBX->app_defaults();
+				$switch_detect->restart_switch();
 			}catch(Exception $e){
 				echo "</pre>\n";
 				echo "<p><b>Failed to install</b><br/>" . $e->getMessage() . "</p>\n";

+ 5 - 7
core/install/resources/classes/install_fusionpbx.php

@@ -94,7 +94,6 @@ include "root.php";
 			$this->create_superuser();
 			require "resources/require.php";
 			$this->create_menus();
-			$this->app_defaults();
 		}
 		
 		protected function create_config_php() {
@@ -976,7 +975,7 @@ include "root.php";
 			}
 		}
 		
-		protected function app_defaults() {
+		public function app_defaults() {
 			$this->write_progress("Running app_defaults");
 			
 		//set needed session settings
@@ -984,7 +983,10 @@ include "root.php";
 			$_SESSION["domain_uuid"] = $this->_domain_uuid;
 			require $this->config_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"]
 			$sql = "SELECT * FROM v_group_users ";
 			$sql .= "where domain_uuid=:domain_uuid ";
@@ -1016,10 +1018,6 @@ include "root.php";
 			$_SESSION['permissions'] = $prep_statementsub->fetchAll(PDO::FETCH_NAMED);
 			unset($sql, $prep_statementsub);
 
-
-
-
-			
 			require_once "resources/classes/schema.php";
 			global $db, $db_type, $db_name, $db_username, $db_password, $db_host, $db_path, $db_port;
 	

+ 10 - 6
core/install/resources/classes/install_switch.php

@@ -35,9 +35,16 @@ include "root.php";
 		public $debug = false;
 
 		function __construct($domain_name, $domain_uuid, $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)');
-			//}
+			if($detect_switch == null){
+				if(strlen($_SESSION['event_socket_ip_address']) == 0 or strlen($_SESSION['event_socket_port']) == 0 or strlen($_SESSION['event_socket_password']) == 0 ){
+					throw new Exception('The parameter $detect_switch was empty and i could not find the event socket details from the session');
+				}
+				$detect_switch = new detect_switch($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
+				$domain_name = $_SESSION['domain_name'];
+				$domain_uuid = $_SESSION['domain_uuid'];
+			}elseif(!is_a($detect_switch, 'detect_switch')){
+				throw new Exception('The parameter $detect_switch must be a detect_switch object (or a subclass of)');
+			}
 			$this->domain_uuid = $domain_uuid;
 			$this->domain = $domain_name;
 			$this->detect_switch = $detect_switch;
@@ -169,9 +176,6 @@ include "root.php";
 		function install() {
 			$this->copy_conf();
 			$this->copy_scripts();
-			//tell freeswitch to restart
-			$this->write_progress("Restarting switch");
-			$this->detect_switch->restart_switch();
 		}
 
 		function upgrade() {

+ 1 - 1
core/install/resources/page_parts/install_config_database.php

@@ -31,7 +31,7 @@
 	echo "<input type='hidden' name='install_step' value='execute'/>\n";
 
 	echo "<input type='hidden' name='event_host' value='$event_host'/>\n";
-	echo "<input type='hidden' name='event_port' value='$event_host'/>\n";
+	echo "<input type='hidden' name='event_port' value='$event_port'/>\n";
 	echo "<input type='hidden' name='event_password' value='$event_password'/>\n";
 	echo "<input type='hidden' name='db_type' value='$db_type'/>\n";
 	echo "<input type='hidden' name='admin_username' value='$admin_username'/>\n";

+ 1 - 1
core/install/resources/page_parts/install_config_detail.php

@@ -31,7 +31,7 @@
 	echo "<input type='hidden' name='install_step' value='config_database'/>\n";
 
 	echo "<input type='hidden' name='event_host' value='$event_host'/>\n";
-	echo "<input type='hidden' name='event_port' value='$event_host'/>\n";
+	echo "<input type='hidden' name='event_port' value='$event_port'/>\n";
 	echo "<input type='hidden' name='event_password' value='$event_password'/>\n";
 
 	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";

+ 2 - 2
core/install/resources/page_parts/install_event_socket.php

@@ -31,10 +31,10 @@
 	try {
 		$switch_detect->detect();
 	} catch(Exception $e){
-		$messages[] = "Failed to detect confgiuration detect_switch reported: " . $e->getMessage();
+		echo "<p><b>Failed to detect configuration</b> detect_switch reported: " . $e->getMessage() ."</p>\n";
 		$detect_ok = false;
 	}
-	echo "<form method='post' name='frm' action=''>\n";
+	echo "<form method='post' name='detect_switch' action=''>\n";
 	echo "<input type='hidden' name='install_language' value='".$_SESSION['domain']['language']['code']."'/>\n";
 	echo "<input type='hidden' name='install_step' value='detect_config'/>\n";
 	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";

+ 0 - 11
core/upgrade/app_defaults.php

@@ -26,17 +26,6 @@
 
 
 if ($domains_processed == 1) {
-	//process if the scripts directory exists
-		if (strlen($_SESSION['switch']['scripts']['dir']) > 0) {
-			//if the resource scripts resource directory does not exist then create it
-				if (!is_dir($_SESSION['switch']['scripts']['dir']."/resources")) {
-					mkdir($_SESSION['switch']['scripts']['dir']."/resources",0755,true);
-				}
-
-			//copy the files and directories from resources/install
-				$obj = new install_switch;
-				$obj->upgrade();
-		}
 
 	//update the software table
 		$sql = "select count(*) as num_rows from v_software ";

+ 4 - 1
core/upgrade/upgrade.php

@@ -67,7 +67,10 @@
 	$obj = new schema;
 	echo $obj->schema("text");
 
-//run all app_defaults.php files
+//request the switch to perform upgrade functions
+	$obj = new install_switch;
+	$obj->upgrade();
+
 	require_once "resources/classes/domains.php";
 	$domain = new domains;
 	$domain->upgrade();