From 9340c5232c39a25108a7fb40337f9b722b411a6d Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Thu, 11 Jul 2013 01:32:53 +0200 Subject: [PATCH] Adds a version and url check to not confuse multiple installations. --- src/_h5ai/server/php/inc/App.php | 13 ++++++++++++- src/_h5ai/server/php/index.php | 9 +++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/_h5ai/server/php/inc/App.php b/src/_h5ai/server/php/inc/App.php index fa5f372a..28cc07b4 100644 --- a/src/_h5ai/server/php/inc/App.php +++ b/src/_h5ai/server/php/inc/App.php @@ -27,6 +27,9 @@ class App { $this->abs_path = $this->get_abs_path($this->abs_href); $this->options = load_commented_json($this->app_abs_path . "/conf/options.json"); + + $this->is_https = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] === 443); + $this->prot_host = 'http' . ($this->is_https ? 's' : '') . '://' . getenv('HTTP_HOST'); } @@ -146,7 +149,15 @@ class App { return 200; } } - return App::$MAGIC_SEQUENCE; + + try { + $res = json_decode(file_get_contents($this->prot_host . $abs_href . '?version')); + if ($res->version === '{{pkg.version}}' && $res->href === $this->app_abs_href) { + return App::$MAGIC_SEQUENCE; + } + } catch (Exception $e) {} + + return 200; } diff --git a/src/_h5ai/server/php/index.php b/src/_h5ai/server/php/index.php index fdbe6bc8..ace8971c 100644 --- a/src/_h5ai/server/php/index.php +++ b/src/_h5ai/server/php/index.php @@ -20,6 +20,15 @@ function normalized_require_once($lib) { } +/* Fast exit on version check */ + +if (array_key_exists("version", $_REQUEST)) { + + echo json_encode(array("code" => 0, "version" => "{{pkg.version}}", "href" => APP_ABS_HREF)); + exit; +} + + /* Load Libs */ normalized_require_once("/server/php/inc/util.php");