]>
jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - api/channels.php
3 define('NO_EVENT_STREAM_HEADER',1);
4 require_once('common_api.php');
5 header("Content-type: application/json; charset=utf-8");
11 $channels = $rpc->channel()->getAll();
13 $columns = array_column($channels, 'num_users');
14 array_multisort($columns, SORT_DESC
, $channels);
17 foreach($channels as $channel)
19 $modes = (isset($channel->modes
)) ? "+" . explode(" ",$channel->modes
)[0] : "<none>";
21 if (isset($channel->topic
))
22 $topic = htmlentities(StripControlCharacters($channel->topic
), ENT_QUOTES
| ENT_SUBSTITUTE
| ENT_HTML401
| ENT_DISALLOWED
);
23 $date = explode("T", $channel->creation_time
)[0];
25 "Name" => htmlspecialchars($channel->name
),
26 "Users" => $channel->num_users
,
27 "Modes" => "<span data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"+".htmlspecialchars($channel->modes
)."\">$modes</span>",
29 "Created" => "<span data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"".$channel->creation_time
."\">$date</span>",
33 function custom_sort($a,$b)
35 return $b["Users"] <=> $a["Users"];
38 usort($out, "custom_sort");
40 echo json_encode($out);