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