]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | ||
3 | define('NO_EVENT_STREAM_HEADER',1); | |
4 | require_once('common_api.php'); | |
5 | ||
6 | if (!$rpc) | |
7 | die(json_encode([])); | |
8 | ||
9 | /* Get the user list */ | |
10 | $users = $rpc->user()->getAll(); | |
11 | ||
12 | $out = []; | |
13 | foreach($users as $user) | |
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>'; | |
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>' : ""; | |
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[] = [ | |
38 | "Select" => "<input type=\"checkbox\" value='" . base64_encode($user->id)."' name=\"userch[]\">", /* yeah ridiculous to have here in this file and the feed ;) */ | |
39 | "Nick" => $nick, | |
40 | "Country" => $country, | |
41 | "Host/IP" => $hostip, | |
42 | "Account" => $account, | |
43 | "Oper" => $oper, | |
44 | "Connected to" => $servername, | |
45 | "Reputation" => $reputation, | |
46 | ]; | |
47 | } | |
48 | ||
49 | function custom_sort($a,$b) | |
50 | { | |
51 | return strcmp(strtoupper($a["Nick"]), strtoupper($b["Nick"])); | |
52 | } | |
53 | ||
54 | usort($out, "custom_sort"); | |
55 | ||
56 | echo json_encode($out); |