Add API for mail list

This commit is contained in:
marc-go committed 2026-04-13 13:45:53 +02:00
1 parent eb6fb23489
commit 8bfa783d9d
4 files changed
+138

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
<?php
require "../api.php";
$api = new spamhasiApi;
if (!$api->checkAuth()) {
die('{"status":500, "error":"Unauthorized"}');
}
$db = $api->getDB();
$sql = "SELECT * FROM opfer";
$stmt = $db->query($sql);
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$all_opfer = [];
if ($result) {
foreach ($result as $opfer_res) {
$opfer["name"] = $opfer_res["name"];
$opfer["mail"] = $opfer_res["mail"];
$opfer["number"] = $opfer_res["number"];
$all_opfer[] = $opfer;
}
$json["servers"] = $all_opfer;
}else{
$json["servers"] = [];
}
$json["status"] = 200;
die(json_encode($json));
?>