From 2ac799d0a48a08ac62c90100623cb94ccf25822d Mon Sep 17 00:00:00 2001 From: hacker_marc Date: Sat, 3 Oct 2026 22:03:11 +0200 Subject: [PATCH] Enhance gbAPI with configuration loading, token generation, and response formatting; update file permissions for API and template files --- api/api.php | 29 +++++++++++++++++++- api/setup/save.php | 4 ++- public/templates/entrys_frontend/entrys.html | 0 public/templates/setup/setup.css | 0 public/test.php | 4 ++- 5 files changed, 34 insertions(+), 3 deletions(-) mode change 100644 => 100755 api/api.php mode change 100644 => 100755 api/setup/save.php mode change 100644 => 100755 public/templates/entrys_frontend/entrys.html mode change 100644 => 100755 public/templates/setup/setup.css diff --git a/api/api.php b/api/api.php old mode 100644 new mode 100755 index d02cd72..9f01168 --- a/api/api.php +++ b/api/api.php @@ -4,10 +4,37 @@ class gbAPI { public $authRequired; function __construct() { - define("APP_PATH", __DIR__ . "/.."); + define("APP_PATH", __DIR__ . "/../"); if ($this->authRequited) { $this->checkAuth(); } } + + function getConfig() { + return parse_ini_file(APP_PATH . ".env"); + } + + function generateToken() { + $config = $this->getConfig(); + + // Generate Token + $token = bin2hex(random_bytes(32)); + $secret = $config["COOKIE_SIGNATURE"]; + + return hash_hmac('sha256', $token, SECRET, true); + } + + function checkAuth() { + if (isset($_SERVER)) + } + + function answer($status, $data) { + http_response_code($status); + + $data = json_encode($data); + + $json = '{"status":' . $status . ',"data":' $data . '}'; + die($json); + } } \ No newline at end of file diff --git a/api/setup/save.php b/api/setup/save.php old mode 100644 new mode 100755 index 6328718..69e519b --- a/api/setup/save.php +++ b/api/setup/save.php @@ -1,3 +1,5 @@ $value) { echo $key . " === " . $value . "
"; -} \ No newline at end of file +} + +//echo $_SERVER["HTTP_X_API_KEY"]; \ No newline at end of file