2024-04-15 11:38:59 -05:00
|
|
|
<?php
|
2024-04-30 08:51:16 -05:00
|
|
|
header("Content-Type: application/json");header("Access-Control-Allow-Origin: *");
|
|
|
|
header("Content-Type: application/json; charset=UTF-8");
|
|
|
|
header("Access-Control-Allow-Methods: OPTIONS,GET,POST,PUT,DELETE");
|
|
|
|
header("Access-Control-Max-Age: 3600");
|
|
|
|
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
|
2024-04-30 12:36:23 -05:00
|
|
|
|
2024-04-15 11:38:59 -05:00
|
|
|
/*
|
|
|
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
|
|
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Scripting/EmptyPHP.php to edit this template
|
|
|
|
*/
|
|
|
|
/* USAGE
|
|
|
|
* https://localhost/index.php/{MODULE_NAME}/{METHOD_NAME}?limit={LIMIT_VALUE}
|
|
|
|
* http://localhost/index.php/customer/process/list?limit=20
|
|
|
|
*/
|
|
|
|
require __DIR__ . "/include/bootstrap.php";
|
2024-04-30 12:36:23 -05:00
|
|
|
|
2024-04-30 22:54:04 -05:00
|
|
|
$requestMethod = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_STRING);
|
|
|
|
$parsedUri = parse_url($requestMethod, PHP_URL_PATH);
|
|
|
|
$uri = explode( '/', $parsedUri );
|
2024-04-30 12:36:23 -05:00
|
|
|
|
2024-04-18 12:08:57 -05:00
|
|
|
//Set uri module location position to 1 for production, 2 for testing
|
|
|
|
$uri_pos = 2;
|
2024-04-15 11:38:59 -05:00
|
|
|
|
2024-04-17 13:55:27 -05:00
|
|
|
/* When testing with UniServer the URI array placement position will be
|
|
|
|
* incremented by 1 due to the folder addition
|
2024-05-06 13:19:09 -05:00
|
|
|
* http://localhost/CustomerRewardsRESTAPI/index.php/customer/process/select?limit=5
|
2024-04-17 13:55:27 -05:00
|
|
|
* uri[1] = folder
|
|
|
|
* uri[2] = index
|
|
|
|
* uri[3] = module
|
|
|
|
* uri[4] = action
|
|
|
|
* uri[5] = parmeters
|
|
|
|
*/
|
|
|
|
|
2024-04-18 12:08:57 -05:00
|
|
|
if (!isset($uri[$uri_pos]) || !isset($uri[$uri_pos+1]) || !isset($uri[$uri_pos+2])) {
|
2024-04-15 11:38:59 -05:00
|
|
|
header("HTTP/1.1 404 Not Found");
|
|
|
|
exit();
|
|
|
|
}
|
2024-05-13 15:12:31 -05:00
|
|
|
//echo var_dump($uri);
|
2024-04-18 12:08:57 -05:00
|
|
|
switch($uri[$uri_pos + 1]) {
|
2024-04-15 11:38:59 -05:00
|
|
|
case "purchase":
|
|
|
|
header("HTTP/1.1 404 Module Not Defined");
|
|
|
|
exit();
|
|
|
|
//require PROJECT_ROOT_PATH . "/Controller/Api/PurchaseController.php";
|
|
|
|
//$objFeedController = new PurchaseController();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "customer":
|
|
|
|
require PROJECT_ROOT_PATH . "/Controller/Api/CustomerController.php";
|
|
|
|
$objFeedController = new CustomerController();
|
|
|
|
break;
|
|
|
|
|
2024-05-09 16:40:42 -05:00
|
|
|
case "image":
|
|
|
|
require PROJECT_ROOT_PATH . "/Controller/Api/ImageController.php";
|
|
|
|
$objFeedController = new ImageController();
|
|
|
|
break;
|
|
|
|
|
2024-04-15 11:38:59 -05:00
|
|
|
default:
|
|
|
|
header("HTTP/1.1 404 Module Not Found");
|
|
|
|
exit();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-04-18 12:08:57 -05:00
|
|
|
$strMethodName = $uri[$uri_pos + 2] . 'Action';
|
2024-04-30 12:36:23 -05:00
|
|
|
$objFeedController->action = $uri[$uri_pos + 3];
|
|
|
|
$objFeedController->{$strMethodName}();
|
2024-04-15 11:38:59 -05:00
|
|
|
|