Przeglądaj źródła

Added Warning in AJAX

own3mall 8 lat temu
rodzic
commit
cf98f91f25
1 zmienionych plików z 14 dodań i 14 usunięć
  1. 14 14
      modules/user_games/edit_home.php

+ 14 - 14
modules/user_games/edit_home.php

@@ -60,18 +60,8 @@ function exec_ogp_module()
 		$new_home_cfg_id = $_POST['home_cfg_id'];
 		if($db->updateHomeCfgId($home_id, $new_home_cfg_id))
 		{
-			$home_info = $db->getGameHomeWithoutMods($home_id);
-			$servers_with_same_path = $db->getGameServersWithSamePath($home_info['remote_server_id'], $home_info['home_path']); 
-			$servers_with_same_path = (is_array($servers_with_same_path) ? count($servers_with_same_path) : 0);
 			$json_message = array('result' => 'success', 'info' => successfully_changed_game_server);
-			
-			if($servers_with_same_path > 1){
-				$json_message["warning_info"] = get_lang('other_servers_exist_with_path_please_change');
-			}
-			
-			echo json_encode($json_message);
-			
-			
+			echo json_encode($json_message);			
 			$db->logger( successfully_changed_game_server ." HOME ID:$home_id - ". change_game_type .":old home_cfg_id:$home_cfg_id, new home_cfg_id:$new_home_cfg_id");
 		}
 		else
@@ -457,6 +447,16 @@ function exec_ogp_module()
 			{
 				if ( $db->changeHomePath($home_id,clean_path($home_path)) === TRUE )
 				{
+					$home_info = $db->getGameHomeWithoutMods($home_id);
+					$servers_with_same_path = $db->getGameServersWithSamePath($home_info['remote_server_id'], $home_info['home_path']); 
+					$servers_with_same_path = (is_array($servers_with_same_path) ? count($servers_with_same_path) : 0);
+					
+					$success_json = array('result' => 'success', 'info' => successfully_changed_game_server);
+					
+					if($servers_with_same_path > 1){
+						$success_json["warning_info"] = get_lang('other_servers_exist_with_path_please_change');
+					}
+					
 					// Create new home directory if it doesn't already exist
 					$remote->exec("mkdir -p " . clean_path($home_path));
 					
@@ -473,7 +473,7 @@ function exec_ogp_module()
 							
 							if (isset($create_new_ftp_account) and $create_new_ftp_account !== 0)
 							{
-								echo json_encode(array('result' => 'success', 'info' => successfully_changed_game_server));
+								echo json_encode($success_json);
 								$db->logger( successfully_changed_game_server ." HOME ID:$home_id - ". home_path .":$home_path");
 							}
 							else
@@ -484,13 +484,13 @@ function exec_ogp_module()
 						}
 						else
 						{
-							echo json_encode(array('result' => 'success', 'info' => successfully_changed_game_server));
+							echo json_encode($success_json);
 							$db->logger( successfully_changed_game_server ." HOME ID:$home_id - ". home_path .":$home_path");
 						}
 					}
 					else
 					{
-						echo json_encode(array('result' => 'success', 'info' => successfully_changed_game_server));
+						echo json_encode($success_json);
 						$db->logger( successfully_changed_game_server ." HOME ID:$home_id - ". home_path .":$home_path");
 					}
 				}