diff --git a/exam/api/docs/index.css b/exam/api/docs/index.css
new file mode 100644
index 0000000..88cb00c
--- /dev/null
+++ b/exam/api/docs/index.css
@@ -0,0 +1,3 @@
+body {
+ background-color: red;
+}
\ No newline at end of file
diff --git a/exam/api/docs/index.html b/exam/api/docs/index.html
index 2fbdaa8..68a3df6 100644
--- a/exam/api/docs/index.html
+++ b/exam/api/docs/index.html
@@ -1 +1,10 @@
-DOCUMENTATION
+
+
+
+
+
+ Calculator
+
+
+
+
diff --git a/exam/api/index.php b/exam/api/index.php
index e495dfe..8ed3009 100644
--- a/exam/api/index.php
+++ b/exam/api/index.php
@@ -1,4 +1,3 @@
prepare($query);
+ $stmt->execute();
+
+ Response::api($stmt->fetchAll());
+}
diff --git a/exam/api/users/index.php b/exam/api/users/index.php
index c032abf..5cc4ccb 100644
--- a/exam/api/users/index.php
+++ b/exam/api/users/index.php
@@ -11,5 +11,16 @@ switch ($method) {
function get()
{
- Response::api("GET USERS");
+ $db = Database::getInstance();
+
+ $query =
+ "SELECT
+ *
+ FROM
+ egb_benutzer";
+
+ $stmt = $db->prepare($query);
+ $stmt->execute();
+
+ Response::api($stmt->fetchAll());
}
diff --git a/exam/config/database.php b/exam/config/database.php
new file mode 100644
index 0000000..c70d477
--- /dev/null
+++ b/exam/config/database.php
@@ -0,0 +1,9 @@
+ "usersql.zedat.fu-berlin.de",
+ "user" => "khofmann-sql",
+ "passwd" => "xz8c7m7p",
+ "database" => "khofmann-db1",
+ "charset" => "utf8",
+];
diff --git a/exam/routes/routes.php b/exam/routes/routes.php
index 8408996..c977975 100644
--- a/exam/routes/routes.php
+++ b/exam/routes/routes.php
@@ -4,7 +4,11 @@ $path = ltrim(str_replace(Config::getBasePath(), "", $_SERVER['REQUEST_URI']), "
try {
if (substr($path, 0, 3) === "api") {
- require_once __DIR__ . "/../api/index.php";
+ if (strpos($path, "docs") === false) {
+ require_once __DIR__ . "/../$path/index.php";
+ } else {
+ Headers::redirect("index.html");
+ }
} else {
require_once __DIR__ . "/../pages/index.html";
}
diff --git a/exam/vendor/config/config.php b/exam/vendor/config/config.php
index f686e9d..af3d89f 100644
--- a/exam/vendor/config/config.php
+++ b/exam/vendor/config/config.php
@@ -5,10 +5,12 @@ class Config
private static $instances = [];
private array $app;
+ private array $database;
protected function __construct()
{
$this->app = require_once __DIR__ . "/../../config/app.php";
+ $this->database = require_once __DIR__ . "/../../config/database.php";
}
protected function __clone()
@@ -34,4 +36,9 @@ class Config
{
return Config::getInstance()->app["basePath"];
}
+
+ public static function getDatabase()
+ {
+ return Config::getInstance()->database;
+ }
}
diff --git a/exam/vendor/database/database.php b/exam/vendor/database/database.php
new file mode 100644
index 0000000..ffda7ba
--- /dev/null
+++ b/exam/vendor/database/database.php
@@ -0,0 +1,32 @@
+ false,
+ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
+ PDO::ATTR_EMULATE_PREPARES => false,
+ ]
+ );
+ }
+
+ return self::$instances[$cls];
+ }
+}