1
0
mirror of https://github.com/lrsjng/h5ai.git synced 2025-08-18 19:51:24 +02:00

Adds a version and url check to not confuse multiple installations.

This commit is contained in:
Lars Jung
2013-07-11 01:32:53 +02:00
parent 5f27518852
commit 9340c5232c
2 changed files with 21 additions and 1 deletions

View File

@@ -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,8 +149,16 @@ class App {
return 200;
}
}
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;
}
public function get_generic_json() {

View File

@@ -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");