Add API for mail list

This commit is contained in:
marc-go
2026-04-13 13:45:53 +02:00
parent eb6fb23489
commit 8bfa783d9d
4 changed files with 138 additions and 0 deletions

35
api/opfer/list.php Normal file
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));
?>