Update URI positions for testing and production

This commit is contained in:
sctn4elk 2024-04-18 12:08:57 -05:00
parent 6212095c32
commit db55067112

View File

@ -11,6 +11,8 @@ header("Content-Type: application/json");
require __DIR__ . "/include/bootstrap.php"; require __DIR__ . "/include/bootstrap.php";
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); $uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$uri = explode( '/', $uri ); $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 /* When testing with UniServer the URI array placement position will be
* incremented by 1 due to the folder addition * incremented by 1 due to the folder addition
@ -22,15 +24,12 @@ $uri = explode( '/', $uri );
* uri[5] = parmeters * uri[5] = parmeters
*/ */
//Set uri module location position to 1 for production, 2 for testing if (!isset($uri[$uri_pos]) || !isset($uri[$uri_pos+1]) || !isset($uri[$uri_pos+2])) {
$uri_pos = 2;
if (!isset($uri[$uri_pos+1]) || !isset($uri[$uri_pos+2]) || !isset($uri[$uri_pos+3])) {
header("HTTP/1.1 404 Not Found"); header("HTTP/1.1 404 Not Found");
exit(); exit();
} }
switch($uri[$uri_pos]) { switch($uri[$uri_pos + 1]) {
case "purchase": case "purchase":
header("HTTP/1.1 404 Module Not Defined"); header("HTTP/1.1 404 Module Not Defined");
exit(); exit();
@ -49,6 +48,6 @@ switch($uri[$uri_pos]) {
break; break;
} }
$strMethodName = $uri[$uri_pos+1] . 'Action'; $strMethodName = $uri[$uri_pos + 2] . 'Action';
$objFeedController->{$strMethodName}($uri[$uri_pos+2]); $objFeedController->{$strMethodName}($uri[$uri_pos + 3]);