Fix Bugs and finish setup.php
This commit is contained in:
1 parent
3ad5f5bdd6
commit
f2bd887783
2 files changed
+19
-2
No files matched your search
+1
-1
@@ -65,7 +65,7 @@ class gbAPI {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function answer($status, $data) {
|
function answer($status, $data = []) {
|
||||||
http_response_code($status);
|
http_response_code($status);
|
||||||
Header ("Content-Type: application/json; charset=UTF-8");
|
Header ("Content-Type: application/json; charset=UTF-8");
|
||||||
|
|
||||||
|
|||||||
+18
-1
@@ -37,4 +37,21 @@ $hash = password_hash($password);
|
|||||||
|
|
||||||
|
|
||||||
// CREATE DATABASE STRUCTURE
|
// CREATE DATABASE STRUCTURE
|
||||||
file_get_contents(APP_PATH . "db_structure.sql");
|
$sql_file = file_get_contents(APP_PATH . "db_structure.sql");
|
||||||
|
|
||||||
|
$db_path = APP_PATH . "database.db";
|
||||||
|
|
||||||
|
$db = new PDO("sqlite:" . $db_path);
|
||||||
|
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
|
||||||
|
$db = exec($sql_file);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// INSERT USER
|
||||||
|
$command = "INSERT INTO users (username, password, owner) VALUES (:username, :password, :owner)";
|
||||||
|
|
||||||
|
$stmt = $db->prepare($command);
|
||||||
|
$stmt->execute([":username" => $username, ":password" => $hash, ":owner" => 1]);
|
||||||
|
|
||||||
|
$api->answer(200);
|
||||||
Reference in new issue
Block a user