]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blame - api/server-bans.php
Add Plugins: remove author from card footer
[irc/unrealircd/unrealircd-webpanel.git] / api / server-bans.php
CommitLineData
63026197 1<?php
63026197
BM
2define('NO_EVENT_STREAM_HEADER',1);
3require_once('common_api.php');
4header("Content-type: application/json; charset=utf-8");
cefec45f
BM
5
6if (!$rpc)
7 die(json_encode([]));
8
9
63026197
BM
10$tkls = $rpc->serverban()->getAll();
11
12$out = [];
13foreach($tkls as $tkl)
14{
15 $set_in_config = ((isset($tkl->set_in_config) && $tkl->set_in_config) || ($tkl->set_by == "-config-")) ? true : false;
2421056f 16 $set_by = $set_in_config ? "<span class=\"badge rounded-pill badge-secondary\">Config</span>" : show_nick_only(htmlspecialchars($tkl->set_by));
63026197
BM
17 $select = '';
18 if (!$set_in_config)
19 $select = "<input type=\"checkbox\" value='" . base64_encode($tkl->name).",".base64_encode($tkl->type) . "' name=\"tklch[]\">";
2421056f 20
63026197
BM
21 $out[] = [
22 "Select" => $select,
2421056f 23 "Mask" => htmlspecialchars($tkl->name),
63026197
BM
24 "Type" => $tkl->type_string,
25 "Duration" => $tkl->duration_string,
2421056f 26 "Reason" => htmlspecialchars($tkl->reason),
63026197
BM
27 "Set By" => $set_by,
28 "Set On" => $tkl->set_at_string,
29 "Expires" => $tkl->expire_at_string,
30 ];
31}
32
33function custom_sort($a,$b)
34{
35 return strcmp(strtoupper($a["Mask"]), strtoupper($b["Mask"]));
36}
37
38usort($out, "custom_sort");
39
40echo json_encode($out);