Add API for mail list
This commit is contained in:
35
api/opfer/list.php
Normal file
35
api/opfer/list.php
Normal 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));
|
||||
?>
|
||||
Reference in New Issue
Block a user