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