From d6420c3243ef82fb69b4eab2ee1b24ede973e49b Mon Sep 17 00:00:00 2001 From: Kay0u Date: Sun, 19 Apr 2020 18:48:44 +0200 Subject: [PATCH 1/2] fix install-apps --- index.php | 88 ++++++++++--------------------------------------- locales/en.json | 3 -- locales/fr.json | 3 -- 3 files changed, 18 insertions(+), 76 deletions(-) diff --git a/index.php b/index.php index a8e0d2e..da2501f 100644 --- a/index.php +++ b/index.php @@ -8,40 +8,26 @@ $user_locale = substr(Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']), if (!file_exists("locales/".$user_locale.".json")) { $user_locale = 'en'; } $locale=json_decode(file_get_contents("locales/".$user_locale.".json"), true); -// Parse the official app list -$official_json=file_get_contents("https://app.yunohost.org/official.json"); -$official=json_decode($official_json, true); +// Parse the apps list +$apps_list_json=file_get_contents("https://app.yunohost.org/apps.json"); +$apps_list=json_decode($apps_list_json, true); -// Check whether the app is official, community, or neither -if(array_key_exists($app, $official)) { - // The app is in the official list - $app_status = 'official'; // The app is in the official list - $app_name = $official[$app]['manifest']['name']; // Saves the app name - $app_git = $official[$app]['git']['url']; // Saves the git URL - $app_state = $official[$app]['state']; // Saves the app state +// Check if the app is the apps list +if(array_key_exists($app, $apps_list)) { + // The app is in the apps list + $app_status = 'apps_list'; // The app is in the apps list + $app_name = $apps_list[$app]['manifest']['name']; // Saves the app name + $app_git = $apps_list[$app]['git']['url']; // Saves the git URL + $app_state = $apps_list[$app]['state']; // Saves the app state } else { - // Parse the community app list - $community_json=file_get_contents("https://app.yunohost.org/community.json"); - $community=json_decode($community_json, true); - - // Check if the app is community - if(array_key_exists($app, $community)) { - // The app is in the community list - $app_status = 'community'; // The app is in the community list - $app_name = $community[$app]['manifest']['name']; // Saves the app name - $app_git = $community[$app]['git']['url']; // Saves the git URL - $app_state = $community[$app]['state']; // Saves the app state - } - else { - // The app is neither in the official, nor in the community list - $app_status = null; - $app_name = ""; - } + // The app is not in the apps list + $app_status = null; + $app_name = ""; } -// If the user submitted his or her server and the app is official, redirects to the server -if(isset($_POST['server']) AND !empty($_POST['server']) AND $app_status == 'official') { +// If the user submitted his or her server and the app is in apps ist, redirects to the server +if(isset($_POST['server']) AND !empty($_POST['server']) AND $app_status == 'apps_list') { $server = rtrim(preg_replace('#^https?://#', '', $_POST['server']),"/"); $url = 'https://'.$server.'/yunohost/admin/#/apps/install/'.$app; header('Location: '.$url); @@ -92,8 +78,8 @@ if(isset($_POST['server']) AND !empty($_POST['server']) AND $app_status == 'offi