41 lines
948 B
PHP
41 lines
948 B
PHP
|
<?php
|
||
|
|
||
|
function runEndpoint($endpoint_file)
|
||
|
{
|
||
|
global $routerRequest;
|
||
|
|
||
|
$endpoint_data = $_POST
|
||
|
require_once $endpoint_file;
|
||
|
|
||
|
return endpoint($endpoint_data);
|
||
|
}
|
||
|
|
||
|
|
||
|
function getEndpoint($endpoint_name)
|
||
|
{
|
||
|
$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";
|
||
|
|
||
|
$endpoint_file_global = $routerConfig["endpoint_dir"] . "global/" . $endpoint_name . ".php";
|
||
|
|
||
|
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);
|
||
|
}
|