Update file permissions and enhance error handling in API responses

This commit is contained in:
admin committed 2026-10-10 21:26:38 +02:00
1 parent eb67458ab1
commit ce0777bb33
8 files changed
+24 -2

No files matched your search

Regular → Executable
View File
File mode changed.
+13 -1
View File
@@ -220,10 +220,18 @@ class gbAPI {
if (!is_file($db_path)) {
$api->answer(500, [
"error" => "database_not_found",
"error_display" => "The Database was not found."
"error_text" => "The Database was not found."
], true);
}
if (!is_writeable($db_path)) {
$this->answer(500, [
"error" => "database_not_writeable",
"error_text" => "The Database is not writeable."
]);
return;
}
$db = new PDO("sqlite:" . $db_path);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
@@ -243,6 +251,10 @@ class gbAPI {
$value = $this->dbCommand($command, true, true, [":name" => $key]);
if (isset($value[0]["value"])) {
return $value[0]["value"];
}else{
return;
}
}
}
+7 -1
View File
@@ -12,7 +12,13 @@ $api = new gbAPI(false, $internal);
// Get App Name
$result = $api->getSetting("application_name");
if ($result !== NULL) {
$api->answer(200, [
"application_name" => $result
]);
}else{
$api->answer(500, [
"error" => "empty_query",
"error_text" => "Database query returned nothing."
]);
}
Regular → Executable
View File
File mode changed.
BIN
View File
Binary file not shown.
Regular → Executable
View File
File mode changed.
+4
View File
@@ -93,6 +93,10 @@ class HTMLLoader {
if ($showAppName) {
$call = new APICall("settings/appname.php");
$response = $call->response;
if (isset($response["error"])) {
$this->showError("Failed to get Application Name: API Returned an error: " . $response["error_text"]);
}
$app_name = $response["data"]["application_name"];
$html = str_replace("%appname%", $app_name, $html);
Regular → Executable
View File
File mode changed.