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