45 lines
1014 B
PHP
45 lines
1014 B
PHP
<?php
|
|
|
|
namespace API;
|
|
|
|
|
|
foreach (glob("modules/$project_name/*.php") as $filename) { include_once $filename;
|
|
}
|
|
|
|
$traits_array_= array();
|
|
$traits_array = get_declared_traits();
|
|
foreach ($traits_array as $key) {
|
|
array_push($traits_array_, substr($key, 4));
|
|
}
|
|
$traits_name=implode(",", $traits_array_);
|
|
|
|
eval("
|
|
namespace API;
|
|
final class API
|
|
{
|
|
use $traits_name;
|
|
private static \$instance;
|
|
public static function getInstance(): self
|
|
{
|
|
if (null === static::\$instance) {
|
|
static::\$instance = new static();
|
|
}
|
|
return static::\$instance;
|
|
}
|
|
}
|
|
");
|
|
|
|
$api = API::getInstance();
|
|
|
|
$_POST = json_decode(file_get_contents('php://input'), true);
|
|
if (isset($_POST)) {
|
|
$params=$_POST['params'];
|
|
$flag=$params['flag'];
|
|
if (method_exists($api, $flag)) {
|
|
call_user_func(array($api, $flag), $params);
|
|
} else {
|
|
header('Content-Type:text/html; charset=UTF-8', true, 301);
|
|
exit;
|
|
}
|
|
}
|