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)) {
|
||||
$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]);
|
||||
|
||||
return $value[0]["value"];
|
||||
if (isset($value[0]["value"])) {
|
||||
return $value[0]["value"];
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user