From 5279b0d34d45ad41c3e0ebc8cc80a3f3bd1eb2e8 Mon Sep 17 00:00:00 2001 From: Lars Gebhardt-Kusche Date: Mon, 17 Nov 2025 23:50:23 +0100 Subject: [PATCH] up --- config/testfile.txt | 1 - public/api/_db.php | 16 ++ public/api/materials.php | 6 + public/api/printer-materials.php | 35 ++++ public/api/printers.php | 6 + public/index.html | 266 +++++++++++++++++++++++++++++++ src/config.php | 10 ++ 7 files changed, 339 insertions(+), 1 deletion(-) delete mode 100644 config/testfile.txt create mode 100755 public/api/_db.php create mode 100755 public/api/materials.php create mode 100755 public/api/printer-materials.php create mode 100755 public/api/printers.php create mode 100755 public/index.html create mode 100755 src/config.php diff --git a/config/testfile.txt b/config/testfile.txt deleted file mode 100644 index 89fe089..0000000 --- a/config/testfile.txt +++ /dev/null @@ -1 +0,0 @@ -sfsfdsdf \ No newline at end of file diff --git a/public/api/_db.php b/public/api/_db.php new file mode 100755 index 0000000..943fc92 --- /dev/null +++ b/public/api/_db.php @@ -0,0 +1,16 @@ + PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, +]; +try { + $pdo = new PDO($dsn, $cfg['db_user'], $cfg['db_pass'], $options); +} catch (PDOException $e) { + http_response_code(500); + header('Content-Type: application/json'); + echo json_encode(['error' => 'DB connection failed']); + exit; +} diff --git a/public/api/materials.php b/public/api/materials.php new file mode 100755 index 0000000..3b743ed --- /dev/null +++ b/public/api/materials.php @@ -0,0 +1,6 @@ +query("SELECT * FROM materials WHERE is_active = 1 ORDER BY code"); +echo json_encode($stmt->fetchAll(), JSON_UNESCAPED_UNICODE); diff --git a/public/api/printer-materials.php b/public/api/printer-materials.php new file mode 100755 index 0000000..29ccf7f --- /dev/null +++ b/public/api/printer-materials.php @@ -0,0 +1,35 @@ + 'printer id missing']); + exit; +} + +$printerStmt = $pdo->prepare("SELECT * FROM printers WHERE id = ?"); +$printerStmt->execute([$printer_id]); +$printer = $printerStmt->fetch(); +if (!$printer) { + http_response_code(404); + echo json_encode(['error' => 'printer not found']); + exit; +} + +$sql = "SELECT m.*, pms.support_level, pms.partial_reason, pms.extra_info + FROM materials m + LEFT JOIN printer_material_support pms + ON pms.material_id = m.id AND pms.printer_id = :pid + WHERE m.is_active = 1 + ORDER BY m.code"; +$stmt = $pdo->prepare($sql); +$stmt->execute([':pid' => $printer_id]); +$materials = $stmt->fetchAll(); + +echo json_encode([ + 'printer' => $printer, + 'materials' => $materials +], JSON_UNESCAPED_UNICODE); diff --git a/public/api/printers.php b/public/api/printers.php new file mode 100755 index 0000000..c560186 --- /dev/null +++ b/public/api/printers.php @@ -0,0 +1,6 @@ +query("SELECT * FROM printers WHERE is_active = 1 ORDER BY name"); +echo json_encode($stmt->fetchAll(), JSON_UNESCAPED_UNICODE); diff --git a/public/index.html b/public/index.html new file mode 100755 index 0000000..9c9fe7a --- /dev/null +++ b/public/index.html @@ -0,0 +1,266 @@ + + + + + 3D-Druck Materialmatrix + + + + + +
+
+
+

3D-Druck Materialmatrix

+

Schnell prüfen, welche Filamente auf welchen Druckern laufen.

+
+ +
+ +
+ + + + +
+
+ + + + + + + + + + + + + + + +
MaterialEigenschaftenTg °CDüsePlatteZusatzAnwendungKinderEmission
+
+ + + + +
+

+ Hinweis: Dieses Projekt wird privat betrieben und befindet sich im Aufbau. + Es sind noch nicht alle Drucker und Materialien eingetragen. + Alle Angaben erfolgen nach bestem Wissen, jedoch ohne Gewähr auf Vollständigkeit oder Richtigkeit. +

+
+
+
+
+ + + + + diff --git a/src/config.php b/src/config.php new file mode 100755 index 0000000..7458b08 --- /dev/null +++ b/src/config.php @@ -0,0 +1,10 @@ + 'localhost', + 'db_name' => 'd0453540', + 'db_user' => 'd0453540', + 'db_pass' => 'P6jGRrSaX8QSiBMEJBL7', + 'db_charset' => 'utf8mb4', +];