diff --git a/api/api.php b/api/api.php index 789761b..2247c32 100755 --- a/api/api.php +++ b/api/api.php @@ -1,4 +1,11 @@ setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $db->prepare($command); @@ -90,4 +97,4 @@ class gbAPI { return $result; } } -} \ No newline at end of file +} diff --git a/api/setup/save.php b/api/setup/save.php index 9a58e58..930af76 100755 --- a/api/setup/save.php +++ b/api/setup/save.php @@ -46,7 +46,7 @@ $db_path = APP_PATH . "database.db"; $db = new PDO("sqlite:" . $db_path); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); -$db = exec($sql_file); +$db->exec($sql_file); @@ -56,4 +56,5 @@ $command = "INSERT INTO users (username, password, owner) VALUES (:username, :pa $stmt = $db->prepare($command); $stmt->execute([":username" => $username, ":password" => $hash, ":owner" => 1]); -$api->answer(200); \ No newline at end of file +$api->answer(200); + diff --git a/database.db b/database.db old mode 100755 new mode 100644 index e69de29..56156f7 Binary files a/database.db and b/database.db differ diff --git a/db_structure.sql b/db_structure.sql index fde2727..deb7921 100755 --- a/db_structure.sql +++ b/db_structure.sql @@ -1,15 +1,14 @@ CREATE TABLE IF NOT EXISTS "users" ( - "id" INTEGER NOT NULL, - "username" VARCHAR NOT NULL, - "password" VARCHAR NOT NULL, - "owner" INTEGER NOT NULL, - PRIMARY KEY("id", "username", "owner") + "id" INTEGER PRIMARY KEY AUTOINCREMENT, + "username" TEXT NOT NULL UNIQUE, + "password" TEXT NOT NULL, + "owner" INTEGER NOT NULL DEFAULT 0 ); CREATE TABLE IF NOT EXISTS "entrys" ( - "id" INTEGER NOT NULL, - "name" VARCHAR NOT NULL, - "text" VARCHAR NOT NULL, - "status" INTEGER, - PRIMARY KEY("id") + "id" INTEGER PRIMARY KEY AUTOINCREMENT, + "name" TEXT NOT NULL, + "text" TEXT NOT NULL, + "status" INTEGER NOT NULL DEFAULT 0 ); + diff --git a/public/test.php b/public/test.php index ade805b..d3ba69f 100755 --- a/public/test.php +++ b/public/test.php @@ -6,9 +6,11 @@ //echo $_SERVER["HTTP_X_API_KEY"]; -$string = '{"user":"marc", "auth":true}'; -$secret = "281361f952279bd9530734c67ed04aed2756f0fe00cb998cd6c28324f491484c"; +//$string = '{"user":"marc", "auth":true}'; +//$secret = "281361f952279bd9530734c67ed04aed2756f0fe00cb998cd6c28324f491484c"; -echo "Hash: " . hash_hmac("sha256", $string, $secret); +//echo "Hash: " . hash_hmac("sha256", $string, $secret); -echo "Decode: " . hash_equals($string, $secret); \ No newline at end of file +//echo "Decode: " . hash_equals($string, $secret); + +print_r(PDO::getAvailableDrivers());