From f898db8a422966d63785594c4bd0767d67167114 Mon Sep 17 00:00:00 2001 From: Kevin J Hoerr Date: Sun, 9 Jul 2017 01:24:53 -0400 Subject: Fix compat issues with Apache and PHP7.0 --- .htaccess | 2 +- private/View/Main.php | 35 ++++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/.htaccess b/.htaccess index 611f7cc..bf7ece5 100644 --- a/.htaccess +++ b/.htaccess @@ -1,3 +1,3 @@ RewriteEngine On -RewriteRule ^/api/ index.php +RewriteRule ^api/(.*)$ index.php/api/$1 RedirectMatch 403 ^/private/.*$ diff --git a/private/View/Main.php b/private/View/Main.php index b693979..c51e91f 100644 --- a/private/View/Main.php +++ b/private/View/Main.php @@ -19,7 +19,7 @@ class Main private $result; /** @var string TYPE The type of output the client should receive. */ - public const TYPE = "json"; + const TYPE = "json"; /** * Prepares the output and environment for the front end of the service. @@ -65,20 +65,25 @@ class Main */ public function generateResult (): string { - switch (strtolower($this->query->getPath()[1])) { - case "callback": - $this->result = Controller\Controller::createResult( - "CALLBACK", - array( - "path" => $this->query->getPath(), - "request" => $this->query->getRequest(), - "content" => $this->query->getContent() - ) - ); - break; - default: - $this->result = Controller\Controller::createResult("", array()); - break; + $path = $this->query->getPath(); + if (count($path) >= 1 && $path[0] === "api" && count($path) >= 2) { + switch (strtolower($path[1])) { + case "callback": + $this->result = Controller\Controller::createResult( + "CALLBACK", + array( + "path" => $path, + "request" => $this->query->getRequest(), + "content" => $this->query->getContent() + ) + ); + break; + default: + $this->result = Controller\Controller::createResult("NOT_UNDERSTOOD", array($path)); + break; + } + } else { + $this->result = Controller\Controller::createResult("NOT_UNDERSTOOD", array($path)); } return self::generateOutput($this->result); -- cgit