2024-01-18 11:49:38 +01:00
|
|
|
<?php
|
|
|
|
|
2024-01-31 22:05:23 +01:00
|
|
|
function runEndpoint($endpoint_file): ?array
|
2024-01-18 11:49:38 +01:00
|
|
|
{
|
|
|
|
|
2024-01-18 11:53:39 +01:00
|
|
|
$endpoint_data = $_POST;
|
2024-01-18 11:49:38 +01:00
|
|
|
require_once $endpoint_file;
|
|
|
|
|
|
|
|
return endpoint($endpoint_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-01-31 23:07:12 +01:00
|
|
|
function getEndpoint($endpoint_name): string
|
2024-01-18 11:49:38 +01:00
|
|
|
{
|
|
|
|
$output = array();
|
|
|
|
$output["status"] = "fail";
|
|
|
|
global $routerConfig;
|
|
|
|
global $routerRequest;
|
|
|
|
|
|
|
|
if(!$endpoint_name){
|
|
|
|
$endpoint_name = $routerRequest["page_name"];
|
|
|
|
}
|
|
|
|
|
|
|
|
$endpoint_file = $routerConfig["endpoint_dir"] . $routerRequest["subdomain"] . "/" . $endpoint_name . ".php";
|
|
|
|
|
2024-02-02 12:38:18 +01:00
|
|
|
$endpoint_file_global = $routerConfig["endpoint_dir"] . "account/" . $endpoint_name . ".php";
|
2024-01-18 11:49:38 +01:00
|
|
|
|
|
|
|
if (file_exists($endpoint_file_global)){
|
|
|
|
$output = runEndpoint($endpoint_file_global);
|
|
|
|
}
|
|
|
|
elseif (file_exists($endpoint_file)){
|
|
|
|
$output = runEndpoint($endpoint_file);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$output["error"] = "Not found";
|
|
|
|
http_response_code(404);
|
|
|
|
}
|
|
|
|
|
|
|
|
return json_encode($output);
|
|
|
|
}
|