This commit is contained in:
2026-01-13 12:36:57 +03:00
commit ebe1f5bd00
29 changed files with 2295 additions and 0 deletions

65
core__.php Normal file
View File

@@ -0,0 +1,65 @@
<?php
namespace API;
//новая версия с классом api
$IP = $_SERVER['REMOTE_ADDR'];
foreach (glob("modules/*.php") as $filename) {
include $filename;
}
final class API
{
//подключение модулей
use Common, Companies, Devices, Stats, Users;
//стандартный шаблон singleton
private static $instance;
public static function getInstance(): API
{
if (null === static::$instance) {
static::$instance = new static();
}
return static::$instance;
}
private function __construct(){}
private function __clone(){}
private function __wakeup(){}
}
$api=API::getInstance();
$_POST = json_decode(file_get_contents('php://input'), true);
if (isset($_POST)) {
$params=$_POST['params'];
$flag=$params['flag'];
//echo ($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;
}
}
//старая версия без класса api
// foreach (glob("api/modules/*.php") as $filename) {
// include $filename;
// }
// $_POST = json_decode(file_get_contents('php://input'), true);
// if (isset($_POST)) {
// $params=$_POST['params'];
// $flag=$params['flag'];
// if (function_exists($flag)) {
// call_user_func($flag, $params);
// } else {
// header('Content-Type:text/html; charset=UTF-8', true, 301);
// exit;
// }
// }