From 006409bdd94d2dc456008e189a8a4803a844bb20 Mon Sep 17 00:00:00 2001 From: fusionate Date: Fri, 3 May 2024 18:18:05 -0600 Subject: [PATCH] Upgrade - Source Code: Additional minor adjustments. --- core/upgrade/index.php | 75 +++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 30 deletions(-) diff --git a/core/upgrade/index.php b/core/upgrade/index.php index 33b3131681..1c8fac9b15 100644 --- a/core/upgrade/index.php +++ b/core/upgrade/index.php @@ -50,6 +50,26 @@ //set a default message_timeout $message_timeout = 4*1000; +//find optional apps with repos + $updateable_repos = git_find_repos($_SERVER["PROJECT_ROOT"]."/app"); + if (!empty($updateable_repos) && is_array($updateable_repos) && @sizeof($updateable_repos) != 0) { + foreach ($updateable_repos as $app_path => $repo) { + $x = 0; + include $app_path.'/app_config.php'; + $updateable_repos[$app_path]['app'] = $repo[0]; + $updateable_repos[$app_path]['name'] = $apps[$x]['name']; + $updateable_repos[$app_path]['uuid'] = $apps[$x]['uuid']; + $updateable_repos[$app_path]['version'] = $apps[$x]['version']; + $updateable_repos[$app_path]['description'] = $apps[$x]['description'][$_SESSION['domain']['language']['code']]; + unset($apps, $updateable_repos[$app_path][0]); + } + } + +//count upgradeable repos including + main repo + $repos_count = 0; + if (is_array($updateable_repos)) { $repos_count = @sizeof($updateable_repos); } + $repos_count++; + //process the http post if (!empty($_POST) && @sizeof($_POST) > 0) { @@ -74,20 +94,18 @@ //run optional app source updates if (!empty($action["optional_apps"]) && permission_exists("upgrade_source")) { - $updateable_repos = git_find_repos($_SERVER["PROJECT_ROOT"]."/app"); - $apps_updated = $apps_failed = 0; if (is_array($action["optional_apps"])) { - foreach ($updateable_repos as $repo => $apps) { - if (array_search(basename($repo), $action["optional_apps"]) !== false) { - $git_result = git_pull($repo); - if ($git_result['result']) { - $_SESSION["response"]["optional_apps"][basename($repo)] = $git_result['message']; + foreach ($updateable_repos as $app_path => $app_details) { + if (array_search(basename($app_path), $action["optional_apps"]) !== false) { + $git_result = git_pull($app_path); + if (!empty($git_result['result'])) { $apps_updated++; } else { $apps_failed++; } + $_SESSION["response"]["optional_apps"][$app_details['name']] = $git_result['message']; } } } @@ -140,26 +158,6 @@ } -//find optional apps with repos - $updateable_repos = git_find_repos($_SERVER["PROJECT_ROOT"]."/app"); - if (!empty($updateable_repos) && is_array($updateable_repos) && @sizeof($updateable_repos) != 0) { - foreach ($updateable_repos as $app_path => $repo) { - $x = 0; - include $app_path.'/app_config.php'; - $updateable_repos[$app_path]['app'] = $repo[0]; - $updateable_repos[$app_path]['name'] = $apps[$x]['name']; - $updateable_repos[$app_path]['uuid'] = $apps[$x]['uuid']; - $updateable_repos[$app_path]['version'] = $apps[$x]['version']; - $updateable_repos[$app_path]['description'] = $apps[$x]['description'][$_SESSION['domain']['language']['code']]; - unset($apps, $updateable_repos[$app_path][0]); - } - } - -//count upgradeable repos including + main repo - $repos_count = 0; - if (is_array($updateable_repos)) { $repos_count = @sizeof($updateable_repos); } - $repos_count++; - //process the http get (source preview) if (!empty($_GET['preview'])) { if (!empty($updateable_repos)) { @@ -449,17 +447,34 @@ if ($part == "optional_apps") { foreach ($response as $app_name => $app_response) { echo "".$app_name."
\n"; - echo "
\n";
+					$error_found = false;
+					foreach ($app_response as $l => $response_line) {
+						if (substr_count($response_line, 'error: ') != 0) {
+							$error_found = true;
+							$app_response[$l] = str_replace('error:', 'Error:', $response_line);
+						}
+					}
+					if ($error_found) { $error_style = 'color: red;'; }
+					echo "\n";
 					foreach ($app_response as $response_line) {
 						echo htmlspecialchars($response_line) . "\n";
 					}
 					echo "
\n"; + unset($error_found, $error_style); } } - elseif (is_array($response)) { - echo "
";
+			else if (is_array($response)) {
+				foreach ($response as $l => $response_line) {
+					if (substr_count($response_line, 'error: ') != 0) {
+						$error_found = true;
+						$response[$l] = str_replace('error:', 'Error:', $response_line);
+					}
+				}
+				if ($error_found) { $error_style = 'color: red;'; }
+				echo "\n";
 				echo implode("\n", $response);
 				echo "
"; + unset($error_found, $error_style); } else { echo $response;