]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blame - api/users.php
Users: get rid of "user modes" column. Similar to previous, at least for now.
[irc/unrealircd/unrealircd-webpanel.git] / api / users.php
CommitLineData
cd5d0af0
VP
1<?php
2
5485abb5
BM
3define('NO_EVENT_STREAM_HEADER',1);
4require_once('common_api.php');
5header("Content-type: application/json; charset=utf-8");
cd5d0af0 6
5485abb5
BM
7/* Get the user list */
8$users = $rpc->user()->getAll();
cd5d0af0 9
5485abb5
BM
10$out = [];
11foreach($users as $user)
cd5d0af0 12{
5485abb5
BM
13 // base64_encode($user->id)
14
15 $isBot = (strpos($user->user->modes, "B") !== false) ? ' <span class="badge rounded-pill badge-dark">Bot</span>' : "";
16 $nick = htmlspecialchars($user->name).$isBot;
17
18 $country = isset($user->geoip->country_code) ? '<img src="https://flagcdn.com/48x36/'.htmlspecialchars(strtolower($user->geoip->country_code)).'.png" width="20" height="15"> '.htmlspecialchars($user->geoip->country_code) : "";
19
20 if ($user->hostname == $user->ip)
21 $hostip = $user->ip;
22 else if ($user->ip == null)
23 $hostip = $user->hostname;
24 else
25 $hostip = $user->hostname . " (".$user->ip.")";
26 $hostip = htmlspecialchars($hostip);
27
28 $account = (isset($user->user->account)) ? "<a href=\"".get_config("base_url")."users/?account=".$user->user->account."\">".htmlspecialchars($user->user->account)."</a>" : '<span class="badge rounded-pill badge-primary">None</span>';
5485abb5
BM
29 $oper = (isset($user->user->operlogin)) ? $user->user->operlogin." <span class=\"badge rounded-pill badge-secondary\">".$user->user->operclass."</span>" : "";
30 if (!strlen($oper))
31 $oper = (strpos($user->user->modes, "S") !== false) ? '<span class="badge rounded-pill badge-warning">Services Bot</span>' : "";
5485abb5
BM
32 $servername = $user->user->servername;
33 $reputation = $user->user->reputation;
34
35 $nick = "<a href=\"details.php?nick=".$user->id."\">$nick</a>";
36
37 $out[] = [
8e3bf75e 38 "Select" => "<input type=\"checkbox\" label='selectall' onClick=\"toggle_user(this)\" />", /* yeah ridiculous to have here in this file and the feed ;) */
5485abb5
BM
39 "Nick" => $nick,
40 "Country" => $country,
41 "Host/IP" => $hostip,
42 "Account" => $account,
5485abb5 43 "Oper" => $oper,
5485abb5
BM
44 "Connected to" => $servername,
45 "Reputation" => $reputation,
46 ];
cd5d0af0 47}
5485abb5
BM
48
49function custom_sort($a,$b)
cd5d0af0 50{
5485abb5 51 return strcmp(strtoupper($a["Nick"]), strtoupper($b["Nick"]));
cd5d0af0
VP
52}
53
5485abb5
BM
54usort($out, "custom_sort");
55
56echo json_encode($out);