dx4 v2
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
api.lock
|
||||
_api.lock
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
$password = 'dengidengi';
|
||||
$directory = '../';
|
||||
$subdirectories = false;
|
||||
// $theme = 'phpliteadmin.css';
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,282 @@
|
||||
<?php
|
||||
include 'k-api.php';
|
||||
|
||||
|
||||
const ADMIN_PASS = "superdengipassword4";
|
||||
const SECRET_KEY = "dengisecretkey_monay_ivan_pletnev";
|
||||
const API_PATH = "./";
|
||||
|
||||
function db()
|
||||
{
|
||||
$pdo = new PDO('sqlite:' . API_PATH . 'data.db');
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
return $pdo;
|
||||
};
|
||||
|
||||
|
||||
function relativePathToUrl($rel)
|
||||
{
|
||||
$parts = explode('/', dirname($_SERVER['SCRIPT_NAME']) . '/' . $rel);
|
||||
$norm = [];
|
||||
foreach ($parts as $p) {
|
||||
if ($p === '..' && $norm) array_pop($norm);
|
||||
elseif ($p && $p !== '.') $norm[] = $p;
|
||||
}
|
||||
$proto = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
|
||||
return $proto . '://' . $_SERVER['HTTP_HOST'] . '/' . implode('/', $norm);
|
||||
}
|
||||
|
||||
|
||||
function FastDBReq(PDO $db, string $sql, array $params = []): array
|
||||
{
|
||||
try {
|
||||
$stmt = $db->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
return $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
function Login($req)
|
||||
{
|
||||
return isset($req->data['pass']) && $req->data['pass'] == ADMIN_PASS;
|
||||
}
|
||||
|
||||
CreateApi(function ($api) {
|
||||
$api->on('/', 'GET', function ($req) {
|
||||
return 'hi';
|
||||
});
|
||||
$api->on('/phpliteadmin', 'GET', function ($req) {
|
||||
header('Location: ./adm/phpliteadmin.php');
|
||||
return "";
|
||||
});
|
||||
$api->on('/login', 'POST', function ($req) {
|
||||
if (!isset($req->data['pass'])) {
|
||||
$req->res->code(401);
|
||||
return 'bad data';
|
||||
}
|
||||
if ($req->data['pass'] == ADMIN_PASS) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
$api->on('/class', 'POST', function ($req) {
|
||||
if (!Login($req)) {
|
||||
$req->res->code(401);
|
||||
return ['ok' => "auth_fail"];
|
||||
}
|
||||
$db = db();
|
||||
if (isset($req->data['classId'])) {
|
||||
$classId = $req->data['classId'];
|
||||
if (isset($req->data['action'])) {
|
||||
switch ($req->data['action']) {
|
||||
// actions
|
||||
case "update_name":
|
||||
try {
|
||||
if (!isset($req->data['value'])) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
$value = trim($req->data['value']);
|
||||
if (strlen($value) == 0) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
FastDBReq($db, "UPDATE classes SET userclassname = ? WHERE classid=?", [$value, $classId]);
|
||||
return true;
|
||||
} catch (PDOException $e) {
|
||||
error_log($e);
|
||||
return "егор";
|
||||
}
|
||||
break;
|
||||
case 'create_admin':
|
||||
if (!isset($req->data['value'])) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
$value = trim($req->data['value']);
|
||||
if (strlen($value) == 0 || !str_contains($value, ';')) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
$value = explode(';', $value);
|
||||
if (sizeof($value) != 3) {
|
||||
$req->res->code(400);
|
||||
return 'bad data';
|
||||
}
|
||||
$n_adminId = $value[0];
|
||||
$n_adminName = base64_decode($value[1]);
|
||||
$n_adminLevel = $value[2];
|
||||
|
||||
try {
|
||||
FastDBReq($db, "INSERT INTO admins (adminId,adminName,adminClass,adminPrems) VALUES (?,?,?,?)", [$n_adminId, $n_adminName, $classId, $n_adminLevel]);
|
||||
return true;
|
||||
} catch (PDOException) {
|
||||
$req->res->code(500);
|
||||
return "ошибка";
|
||||
}
|
||||
case "create":
|
||||
if (!isset($req->data['value'])) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
$classname = trim($req->data['value']);
|
||||
if (strlen($classname) == 0) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
FastDBReq($db, "INSERT INTO classes (classid, userclassname) VALUES (?,?)", [$classId, $classname]);
|
||||
return true;
|
||||
break;
|
||||
case "DELETE":
|
||||
// DANGER ZONE::
|
||||
FastDBReq($db, "DELETE FROM classes WHERE classid=?", [$classId]);
|
||||
FastDBReq($db, "DELETE FROM admins WHERE adminClass=?", [$classId]);
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
$db = null;
|
||||
return "?";
|
||||
}
|
||||
} else {
|
||||
// display class page
|
||||
|
||||
$results = FastDBReq($db, "SELECT * FROM classes WHERE classId=?", [$classId]);
|
||||
if (count($results) == 0) {
|
||||
$db = null;
|
||||
$req->res->code(400);
|
||||
return "idi naxodi";
|
||||
}
|
||||
$classData = $results[0];
|
||||
$adminsData = FastDBReq($db, "SELECT * FROM admins WHERE adminClass=?", [$classId]);
|
||||
$db = null;
|
||||
|
||||
return ["ok" => 'da', "class" => $classData, "admins" => $adminsData];
|
||||
}
|
||||
} else {
|
||||
// diplay all classes
|
||||
$result = FastDBReq($db, "SELECT * FROM classes");
|
||||
return ['ok' => 'da', "data" => $result];
|
||||
}
|
||||
});
|
||||
|
||||
$api->on('/admin', "POST", function ($req) {
|
||||
if (!Login($req)) {
|
||||
$req->res->code(401);
|
||||
return "auth_fail";
|
||||
}
|
||||
$db = db();
|
||||
if (isset($req->data['adminId'])) {
|
||||
if (isset($req->data['action'])) {
|
||||
switch ($req->data['action']) {
|
||||
case "update_name":
|
||||
if (!$req->hasData(['value', 'adminId'])) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
$value = trim($req->data['value']);
|
||||
$adminId = $req->data['adminId'];
|
||||
if (strlen($value) == 0) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
try {
|
||||
FastDBReq($db, 'UPDATE admins SET adminName = ? WHERE adminId = ?', [$value, $adminId]);
|
||||
} catch (PDOException) {
|
||||
$db = null;
|
||||
return "egor";
|
||||
}
|
||||
$db = null;
|
||||
return true;
|
||||
case "DELETE":
|
||||
//scary
|
||||
if (!isset($req->data['adminId'])) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
$adminId = $req->data['adminId'];
|
||||
FastDBReq($db, "DELETE FROM admins WHERE adminId=?", [$adminId]);
|
||||
return true;
|
||||
case "update_level":
|
||||
if (!$req->hasData(['value', 'adminId'])) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
$value = trim($req->data['value']);
|
||||
$adminId = $req->data['adminId'];
|
||||
if (strlen($value) == 0) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
try {
|
||||
FastDBReq($db, 'UPDATE admins SET adminPrems = ? WHERE adminId = ?', [$value, $adminId]);
|
||||
} catch (PDOException) {
|
||||
$db = null;
|
||||
return "egor";
|
||||
}
|
||||
$db = null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$api->on('/server', "POST", function ($req) {
|
||||
if (!Login($req)) {
|
||||
$req->res->code(401);
|
||||
return "auth_fail";
|
||||
}
|
||||
if (isset($req->data['action'])) {
|
||||
switch ($req->data['action']) {
|
||||
case 'enable':
|
||||
// unblock
|
||||
if (file_exists(API_PATH . 'api.lock')) {
|
||||
rename(API_PATH . 'api.lock', API_PATH . '_api.lock');
|
||||
}
|
||||
break;
|
||||
case 'disable':
|
||||
// block
|
||||
if (file_exists(API_PATH . 'api.lock')) return true;
|
||||
if (file_exists(API_PATH . '_api.lock')) {
|
||||
rename(API_PATH . '_api.lock', API_PATH . 'api.lock');
|
||||
} else {
|
||||
$f = fopen(API_PATH . 'api.lock', 'w');
|
||||
fclose($f);
|
||||
}
|
||||
break;
|
||||
case 'update_block_message':
|
||||
if (!isset($req->data['value'])) {
|
||||
$req->res->code(400);
|
||||
return false;
|
||||
}
|
||||
if (file_exists(API_PATH . 'api.lock')) {
|
||||
// write to existing
|
||||
$f = fopen(API_PATH . 'api.lock', 'w');
|
||||
} else {
|
||||
$f = fopen(API_PATH . '_api.lock', 'w');
|
||||
}
|
||||
fwrite($f, $req->data['value']);
|
||||
fclose($f);
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
$capi = relativePathToUrl(API_PATH . 'api.php');
|
||||
$status = !file_exists(API_PATH . 'api.lock');
|
||||
$apiblockmsg = "";
|
||||
if ($status) {
|
||||
// server enabled (lock disabled)
|
||||
if (file_exists(API_PATH . '_api.lock')) {
|
||||
$apiblockmsg = file_get_contents(API_PATH . '_api.lock');
|
||||
}
|
||||
} else {
|
||||
$apiblockmsg = file_get_contents(API_PATH . 'api.lock');
|
||||
}
|
||||
return ["CLIENT_API" => $capi, "STATUS" => $status, "BLOCKMSG" => $apiblockmsg];
|
||||
}
|
||||
});
|
||||
});
|
||||
+232
-6
@@ -10,6 +10,7 @@ function db()
|
||||
|
||||
function findClosestDateSort($array, $targetDate)
|
||||
{
|
||||
if (!preg_match('/\d{1,2}-\d{1,2}-(\d{2}|\d{4})$/', $targetDate)) return;
|
||||
$targetTimestamp = DateTime::createFromFormat('d-m-y', $targetDate)->getTimestamp();
|
||||
usort($array, function ($a, $b) use ($targetTimestamp) {
|
||||
$aTimestamp = DateTime::createFromFormat('d-m-y', $a['fromDate'])->getTimestamp();
|
||||
@@ -60,16 +61,31 @@ function joinArraysByKey(array $primaryArray, array $secondaryArray, bool $doNot
|
||||
|
||||
function FastDBReq(PDO $db, string $sql, array $params = []): array
|
||||
{
|
||||
// ivan
|
||||
// pickme love
|
||||
// <3 <3 <3 <3
|
||||
$stmt = $db->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
return $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
try {
|
||||
$stmt = $db->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
return $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CreateApi(function ($api) {
|
||||
|
||||
if (file_exists('./api.lock')) {
|
||||
http_response_code(500);
|
||||
$f = fopen('./api.lock', 'r') or die("server eгor");
|
||||
$fs = filesize('./api.lock');
|
||||
if ($fs == 0) {
|
||||
$cnt = "";
|
||||
} else {
|
||||
$cnt = fread($f, $fs);
|
||||
}
|
||||
fclose($f);
|
||||
die($cnt);
|
||||
}
|
||||
|
||||
$api->on('/', 'GET', function () {
|
||||
return 'dengi';
|
||||
});
|
||||
@@ -125,6 +141,23 @@ CreateApi(function ($api) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
$api->on('/get_admin_level', 'POST', function ($req) {
|
||||
if (!isset($req->data['adminId'])) {
|
||||
$req->res->code(400);
|
||||
return "";
|
||||
}
|
||||
$adminId = $req->data['adminId'];
|
||||
$db = db();
|
||||
$results = FastDBReq($db, "SELECT adminPrems FROM admins where adminid = ?", [$adminId]);
|
||||
$db = null;
|
||||
|
||||
if (count($results) != 0) {
|
||||
return $results[0];
|
||||
} else {
|
||||
$req->res->code(400);
|
||||
return;
|
||||
}
|
||||
});
|
||||
$api->on('/admin_login', 'POST', function ($req) {
|
||||
if (!isset($req->data['adminId'])) {
|
||||
$req->res->code(400);
|
||||
@@ -152,6 +185,7 @@ CreateApi(function ($api) {
|
||||
}
|
||||
$classId = substr(strtoupper($req->data['classId']), 0, 10);
|
||||
$day = $req->data['day'];
|
||||
if (!preg_match('/\d{1,2}-\d{1,2}-(\d{2}|\d{4})$/', $day)) return "wrong date format";
|
||||
|
||||
$db = db();
|
||||
$results = FastDBReq($db, "SELECT * FROM changes WHERE classId = ? AND forDay = ?", [$classId, $day]);
|
||||
@@ -362,9 +396,201 @@ CreateApi(function ($api) {
|
||||
FastDBReq($db, 'DELETE FROM rings WHERE classId=? AND fromDate=?', [$classId, $day]);
|
||||
break;
|
||||
default:
|
||||
$db = null;
|
||||
return "you saved your live because you didn't know what tabs are here";
|
||||
}
|
||||
$db = null;
|
||||
return true;
|
||||
});
|
||||
$api->on('/update_admin', "POST", function ($req) {
|
||||
if (!$req->hasData(['adminId', 'action'])) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
$adminId = $req->data['adminId'];
|
||||
$withSelf = true;
|
||||
$action = $req->data['action'];
|
||||
if (isset($req->data['person'])) {
|
||||
$withSelf = false;
|
||||
}
|
||||
$adminId = $req->data['adminId'];
|
||||
$db = db();
|
||||
$results = FastDBReq($db, "SELECT * FROM admins WHERE adminId=?", [$adminId]);
|
||||
if (count($results) == 0) {
|
||||
$db = null;
|
||||
$req->res->code(400);
|
||||
return "админ не найден";
|
||||
}
|
||||
if (!$withSelf && !in_array($results[0]['adminPrems'], [-1, 2])) {
|
||||
$db = null;
|
||||
$req->res->code(400);
|
||||
return 'нету прав';
|
||||
}
|
||||
if ($withSelf) {
|
||||
switch ($action) {
|
||||
case "change_name":
|
||||
if (!isset($req->data['value'])) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
$value = trim($req->data['value']);
|
||||
if (strlen($value) == 0) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
try {
|
||||
FastDBReq($db, 'UPDATE admins SET adminName = ? WHERE adminId = ?', [$value, $adminId]);
|
||||
} catch (PDOException) {
|
||||
$db = null;
|
||||
return "egor";
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$person = $req->data['person'];
|
||||
switch ($action) {
|
||||
case "change_name":
|
||||
if (!isset($req->data['value'])) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
$value = trim($req->data['value']);
|
||||
if (strlen($value) == 0) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
try {
|
||||
FastDBReq($db, 'UPDATE admins SET adminName = ? WHERE adminId = ?', [$value, $person]);
|
||||
} catch (PDOException) {
|
||||
$db = null;
|
||||
return "egor";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$db = null;
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
$db = null;
|
||||
return true;
|
||||
});
|
||||
|
||||
$api->on('/classprofile_view', "POST", function ($req) {
|
||||
if (!$req->hasData(['adminId'])) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
$adminId = $req->data['adminId'];
|
||||
$db = db();
|
||||
$results = FastDBReq($db, "SELECT * FROM admins WHERE adminId=?", [$adminId]);
|
||||
if (count($results) == 0) {
|
||||
$db = null;
|
||||
$req->res->code(400);
|
||||
return "админ не найден";
|
||||
}
|
||||
if (!in_array($results[0]['adminPrems'], [-1, 2])) {
|
||||
$db = null;
|
||||
$req->res->code(400);
|
||||
return "недостаточно прав";
|
||||
}
|
||||
|
||||
$classId = $results[0]['adminClass'];
|
||||
|
||||
$results = FastDBReq($db, "SELECT * FROM classes WHERE classId=?", [$classId]);
|
||||
if (count($results) == 0) {
|
||||
$db = null;
|
||||
$req->res->code(400);
|
||||
return "класса не существует";
|
||||
}
|
||||
$classData = $results[0];
|
||||
$adminsData = FastDBReq($db, "SELECT * FROM admins WHERE adminClass=?", [$classId]);
|
||||
$db = null;
|
||||
|
||||
return ["status" => 1, "class" => $classData, "admins" => $adminsData];
|
||||
});
|
||||
|
||||
$api->on('/classprofile_edit', "POST", function ($req) {
|
||||
if (!$req->hasData(['adminId', 'action'])) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
$adminId = $req->data['adminId'];
|
||||
$db = db();
|
||||
$results = FastDBReq($db, "SELECT * FROM admins WHERE adminId=?", [$adminId]);
|
||||
if (count($results) == 0) {
|
||||
$db = null;
|
||||
$req->res->code(400);
|
||||
return "админ не найден";
|
||||
}
|
||||
if (!in_array($results[0]['adminPrems'], [-1, 2])) {
|
||||
$db = null;
|
||||
$req->res->code(400);
|
||||
return "недостаточно прав";
|
||||
}
|
||||
|
||||
$classId = $results[0]['adminClass'];
|
||||
|
||||
$action = $req->data['action'];
|
||||
|
||||
switch ($action) {
|
||||
case 'update_name':
|
||||
try {
|
||||
if (!isset($req->data['value'])) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
$value = trim($req->data['value']);
|
||||
if (strlen($value) == 0) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
FastDBReq($db, "UPDATE classes SET userclassname = ? WHERE classid=?", [$value, $classId]);
|
||||
return true;
|
||||
} catch (PDOException $e) {
|
||||
error_log($e);
|
||||
return "егор";
|
||||
}
|
||||
break;
|
||||
case 'create_admin':
|
||||
if (!isset($req->data['value'])) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
$value = trim($req->data['value']);
|
||||
if (strlen($value) == 0 || !str_contains($value, ';')) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
$value = explode(';', $value);
|
||||
if (sizeof($value) != 2) {
|
||||
$req->res->code(400);
|
||||
return 'bad data';
|
||||
}
|
||||
$n_adminId = $value[0];
|
||||
$n_adminName = base64_decode($value[1]);
|
||||
|
||||
try {
|
||||
FastDBReq($db, "INSERT INTO admins (adminId,adminName,adminClass,adminPrems) VALUES (?,?,?,?)", [$n_adminId, $n_adminName, $classId, 1]);
|
||||
return true;
|
||||
} catch (PDOException) {
|
||||
$req->res->code(500);
|
||||
return "ошибка";
|
||||
}
|
||||
case "delete_admin":
|
||||
if (!isset($req->data['value'])) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
$person = trim($req->data['value']);
|
||||
if (strlen($person) == 0) {
|
||||
$req->res->code(400);
|
||||
return "bad data";
|
||||
}
|
||||
FastDBReq($db, "DELETE FROM admins WHERE adminId=?", [$person]);
|
||||
return true;
|
||||
default:
|
||||
$db = null;
|
||||
return "?";
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
+31
-6
@@ -1,38 +1,54 @@
|
||||
<?php
|
||||
|
||||
/** @param callable(_K_Api): void $apiFun */
|
||||
function CreateApi(callable $apiFun)
|
||||
function CreateApi(callable $apiFun, bool $devmode = false)
|
||||
{
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Headers: Content-Type");
|
||||
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization");
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
||||
http_response_code(200);
|
||||
exit;
|
||||
}
|
||||
|
||||
$api = new _K_Api();
|
||||
$api->dev_mode = $devmode;
|
||||
$apiFun($api);
|
||||
$api->end();
|
||||
}
|
||||
class _K_Api
|
||||
{
|
||||
private $has_exec = false;
|
||||
public $dev_mode = false;
|
||||
/** @param callable(_K_ApiRequest): string|array|int|float|bool $fun */
|
||||
public function on(string $route, string $method, callable $fun)
|
||||
{
|
||||
$request_url = (count($_GET) > 0 ? array_keys($_GET)[0] : '');
|
||||
$r = str_starts_with($route, '/') ? substr($route, 1) : $route;
|
||||
if ($this->has_exec) return;
|
||||
if ($r != $request_url) {
|
||||
return;
|
||||
} else {
|
||||
$this->has_exec = true;
|
||||
if ($_SERVER['REQUEST_METHOD'] != $method) {
|
||||
|
||||
$req_method = $_SERVER['REQUEST_METHOD'];
|
||||
if ($req_method != $method) {
|
||||
http_response_code(405);
|
||||
die("ERROR: unsupported method ($method available)");
|
||||
$_a = "";
|
||||
if ($this->dev_mode)
|
||||
$_a = " - using $req_method, available $method";
|
||||
die("ERROR: Method Not Allowed" . $_a);
|
||||
return;
|
||||
}
|
||||
|
||||
$data = [];
|
||||
if ($method == 'GET' && count($_GET) > 1) {
|
||||
$data = array_slice(array_keys($_GET), 1);
|
||||
} else if ($method == 'POST' && count($_POST) > 0) {
|
||||
$data = $_POST;
|
||||
}
|
||||
|
||||
$fun = $fun(new _K_ApiRequest($data));
|
||||
if (is_string($fun) || is_numeric($fun)) {
|
||||
if (json_validate($fun) && !is_numeric($fun)) {
|
||||
@@ -43,8 +59,17 @@ class _K_Api
|
||||
Header('Content-Type: application/json');
|
||||
echo json_encode($fun);
|
||||
} else {
|
||||
die("ERROR: unknown return type");
|
||||
http_response_code(500);
|
||||
$_a = "Internal Server Error";
|
||||
if ($this->dev_mode) {
|
||||
$_type = gettype($fun);
|
||||
$_a = "unknown return type ($_type), (available bool, array, numeric, string)";
|
||||
}
|
||||
die("ERROR: " . $_a);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +77,7 @@ class _K_Api
|
||||
{
|
||||
if (!$this->has_exec) {
|
||||
http_response_code(404);
|
||||
echo '404';
|
||||
echo 'ERROR: Not Found';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<?php phpinfo();
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
echo 'test';
|
||||
Reference in New Issue
Block a user