]>
Commit | Line | Data |
---|---|---|
bf719cce BM |
1 | <?php |
2 | ||
3 | define('NO_EVENT_STREAM_HEADER',1); | |
4 | require_once('common_api.php'); | |
bf719cce BM |
5 | |
6 | if (!$rpc) | |
7 | die(json_encode([])); | |
8 | ||
9 | /* Get the list */ | |
10 | $channels = $rpc->channel()->getAll(); | |
11 | ||
12 | $columns = array_column($channels, 'num_users'); | |
13 | array_multisort($columns, SORT_DESC, $channels); | |
14 | ||
15 | $out = []; | |
16 | foreach($channels as $channel) | |
17 | { | |
18 | $modes = (isset($channel->modes)) ? "+" . explode(" ",$channel->modes)[0] : "<none>"; | |
19 | $topic = ''; | |
20 | if (isset($channel->topic)) | |
064843a8 | 21 | $topic = htmlentities(StripControlCharacters($channel->topic), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 | ENT_DISALLOWED); |
bf719cce BM |
22 | $date = explode("T", $channel->creation_time)[0]; |
23 | $out[] = [ | |
24 | "Name" => htmlspecialchars($channel->name), | |
25 | "Users" => $channel->num_users, | |
26 | "Modes" => "<span data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"+".htmlspecialchars($channel->modes)."\">$modes</span>", | |
27 | "Topic" => $topic, | |
28 | "Created" => "<span data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"".$channel->creation_time."\">$date</span>", | |
29 | ]; | |
30 | } | |
31 | ||
32 | function custom_sort($a,$b) | |
33 | { | |
eb7d3d96 | 34 | return $b["Users"] <=> $a["Users"]; |
bf719cce BM |
35 | } |
36 | ||
37 | usort($out, "custom_sort"); | |
38 | ||
39 | echo json_encode($out); |