From db55067112ba65c9885c012cc321fc326641cec3 Mon Sep 17 00:00:00 2001 From: sctn4elk Date: Thu, 18 Apr 2024 12:08:57 -0500 Subject: [PATCH] Update URI positions for testing and production --- index.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/index.php b/index.php index 665d467..eca3f20 100644 --- a/index.php +++ b/index.php @@ -11,6 +11,8 @@ header("Content-Type: application/json"); require __DIR__ . "/include/bootstrap.php"; $uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); $uri = explode( '/', $uri ); +//Set uri module location position to 1 for production, 2 for testing +$uri_pos = 2; /* When testing with UniServer the URI array placement position will be * incremented by 1 due to the folder addition @@ -22,15 +24,12 @@ $uri = explode( '/', $uri ); * uri[5] = parmeters */ -//Set uri module location position to 1 for production, 2 for testing -$uri_pos = 2; - -if (!isset($uri[$uri_pos+1]) || !isset($uri[$uri_pos+2]) || !isset($uri[$uri_pos+3])) { +if (!isset($uri[$uri_pos]) || !isset($uri[$uri_pos+1]) || !isset($uri[$uri_pos+2])) { header("HTTP/1.1 404 Not Found"); exit(); } -switch($uri[$uri_pos]) { +switch($uri[$uri_pos + 1]) { case "purchase": header("HTTP/1.1 404 Module Not Defined"); exit(); @@ -49,6 +48,6 @@ switch($uri[$uri_pos]) { break; } -$strMethodName = $uri[$uri_pos+1] . 'Action'; -$objFeedController->{$strMethodName}($uri[$uri_pos+2]); +$strMethodName = $uri[$uri_pos + 2] . 'Action'; +$objFeedController->{$strMethodName}($uri[$uri_pos + 3]);