Refactor API structure: add internal handling, update templates, and remove deprecated files

This commit is contained in:
marc-go committed 2026-10-10 13:43:18 +02:00
1 parent 313ffec92c
commit a33de15f0c
16 files changed
+91 -29

No files matched your search

+4 -1
View File
@@ -12,6 +12,8 @@ class gbAPI {
private $db;
private $config;
private $internal;
private function b64url_encode($data) {
return rtrim(strtr(base64_encode($data), "+/", "-_"), "=");
}
@@ -20,8 +22,9 @@ class gbAPI {
return base64_decode(strtr($data, "-_", "+/"));
}
function __construct($authRequired) {
function __construct($authRequired, $internal) {
define("APP_PATH", __DIR__ . "/../");
$this->internal = $internal;
if ($authRequired) {
if (!$this->checkAuth()) {
+5
View File
@@ -1,4 +1,9 @@
<?php
// Set internal to false so that the answer goes to the client
if (!isset($internal)) {
$internal = false;
}
// Load Main Library
require "../api.php";
$api = new gbAPI(true);
+5
View File
@@ -1,4 +1,9 @@
<?php
// Set internal to false so that the answer goes to the client
if (!isset($internal)) {
$internal = false;
}
// Load API Library
require "../api.php";
+5
View File
@@ -1,4 +1,9 @@
<?php
// Set internal to false so that the answer goes to the client
if (!isset($internal)) {
$internal = false;
}
// Load Main Library
require "../api.php";
+5
View File
@@ -1,4 +1,9 @@
<?php
// Set internal to false so that the answer goes to the client
if (!isset($internal)) {
$internal = false;
}
// Load Main Library
require "../api.php";
+5
View File
@@ -1,4 +1,9 @@
<?php
// Set internal to false so that the answer goes to the client
if (!isset($internal)) {
$internal = false;
}
// Load Main Library
require "../api.php";
+2 -1
View File
@@ -80,7 +80,8 @@ $settings = [
"application_name" => "Guestbook",
"allow_html" => "false",
"approve_entrys" => "true",
"allow_new_entrys" => "true"
"allow_new_entrys" => "true",
"template" => "standard"
];
foreach ($settings as $key => $value) {
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
class HTMLLoader {
private $template;
private $page;
function __construct() {
// Check if Paths variables exists
@@ -20,7 +20,7 @@ class HTMLLoader {
}elseif (!array_key_exists("error", $json)){
die("Error Template was not found.");
}
$this->template = $template;
$this->page = $template;
}
function showError($error) {
+27
View File
@@ -12,6 +12,7 @@ class gb {
define("APP_DOMAIN", $_SERVER["SERVER_NAME"]);
define("APP_PATH", __DIR__ . "/../");
define("FRONTEND_PATH", __DIR__ . "/");
define("API_PATH", __DIR__ . "/../api/");
define("TEMPLATE_PATH", FRONTEND_PATH . "templates/");
define("TEMPLATE_CONF", TEMPLATE_PATH . "templates.json");
@@ -30,4 +31,30 @@ class gb {
$html->setTemplate("setup");
$html->show();
}
}
// Internal API Call Library
class APICall {
private $response;
private $error;
function __construct($path, $data) {
// Set $internal to true so the api return does not go to the browser
$internal = true;
// Check Path
if (!is_file(API_PATH . $path)) {
$this->error("API Path invalid.");
return false;
}
// Call API
require API_PATH . $path;
// Get return from the API Library
$response = $api->getAnswer();
$this->response = $response;
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+28
View File
@@ -0,0 +1,28 @@
{
"error":{
"name":"error",
"dir_name":"error",
"html_file":"error.html",
"css_files":[
"error.css"
]
},
"setup":{
"name":"setup",
"dir_name":"setup",
"html_file":"setup.html",
"css_files":[]
},
"entrys_frontend":{
"name":"entrys_frontend",
"dir_name":"entrys_frontend",
"html_file":"entrys_frontend.html",
"css_files":[]
},
"login":{
"name":"login",
"dir_name":"login",
"html_file":"login.html",
"css_files":[]
}
}
Executable → Regular
+3 -25
View File
@@ -1,28 +1,6 @@
{
"error":{
"name":"error",
"dir_name":"error",
"html_file":"error.html",
"css_files":[
"error.css"
]
},
"setup":{
"name":"setup",
"dir_name":"setup",
"html_file":"setup.html",
"css_files":[]
},
"entrys_frontend":{
"name":"entrys_frontend",
"dir_name":"entrys_frontend",
"html_file":"entrys_frontend.html",
"css_files":[]
},
"login":{
"name":"login",
"dir_name":"login",
"html_file":"login.html",
"css_files":[]
"standard":{
"name":"Standard Template",
"dir_name":"standard"
}
}