Make version check API that doesn't require login

This commit is contained in:
Skylar Ittner 2019-06-12 15:47:51 -06:00
parent f20f24994b
commit 53aa167e79
5 changed files with 21 additions and 24 deletions

View File

@ -1,5 +1,5 @@
# Rewrite for Nextcloud Notes API
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule version version.php [PT]
RewriteRule ([a-zA-Z0-9]+) index.php?action=$1 [PT]
</IfModule>

View File

@ -1,9 +0,0 @@
<?php
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
exitWithJson(["status" => "OK", "version" => $SETTINGS["minimum_client_version"]]);

View File

@ -10,9 +10,6 @@ $APIS = [
"ping" => [
"load" => "ping.php"
],
"version" => [
"load" => "version.php"
],
"inventory" => [
"load" => "inventory.php"
],

20
api/version.php Normal file
View File

@ -0,0 +1,20 @@
<?php
require_once __DIR__ . "/../settings.php";
$format = end(explode(".", $_SERVER['REQUEST_URI']));
header("Access-Control-Allow-Origin: *");
switch ($format) {
case "json":
header("Content-Type: application/json");
echo json_encode(["min_version" => $SETTINGS["minimum_client_version"]]);
break;
case "txt":
default:
header("Content-Type: text/plain");
echo $SETTINGS["minimum_client_version"];
break;
}

View File

@ -1,11 +0,0 @@
<?php
/*
* Give the minimum allowed game client version. The client should check on
* startup and not continue if its version is less than the given version.
*/
header('Content-Type: application/json');
header("Access-Control-Allow-Origin: *");
echo json_encode(["status" => "OK", "version" => "2.0.0"]);