diff --git a/api/api.php b/api/api.php index bae2be2..a38bb6f 100755 --- a/api/api.php +++ b/api/api.php @@ -40,7 +40,7 @@ class gbAPI { "error_text" => "Authentication failed." ]; - $this->answer($status, $data); + $this->answer($status, $data, true); } } } @@ -181,6 +181,7 @@ class gbAPI { // Check if request is internal or external if ($this->internal) { $this->response = $return; + return; }else{ http_response_code($status); header("Content-Type: application/json; charset=UTF-8"); diff --git a/api/auth/login.php b/api/auth/login.php index 91ea1ad..fde592a 100755 --- a/api/auth/login.php +++ b/api/auth/login.php @@ -18,6 +18,7 @@ if (!isset($input["username"]) || !isset($input["password"])) { "error" => "missing_fields", "error_text" => "Some fields are missing" ], true); + return; } $username = $input["username"]; diff --git a/api/entrys/add.php b/api/entrys/add.php index e3e2bf7..44bb928 100755 --- a/api/entrys/add.php +++ b/api/entrys/add.php @@ -16,7 +16,8 @@ if (!isset($input["name"]) || !isset($input["text"])) { $api->answer(400, [ "error" => "missing_fields", "error_text" => "Some fields are missing" - ]); + ], true); + return; } $html_allowed = $api->getSetting("allow_html"); diff --git a/api/entrys/get.php b/api/entrys/get.php index b8844ec..f863d51 100755 --- a/api/entrys/get.php +++ b/api/entrys/get.php @@ -21,6 +21,7 @@ if (!$result) { "entrys" => [], "empty" => true ]); + return; } foreach($result as $row) { diff --git a/api/settings/appname.php b/api/settings/appname.php index 0977cee..a9d279f 100755 --- a/api/settings/appname.php +++ b/api/settings/appname.php @@ -11,9 +11,8 @@ require_once API_DIR . "api.php"; $api = new gbAPI(false, $internal); // Get App Name -$command = "SELECT name, value FROM settings WHERE name = :name"; -$result = $api->dbCommand($command, true, true, [":name" => "application_name"]); +$result = $api->getSetting("application_name"); $api->answer(200, [ - "application_name" => $result[0]["value"] + "application_name" => $result ]); \ No newline at end of file diff --git a/api/setup/save.php b/api/setup/save.php index 8b693c3..ce5f791 100755 --- a/api/setup/save.php +++ b/api/setup/save.php @@ -18,6 +18,7 @@ if (!isset($input["username"]) || !isset($input["password"]) || !isset($input["p "error" => "missing_fields", "error_text" => "Some fields are missing" ]); + return; } // Check if application already configurated @@ -26,6 +27,7 @@ if (is_file(APP_PATH . "database.db")) { "error" => "already_configurated", "error_text" => "The application is already configurated." ]); + return; } // Check PDO drivers @@ -34,6 +36,7 @@ if (!extension_loaded("pdo_sqlite") || !extension_loaded("sqlite3")) { "error" => "missing_drives", "error_text" => "Please install the extensions pdo_sqlite and sqlite3." ]); + return; } $username = $input["username"]; @@ -46,6 +49,7 @@ if ($password !== $password_repeat) { "error" => "passwords_dont_match", "error_text" => "The passwords does not match." ]); + return; } // Hash Password diff --git a/public/admin/index.php b/public/admin/index.php new file mode 100644 index 0000000..fbe2964 --- /dev/null +++ b/public/admin/index.php @@ -0,0 +1,22 @@ +response; + +if (!isset($response["data"]["login"])) { + $htmlloader->setPage("login"); + $htmlloader->show(); +} \ No newline at end of file diff --git a/public/html_loader.php b/public/html_loader.php index abbf8ce..a719383 100755 --- a/public/html_loader.php +++ b/public/html_loader.php @@ -91,9 +91,9 @@ class HTMLLoader { $html = file_get_contents(TEMPLATE_PATH . $template_dir . "/" . $page["dir_name"] . "/" . $page["html_file"]); if ($showAppName) { - $app_name = file_get_contents("http://" . APP_DOMAIN . "/api/settings/appname.php"); - $app_name = json_decode($app_name, true); - $app_name = $app_name["data"]["application_name"]; + $call = new APICall("settings/appname.php"); + $response = $call->response; + $app_name = $response["data"]["application_name"]; $html = str_replace("%appname%", $app_name, $html); } diff --git a/public/index.php b/public/index.php index 3814bc7..cda4d16 100755 --- a/public/index.php +++ b/public/index.php @@ -40,4 +40,4 @@ if ($response["data"]["empty"]) { } } -$htmlLoader->show(["%entrys%" => $html_block]); \ No newline at end of file +$htmlLoader->show(["%entrys%" => $html_block]);