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";
$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]);