Update file permissions and enhance error handling in API responses
This commit is contained in:
1 parent
eb67458ab1
commit
ce0777bb33
8 files changed
+28
-6
No files matched your search
+14
-2
@@ -220,10 +220,18 @@ class gbAPI {
|
|||||||
if (!is_file($db_path)) {
|
if (!is_file($db_path)) {
|
||||||
$api->answer(500, [
|
$api->answer(500, [
|
||||||
"error" => "database_not_found",
|
"error" => "database_not_found",
|
||||||
"error_display" => "The Database was not found."
|
"error_text" => "The Database was not found."
|
||||||
], true);
|
], 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 = new PDO("sqlite:" . $db_path);
|
||||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
}
|
}
|
||||||
@@ -243,6 +251,10 @@ class gbAPI {
|
|||||||
|
|
||||||
$value = $this->dbCommand($command, true, true, [":name" => $key]);
|
$value = $this->dbCommand($command, true, true, [":name" => $key]);
|
||||||
|
|
||||||
return $value[0]["value"];
|
if (isset($value[0]["value"])) {
|
||||||
|
return $value[0]["value"];
|
||||||
|
}else{
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,13 @@ $api = new gbAPI(false, $internal);
|
|||||||
|
|
||||||
// Get App Name
|
// Get App Name
|
||||||
$result = $api->getSetting("application_name");
|
$result = $api->getSetting("application_name");
|
||||||
|
if ($result !== NULL) {
|
||||||
$api->answer(200, [
|
$api->answer(200, [
|
||||||
"application_name" => $result
|
"application_name" => $result
|
||||||
]);
|
]);
|
||||||
|
}else{
|
||||||
|
$api->answer(500, [
|
||||||
|
"error" => "empty_query",
|
||||||
|
"error_text" => "Database query returned nothing."
|
||||||
|
]);
|
||||||
|
}
|
||||||
Regular → Executable
File mode changed.
BIN
Binary file not shown.
Regular → Executable
File mode changed.
@@ -93,6 +93,10 @@ class HTMLLoader {
|
|||||||
if ($showAppName) {
|
if ($showAppName) {
|
||||||
$call = new APICall("settings/appname.php");
|
$call = new APICall("settings/appname.php");
|
||||||
$response = $call->response;
|
$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"];
|
$app_name = $response["data"]["application_name"];
|
||||||
|
|
||||||
$html = str_replace("%appname%", $app_name, $html);
|
$html = str_replace("%appname%", $app_name, $html);
|
||||||
|
|||||||
Regular → Executable
File mode changed.
Reference in new issue
Block a user