]>
Commit | Line | Data |
---|---|---|
cd5d0af0 VP |
1 | <?php |
2 | ||
5485abb5 BM |
3 | define('NO_EVENT_STREAM_HEADER',1); |
4 | require_once('common_api.php'); | |
cd5d0af0 | 5 | |
cefec45f BM |
6 | if (!$rpc) |
7 | die(json_encode([])); | |
8 | ||
5485abb5 BM |
9 | /* Get the user list */ |
10 | $users = $rpc->user()->getAll(); | |
cd5d0af0 | 11 | |
5485abb5 BM |
12 | $out = []; |
13 | foreach($users as $user) | |
cd5d0af0 | 14 | { |
5485abb5 BM |
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[] = [ | |
78142aba | 38 | "Select" => "<input type=\"checkbox\" value='" . base64_encode($user->id)."' name=\"userch[]\">", /* 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 | |
49 | function custom_sort($a,$b) | |
cd5d0af0 | 50 | { |
5485abb5 | 51 | return strcmp(strtoupper($a["Nick"]), strtoupper($b["Nick"])); |
cd5d0af0 VP |
52 | } |
53 | ||
5485abb5 BM |
54 | usort($out, "custom_sort"); |
55 | ||
56 | echo json_encode($out); |