diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..28a804d
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..ff4d14b
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/taskit.iml b/.idea/taskit.iml
new file mode 100644
index 0000000..c956989
--- /dev/null
+++ b/.idea/taskit.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..3791bed
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1641996109010
+
+
+ 1641996109010
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.vs/ProjectSettings.json b/.vs/ProjectSettings.json
new file mode 100644
index 0000000..f8b4888
--- /dev/null
+++ b/.vs/ProjectSettings.json
@@ -0,0 +1,3 @@
+{
+ "CurrentProjectSetting": null
+}
\ No newline at end of file
diff --git a/.vs/VPR_Backend/CopilotIndices/17.12.53.23981/CodeChunks.db b/.vs/VPR_Backend/CopilotIndices/17.12.53.23981/CodeChunks.db
new file mode 100644
index 0000000..9c14866
Binary files /dev/null and b/.vs/VPR_Backend/CopilotIndices/17.12.53.23981/CodeChunks.db differ
diff --git a/.vs/VPR_Backend/CopilotIndices/17.12.53.23981/SemanticSymbols.db b/.vs/VPR_Backend/CopilotIndices/17.12.53.23981/SemanticSymbols.db
new file mode 100644
index 0000000..527188c
Binary files /dev/null and b/.vs/VPR_Backend/CopilotIndices/17.12.53.23981/SemanticSymbols.db differ
diff --git a/.vs/VPR_Backend/CopilotIndices/17.12.53.23981/SemanticSymbols.db-shm b/.vs/VPR_Backend/CopilotIndices/17.12.53.23981/SemanticSymbols.db-shm
new file mode 100644
index 0000000..7ea75a5
Binary files /dev/null and b/.vs/VPR_Backend/CopilotIndices/17.12.53.23981/SemanticSymbols.db-shm differ
diff --git a/.vs/VPR_Backend/CopilotIndices/17.12.53.23981/SemanticSymbols.db-wal b/.vs/VPR_Backend/CopilotIndices/17.12.53.23981/SemanticSymbols.db-wal
new file mode 100644
index 0000000..3045920
Binary files /dev/null and b/.vs/VPR_Backend/CopilotIndices/17.12.53.23981/SemanticSymbols.db-wal differ
diff --git a/.vs/VPR_Backend/FileContentIndex/79ae8a60-0676-438a-bb17-f1b4ca7f1666.vsidx b/.vs/VPR_Backend/FileContentIndex/79ae8a60-0676-438a-bb17-f1b4ca7f1666.vsidx
new file mode 100644
index 0000000..07fa9d6
Binary files /dev/null and b/.vs/VPR_Backend/FileContentIndex/79ae8a60-0676-438a-bb17-f1b4ca7f1666.vsidx differ
diff --git a/.vs/VPR_Backend/v17/.wsuo b/.vs/VPR_Backend/v17/.wsuo
new file mode 100644
index 0000000..ab9a83c
Binary files /dev/null and b/.vs/VPR_Backend/v17/.wsuo differ
diff --git a/.vs/VPR_Backend/v17/DocumentLayout.json b/.vs/VPR_Backend/v17/DocumentLayout.json
new file mode 100644
index 0000000..25321c4
--- /dev/null
+++ b/.vs/VPR_Backend/v17/DocumentLayout.json
@@ -0,0 +1,39 @@
+{
+ "Version": 1,
+ "WorkspaceRootPath": "C:\\Bib Unterlagen\\SEN\\VPR\\VPR_Backend\\",
+ "Documents": [],
+ "DocumentGroupContainers": [
+ {
+ "Orientation": 0,
+ "VerticalTabListWidth": 256,
+ "DocumentGroups": [
+ {
+ "DockedWidth": 200,
+ "SelectedChildIndex": -1,
+ "Children": [
+ {
+ "$type": "Bookmark",
+ "Name": "ST:0:0:{b1e99781-ab81-11d0-b683-00aa00a3ee26}"
+ },
+ {
+ "$type": "Bookmark",
+ "Name": "ST:128:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}"
+ },
+ {
+ "$type": "Bookmark",
+ "Name": "ST:0:0:{3ae79031-e1bc-11d0-8f78-00a0c9110057}"
+ },
+ {
+ "$type": "Bookmark",
+ "Name": "ST:0:0:{1c64b9c2-e352-428e-a56d-0ace190b99a6}"
+ },
+ {
+ "$type": "Bookmark",
+ "Name": "ST:0:0:{40ea2e6b-2121-4bb8-a43e-c83c04b51041}"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json
new file mode 100644
index 0000000..86894d7
--- /dev/null
+++ b/.vs/VSWorkspaceState.json
@@ -0,0 +1,7 @@
+{
+ "ExpandedNodes": [
+ ""
+ ],
+ "SelectedNode": "\\C:\\Bib Unterlagen\\SEN\\VPR\\VPR_Backend",
+ "PreviewInSolutionExplorer": false
+}
\ No newline at end of file
diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite
new file mode 100644
index 0000000..f9c88b0
Binary files /dev/null and b/.vs/slnx.sqlite differ
diff --git a/Tests/connectionTest.php b/Tests/connectionTest.php
new file mode 100644
index 0000000..c3e5e0d
--- /dev/null
+++ b/Tests/connectionTest.php
@@ -0,0 +1,20 @@
+
+linkDB();
+
+ // If the connection is successful
+ echo "Connected successfully using PDO";
+} catch (Exception $e) {
+ // Handle connection error
+ error_log($e->getMessage()); // Log the error message
+ echo "An error occurred while connecting to the database. Please try again later.";
+}
diff --git a/Tests/controllersTest.php b/Tests/controllersTest.php
new file mode 100644
index 0000000..eedc486
--- /dev/null
+++ b/Tests/controllersTest.php
@@ -0,0 +1,40 @@
+testController($controllerPath, $methodName, $params);
+echo '
';
+print_r($result);
+echo '
';
\ No newline at end of file
diff --git a/Tests/test.php b/Tests/test.php
new file mode 100644
index 0000000..3c71f64
--- /dev/null
+++ b/Tests/test.php
@@ -0,0 +1,128 @@
+ $url . '/project',
+ // CURLOPT_COOKIEFILE => $filepath . 'cookie.txt', // set cookie file to given file
+ // CURLOPT_COOKIEJAR => $filepath . 'cookie.txt', // set same file as cookie jar
+ CURLOPT_CUSTOMREQUEST => "GET"
+
+ );
+
+/**
+ * Options for get all tasks
+ */
+ // $defaults = array(
+ // CURLOPT_URL => $url . '/task',
+ // CURLOPT_COOKIEFILE => $filepath . 'cookie.txt', // set cookie file to given file
+ // CURLOPT_COOKIEJAR => $filepath . 'cookie.txt', // set same file as cookie jar
+ // CURLOPT_CUSTOMREQUEST => "GET"
+ // );
+
+/**
+ * Options for get tasks filtered
+ */
+ // $defaults = array(
+ // CURLOPT_URL => $url . '/task/getFilteredTasks?dueDate=1%20DAY',
+ // CURLOPT_COOKIEFILE => $filepath . 'cookie.txt', // set cookie file to given file
+ // CURLOPT_COOKIEJAR => $filepath . 'cookie.txt', // set same file as cookie jar
+ // CURLOPT_CUSTOMREQUEST => "GET"
+ // );
+
+/**
+ * Options for insert new task
+ */
+ // $params = json_encode(array(
+ // "projectId" => '72f7cc6e-3717-11eb-add7-2c4d544f8fe0'
+ // , 'title' => 'Neuer Task 5'
+ // , 'expense' => '0,25'
+ // , 'dueDate' => '15.03.2022'
+ // , 'priorityId' => 1));
+ // $defaults = array(
+ // CURLOPT_URL => $url . '/task',
+ // CURLOPT_CUSTOMREQUEST => "POST",
+ // // CURLOPT_COOKIEFILE => $filepath . 'cookie.txt', // set cookie file to given file
+ // // CURLOPT_COOKIEJAR => $filepath . 'cookie.txt', // set same file as cookie jar
+ // CURLOPT_POSTFIELDS => $params
+ // );
+
+/**
+ * Options for Update Task OHNE Login
+ */
+ // $params = json_encode(array("done" => '0'));
+ // $defaults = array(
+ // CURLOPT_URL => $url . '/task/1b2d4564-3718-11eb-add7-2c4d544f8fe0',
+ // CURLOPT_CUSTOMREQUEST => "PUT",
+ // CURLOPT_POSTFIELDS => $params
+ // );
+
+
+/**
+ * Options for Delete Task OHNE Login
+ */
+ // $defaults = array(
+ // CURLOPT_URL => $url . '/task/01b169aa-3718-11eb-add7-2c4d544f8fe0',
+ // CURLOPT_CUSTOMREQUEST => "DELETE"
+ // );
+
+/**
+ * Options for Delete Task MIT Login
+ */
+ // $defaults = array(
+ // CURLOPT_URL => $url . '/task/cbdb169f-e0da-11e7-a056-2c4d544f8fe0',
+ // CURLOPT_COOKIEFILE => $filepath . 'cookie.txt', // set cookie file to given file
+ // CURLOPT_COOKIEJAR => $filepath . 'cookie.txt', // set same file as cookie jar
+ // CURLOPT_CUSTOMREQUEST => "DELETE"
+ // );
+
+/**
+ * Options for loginUser
+ */
+ // $defaults = array(
+ // CURLOPT_URL => $url . '/user/loginUser?username=fiona&pw=12345',
+ // CURLOPT_CUSTOMREQUEST => "GET",
+ // CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
+ // CURLOPT_COOKIEFILE => $filepath . 'cookie.txt', // set cookie file to given file
+ // CURLOPT_COOKIEJAR => $filepath . 'cookie.txt' // set same file as cookie jar
+ // );
+
+/**
+ * Options for isLogin
+ */
+ // $defaults = array(
+ // CURLOPT_URL => $url . '/user/isLogin',
+ // CURLOPT_CUSTOMREQUEST => "GET",
+ // CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
+ // CURLOPT_COOKIEFILE => $filepath . 'cookie.txt', // set cookie file to given file
+ // CURLOPT_COOKIEJAR => $filepath . 'cookie.txt' // set same file as cookie jar
+ // );
+
+/**
+ * Options for logout
+ */
+ // $defaults = array(
+ // CURLOPT_URL => $url . '/user/logout',
+ // CURLOPT_CUSTOMREQUEST => "GET",
+ // CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
+ // CURLOPT_COOKIEFILE => $filepath . 'cookie.txt', // set cookie file to given file
+ // CURLOPT_COOKIEJAR => $filepath . 'cookie.txt' // set same file as cookie jar
+ // );
+
+ // session_write_close();
+
+ $ch = curl_init();
+ curl_setopt_array($ch, ($defaults));
+ curl_exec($ch);
+ if(curl_error($ch)) {
+ print(curl_error($ch));
+ }
+ curl_close($ch);
+
+ // session_start();
+
+?>
\ No newline at end of file
diff --git a/app/Config/database.php b/app/Config/database.php
index 53a83a0..9a76c8b 100644
--- a/app/Config/database.php
+++ b/app/Config/database.php
@@ -1,20 +1,47 @@
conn = null;
+namespace App\Config;
+
+use ppb\Library\Msg;
+
+abstract class Database {
+
+ /**
+ * Zugangsdaten für die Datenbank
+ */
+ private $dbName = "vpr_pbat3h23a"; //Datenbankname
+ private $linkName = "mysql.pb.bib.de"; //Datenbank-Server
+ private $user = "vpr_pbat3h23a"; //Benutzername
+ private $pw = "SBHwIWNqmMevnlqt"; //Passwort
+
+ /**
+ * Stellt eine Verbindung zur Datenbank her
+ *
+ * @return \PDO Gibt eine Datenbankverbindung zurueck
+ */
+ public function linkDB() {
try {
- $this->conn = new PDO("mysql:host={$this->host};dbname={$this->db_name}",
- $this->username, $this->password);
- $this->conn->exec("set names utf8");
- } catch (PDOException $exception) {
- echo "Connection error: " . $exception->getMessage();
+ $pdo = new \PDO("mysql:dbname=$this->dbName;host=$this->linkName"
+ , $this->user
+ , $this->pw
+ , [\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION]);
+ return $pdo;
+ } catch (\PDOException $e) {
+ new Msg(true, null, $e);
+ throw $e;
}
- return $this->conn;
}
-}
+
+ /**
+ * Zum serverseitigen generieren einer UUID
+ *
+ * @return string Liefert eine UUID
+ */
+ public function createUUID()
+ {
+ $data = openssl_random_pseudo_bytes(16);
+ $data[6] = chr(ord($data[6]) & 0x0f | 0x40);
+ $data[8] = chr(ord($data[8]) & 0x3f | 0x80);
+ return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
+ }
+}
\ No newline at end of file
diff --git a/app/Controller/ExampleController.php b/app/Controller/ExampleController.php
new file mode 100644
index 0000000..3be9149
--- /dev/null
+++ b/app/Controller/ExampleController.php
@@ -0,0 +1,65 @@
+model = new ExampleModel();
+ }
+
+ /**
+ * Write a new record to the database
+ *
+ * @param array $data
+ * @return void
+ */
+ public function writeRecord(array $data): void
+ {
+ try {
+ $this->model->insertRecord($data);
+ } catch (Exception $e) {
+ // Log the error or handle it as needed
+ error_log("Error writing record: " . $e->getMessage());
+ throw new Exception("Failed to write record.");
+ }
+ }
+
+ /**
+ * Get all records from the database
+ *
+ * @return array
+ */
+ public function getAllRecords(): array
+ {
+ try {
+ return $this->model->fetchAllRecords();
+ } catch (Exception $e) {
+ // Log the error or handle it as needed
+ error_log("Error fetching records: " . $e->getMessage());
+ return [];
+ }
+ }
+
+ /**
+ * Delete a record by ID
+ *
+ * @param int $id
+ * @return void
+ */
+ public function deleteRecord(int $id): void
+ {
+ try {
+ $this->model->removeRecord($id);
+ } catch (Exception $e) {
+ // Log the error or handle it as needed
+ error_log("Error deleting record: " . $e->getMessage());
+ throw new Exception("Failed to delete record.");
+ }
+ }
+}
diff --git a/app/Controller/ProjectController.php b/app/Controller/ProjectController.php
new file mode 100644
index 0000000..b8572df
--- /dev/null
+++ b/app/Controller/ProjectController.php
@@ -0,0 +1,47 @@
+";
+ $model = new ProjectModel();
+ $data = $model->readProject();
+
+ echo "
";
+
+
+ // Display the data in a table format
+ echo '';
+ // Table header
+ echo '';
+ foreach (array_keys($data[0]) as $header) {
+ echo '' . htmlspecialchars($header) . ' | ';
+ }
+ echo '
';
+ // Table rows
+ foreach ($data as $row) {
+ echo '';
+ foreach ($row as $cell) {
+ echo '' . htmlspecialchars($cell) . ' | ';
+ }
+ echo '
';
+ }
+ echo '
';
+ }
+}
diff --git a/app/Controllers/ProjectController.php b/app/Controllers/ProjectController.php
deleted file mode 100644
index c03f07e..0000000
--- a/app/Controllers/ProjectController.php
+++ /dev/null
@@ -1,14 +0,0 @@
-project = new Project($db);
- }
-
- public function getAllProjects() {
- return $this->project->fetchAll();
- }
-}
diff --git a/app/Model/ExampleModel.php b/app/Model/ExampleModel.php
new file mode 100644
index 0000000..d1e6ba6
--- /dev/null
+++ b/app/Model/ExampleModel.php
@@ -0,0 +1,55 @@
+records = [
+ ['id' => 1, 'name' => 'Example 1', 'value' => 100],
+ ['id' => 2, 'name' => 'Example 2', 'value' => 200],
+ ['id' => 3, 'name' => 'Example 3', 'value' => 300],
+ ];
+ }
+
+ /**
+ * Insert a new record into the example data
+ *
+ * @param array $data
+ * @return void
+ */
+ public function insertRecord(array $data): void
+ {
+ $this->records[] = [
+ 'id' => count($this->records) + 1,
+ 'name' => $data['name'] ?? 'Unnamed',
+ 'value' => $data['value'] ?? 0,
+ ];
+ }
+
+ /**
+ * Fetch all records from the example data
+ *
+ * @return array
+ */
+ public function fetchAllRecords(): array
+ {
+ return $this->records;
+ }
+
+ /**
+ * Remove a record by ID from the example data
+ *
+ * @param int $id
+ * @return void
+ */
+ public function removeRecord(int $id): void
+ {
+ $this->records = array_filter($this->records, function ($record) use ($id) {
+ return $record['id'] !== $id;
+ });
+ }
+}
diff --git a/app/Model/ProjectModel.php b/app/Model/ProjectModel.php
new file mode 100644
index 0000000..10fa40f
--- /dev/null
+++ b/app/Model/ProjectModel.php
@@ -0,0 +1,30 @@
+linkDB();
+ $sql = "SELECT id, name FROM project";
+
+ try {
+ $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
+ } catch (\PDOException $e) {
+ new Msg(true, null, $e);
+ }
+
+ $sth = $pdo->prepare($sql);
+ $sth->execute();
+
+ $result = $sth->fetchAll(\PDO::FETCH_ASSOC);
+ $sth->closeCursor();
+ $pdo = null;
+ // fetch all
+ return $result;
+
+ }
+}
\ No newline at end of file
diff --git a/app/Models/Project.php b/app/Models/Project.php
deleted file mode 100644
index 7c156ad..0000000
--- a/app/Models/Project.php
+++ /dev/null
@@ -1,16 +0,0 @@
-conn = $db;
- }
-
- public function fetchAll() {
- $query = "SELECT * FROM " . $this->table;
- $stmt = $this->conn->prepare($query);
- $stmt->execute();
- return $stmt->fetchAll(PDO::FETCH_ASSOC);
- }
-}
diff --git a/index.php b/index.php
index 84b8e56..e69de29 100644
--- a/index.php
+++ b/index.php
@@ -1,5 +0,0 @@
-getConnection();
-$controller = new ProjectController($db);
-
-header("Content-Type: application/json");
-echo json_encode($controller->getAllProjects());
diff --git a/sql/.gitkeep b/sql/.gitkeep
deleted file mode 100644
index e69de29..0000000