45 lines
880 B
PHP
45 lines
880 B
PHP
<?php
|
|
|
|
ini_set('display_errors', 1);
|
|
ini_set('display_startup_errors', 1);
|
|
error_reporting(E_ALL);
|
|
|
|
include_once '../../../Router.php';
|
|
include_once 'api.php';
|
|
|
|
|
|
$dirs = [];
|
|
$file = "";
|
|
$args = [];
|
|
|
|
foreach($_GET as $arg){
|
|
if(
|
|
(empty($dirs) && is_dir($arg)) ||
|
|
is_dir( implode('/', $dirs)."/".$arg )
|
|
){
|
|
$dirs[] = $arg;
|
|
}
|
|
elseif(file_exists( $filePathTemp = implode('/', $dirs)."/".$arg.".php" )){
|
|
$file = $arg.".php";
|
|
$filePath = $filePathTemp;
|
|
}
|
|
else {
|
|
$args[] = $arg;
|
|
}
|
|
}
|
|
|
|
if(!empty($filePath)){
|
|
$_GET['args'] = $args;
|
|
// echo __dir__ . '/' . $filePath;
|
|
|
|
if(file_exists( __dir__ . '/' . $filePath )){
|
|
include_once __dir__ . '/' . $filePath;
|
|
return;
|
|
}
|
|
}
|
|
http_send_status(500);
|
|
header('Content-Type: application/json');
|
|
echo json_encode([ 'error' => "API not found." ]);
|
|
|
|
|