diff --git a/api/login/getcookies.php b/api/login/getcookies.php index 6907ad1..1e8c180 100644 --- a/api/login/getcookies.php +++ b/api/login/getcookies.php @@ -39,7 +39,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { setcookie("device_id", $device_id, time() + 3600, "/"); setcookie("username", $user, time() + 3600, "/"); - header("Location: /opfer.html"); + header("Location: /index.html"); exit; }else{ diff --git a/api/opfer/add.php b/api/opfer/add.php index 2b1735e..ea7a6ce 100644 --- a/api/opfer/add.php +++ b/api/opfer/add.php @@ -1,4 +1,38 @@ checkAuth()) { + header("Location: /index.html?status=500&error=Unauthorized"); + exit; +} + +if (!isset($_POST["name"]) || !isset($_POST["mail"]) || !isset($_POST["number"])) { + die('{"status":500, "error":"Missing fields"}'); +} + +$name = htmlspecialchars($_POST["name"]); +$mail = htmlspecialchars($_POST["mail"]); +$number = intval(htmlspecialchars($_POST["number"])); +if (isset($_POST["enabled"])) { + $enabled = 1; +}else{ + $enabled = 0; +} + +$db = $api->getDB(); + +$sql = "INSERT INTO opfer (name, mail, number, status) VALUES (:name, :mail, :number, :status)"; + +$stmt = $db->prepare($sql); + +$sql_exec = $stmt->execute([':name' => $name, ':mail' => $mail, ':number' => $number, ':status' => $enabled]); + +if ($sql_exec) { + header("Location: /index.html?status=200"); +}else{ + header("Location: /index.html?status=500&error=SQL Error"); +} +exit; +?> \ No newline at end of file diff --git a/api/opfer/info.php b/api/opfer/info.php new file mode 100644 index 0000000..6cfade3 --- /dev/null +++ b/api/opfer/info.php @@ -0,0 +1,33 @@ +checkAuth()) { + die('{"status":500, "error":"Unauthorized"}'); +} + +if (!isset($_POST["id"])) { + die('{"status":500, "error":"Missing parameter"}'); +} + +$id = intval($_POST["id"]); + +$db = $api->getDB(); + +$sql = "SELECT * FROM opfer WHERE id = :id"; +$stmt = $db->prepare($sql); +$stmt->execute([':id' => $id]); + +$result = $stmt->fetchAll(PDO::FETCH_ASSOC); + +if ($result) { + $json["opfer"] = $result; + $json["status"] = 200; +}else{ + $json["status"] = 500; + $json["error"] = "Empty SQL Result"; +} + +die(json_encode($json)); +?> \ No newline at end of file diff --git a/api/opfer/list.php b/api/opfer/list.php index 293459b..c2b9b1b 100644 --- a/api/opfer/list.php +++ b/api/opfer/list.php @@ -17,6 +17,7 @@ $all_opfer = []; if ($result) { foreach ($result as $opfer_res) { + $opfer["id"] = $opfer_res["id"]; $opfer["name"] = $opfer_res["name"]; $opfer["mail"] = $opfer_res["mail"]; $opfer["number"] = $opfer_res["number"]; diff --git a/front/background.png b/front/background.png new file mode 100644 index 0000000..e394edb Binary files /dev/null and b/front/background.png differ diff --git a/front/basic-tables.html b/front/basic-tables.html index 9033fd3..90b20af 100644 --- a/front/basic-tables.html +++ b/front/basic-tables.html @@ -691,6 +691,7 @@
` + opfer.name + ` diff --git a/front/index.html b/front/index.html index 6c90cae..20a349d 100644 --- a/front/index.html +++ b/front/index.html @@ -10,9 +10,18 @@ Alle Opfer | Spamhasi + Add - +
+
+
+
+
+ + + +
+ +
+

+ Erfolgreich! +

+ +

+ Das neue Opfer wurde erfolgreich hinzugefügt! +

+
+
+
+
+
+
+ + + +
+ +
+

+ Ups... +

+ +

+ Es ist ein Fehler aufgetreten +

+
+
+
+
@@ -698,6 +777,7 @@
` + opfer.name + ` @@ -797,6 +877,7 @@ Name - Close + Später
- +
+ +
+ + +
+

+ Ein Opfer bearbeiten +

+

+ Bearbeite ein Opfer! +

+
+
+
+
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+
+
+
+ + +
+
+
+
+ + diff --git a/front/login.css b/front/login.css index 9ef1b2f..eb83a8d 100644 --- a/front/login.css +++ b/front/login.css @@ -4,7 +4,9 @@ body { place-items: center; height: 100vh; overflow: hidden; - background-image: url("/css/background.png"); + background-image: url("/background.png"); + background-repeat: no-repeat; + background-size: cover; } .page-content { diff --git a/front/opfer.html b/front/opfer.html index e46965d..29cc36b 100644 --- a/front/opfer.html +++ b/front/opfer.html @@ -691,6 +691,7 @@
` + opfer.name + ` diff --git a/front/profile.html b/front/profile.html index 9c45def..b0e5028 100644 --- a/front/profile.html +++ b/front/profile.html @@ -999,6 +999,7 @@ Name - Close + Später - +
+
+
+
+
+ + + +
+ +
+

+ Erfolgreich! +

+ +

+ Das neue Opfer wurde erfolgreich hinzugefügt! +

+
+
+
+
+
+
+ + + +
+ +
+

+ Ups... +

+ +

+ Es ist ein Fehler aufgetreten +

+
+
+
+
@@ -89,5 +168,17 @@
+ + diff --git a/tailadmin/src/partials/profile/opfer_add.html b/tailadmin/src/partials/profile/opfer_add.html index e271fac..7d2fb1d 100644 --- a/tailadmin/src/partials/profile/opfer_add.html +++ b/tailadmin/src/partials/profile/opfer_add.html @@ -49,6 +49,7 @@ Name + +
+ + +
+

+ Ein Opfer bearbeiten +

+

+ Bearbeite ein Opfer! +

+
+
+
+
+
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+
+
+
+ + +
+
+
+
diff --git a/tailadmin/src/partials/table/table-06.html b/tailadmin/src/partials/table/table-06.html index 8656ce6..a008e20 100644 --- a/tailadmin/src/partials/table/table-06.html +++ b/tailadmin/src/partials/table/table-06.html @@ -77,6 +77,8 @@
` + opfer.name + ` @@ -112,5 +114,27 @@ document.getElementById("opfer_table").innerHTML = list; }) .catch(error => console.error("API Error: " + error)) + + function opferEdit(id) { + fetch("/api/opfer/info.php", { + method: "POST", + headers: { + "Content-Type": "multipart/form-data" + }, + body: JSON.stringify({ + id: id + }) + }) + .then(respone => respone.json()) + .then(data => { + if (data.status == 500) { + console.error("API Error: " + data.error); + } + + document.getElementById("opfer_name").innerHTML = data.name; + document.getElementById("opfer_mail").innerHTML = data.mail; + document.getElementById("opfer_name").innerHTML = data.number; + }) + }
diff --git a/tmp/user_sessions/marc.json b/tmp/user_sessions/marc.json index b14e9b3..617ace5 100755 --- a/tmp/user_sessions/marc.json +++ b/tmp/user_sessions/marc.json @@ -1 +1 @@ -{"461":{"session_id":"3fb1a882e8c2983eb5981559fc72133652ac1b9c9a3be80e31a7066ae1aa60ed"}} \ No newline at end of file +{"270":{"session_id":"896d8b84fd9ae2471bc70a2023f55db83a8e88244bfb92f0c06e7a05c8d03599"}} \ No newline at end of file