From 8c15ec987324f7fdc5a1935c8db5417e8d16c621 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 10 Dec 2018 11:23:29 +0100 Subject: packages/pkginfo.php: adopt to new location and output format of pkgapi --- packages/pkginfo.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/pkginfo.php b/packages/pkginfo.php index 3a3fc2e..d6d04fb 100644 --- a/packages/pkginfo.php +++ b/packages/pkginfo.php @@ -5,17 +5,17 @@ require_once BASE . "/lib/helper.php"; require_once BASE . "/lib/mysql.php"; require_once BASE . "/lib/style.php"; - if ($_GET["arch"] == "i486") - $skip_json_checks = true; - else - $skip_json_checks = false; - if (!$skip_json_checks) { $memcache = new Memcache; $memcache -> connect('localhost', 11211) or die ('Memcached Connection Error'); $pkgapi_reachable = $memcache -> get('pkgapi_reachable'); + $tld = array_pop((explode('.', $_SERVER['HTTP_HOST']))); + if (array_key_exists('HTTPS', $_SERVER) && ($_SERVER['HTTPS'] == 'on')) + $protocol = 'https'; + else + $protocol = 'http'; if ($pkgapi_reachable === false) { - if (site_is_reachable('https://pkgapi.arch32.tyzoid.com/package/')) + if (site_is_reachable($protocol . '://pkgapi.archlinux32.' . $tld . '/')) $pkgapi_reachable = 'YES'; else $pkgapi_reachable = 'NO'; @@ -28,18 +28,19 @@ require_once BASE . "/lib/style.php"; if (!$skip_json_checks) { $json_content = json_decode( file_get_contents( - "https://pkgapi.arch32.tyzoid.com/package/" . - urlencode ($_GET["repo"].":".$_GET["pkgname"]) + $protocol . '://pkgapi.archlinux32.' . $tld . '/' . + urlencode($_GET["arch"]) . '/' . + urlencode($_GET["repo"]) . '/' . + urlencode($_GET["pkgname"]) ), true ); - if (!isset($json_content["package"])) { + if (!isset($json_content["Name"])) { //throw_http_error(404, "Package Not Found In Sync Database"); unset($json_content); $skip_json_checks = true; - } else - $json_content = $json_content["package"]; + }; } $mysql_result = mysql_run_query( -- cgit v1.2.3-70-g09d2