back office gate

This commit is contained in:
CHIEFSOFT\ameye
2025-06-13 22:40:42 -04:00
parent c59de16d04
commit 013da276fb
2 changed files with 88 additions and 0 deletions
+3
View File
@@ -7,6 +7,9 @@ $routes->get('/', 'Home::index');
$routes->get('/en/wrench/api/v1/test','Home::test');
$routes->get('/backoffice/svs/bko','BackOffice::backofficegate');
$routes->post('/backoffice/svs/bko','BackOffice::backofficegate');
$routes->post('/en/wrench/api/v1/promoverify', 'Promo::promoVerify');
+85
View File
@@ -0,0 +1,85 @@
<?php
namespace App\Controllers;
use CodeIgniter\API\ResponseTrait;
class BackOffice extends BaseController
{
use ResponseTrait;
protected $request;
public function index()
{
return '';
}
public function backofficegate()
{
log_message('critical', "Back Office Call 0001");
$call_backend = true; // sometimes we need to overwite the call to the extenstion API
$local_out = []; // use local out to send output when the result is not from the extenstion
$ret = -1;
header("Access-Control-Allow-Origin: *");
header("Access-Control-Expose-Headers: Access-Control-Allow-Origin");
header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS");
header('Content-type: application/json');
if ("OPTIONS" === $_SERVER['REQUEST_METHOD']) {
exit();
}
$endpoint = strtolower(str_replace('/svs/bko/', '', strtok($_SERVER['REQUEST_URI'], '?')));
$id = 0; // update, get & delete actions require ID
if (substr($endpoint, 0, 19) == 'gettransportrequest' || substr($endpoint, 0, 13) == 'updateprofile') {
$endpoint = strtok($endpoint, '/');
$id = strtok('/');
}
if (!isset($endpoints[$endpoint])) {
header('HTTP/1.1 400 Bad Request');
header('Status: 400 Bad Request');
echo "{\"status\":\"Invalid endpoint url WRB\"}";
exit();
}
$methods = $endpoints[$endpoint];
if (array_search($_SERVER['REQUEST_METHOD'], $methods) === false) {
header('HTTP/1.1 405 Method Not Allowed');
header('Status: 405 Method Not Allowed');
echo "{\"status\":\"Invalid request method\"}";
exit();
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$in = flatten(json_decode(file_get_contents('php://input'), true));
}
if ($_SERVER["REQUEST_METHOD"] == "PUT") {
parse_str(file_get_contents('php://input'), $in);
}
if ($_SERVER["REQUEST_METHOD"] == "GET") {
$in = $_GET;
}
$in["loc"] = $_SERVER["REMOTE_ADDR"];
switch ($endpoint) {
case 'generics':
break;
}
$in["pid"] = 100;
$ret = $this->wrenchboard->wrenchboard_api($in, $out);
$out['internal_return'] = $ret;
return $this->respond($this->summaryReturnData($in,$out,[]), 200);
}
}