]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - misc/user-lookup-misc.php
Include ASN info in user details
[irc/unrealircd/unrealircd-webpanel.git] / misc / user-lookup-misc.php
1 <?php
2
3 function generate_html_whois($user)
4 {
5 global $rpc;
6
7 $notes = Notes::find(["nick" => $user->name, "ip" => $user->ip, "account" => $user->account ?? NULL]);
8 $numnotes = [
9 "ip" => isset($notes['ip']['notes']) ? count($notes["ip"]['notes']) : 0,
10 "nick" => isset($notes['ip']['notes']) ? count($notes["nick"]['notes'] ?? []) : 0,
11 "account" => isset($notes['ip']['notes']) ? count($notes['account']['notes'] ?? []) : 0,
12 ];
13 $cc = (isset($user->geoip->country_code)) ? strtolower($user->geoip->country_code) : "";
14
15 $asn = $user->geoip->asn ?? "none";
16 $asname = $user->geoip->asname ?? "none";
17 Message::Fail(var_export($user->geoip, true));
18
19 ?>
20
21 <table class="table-sm table-responsive caption-top table-hover">
22 <span class="badge rounded-pill"
23 style="position: absolute;
24 top:25px;
25 right: 25px;
26 background-color:lightgrey;
27 font-size:small;"
28 >Reputation <span class="badge badge-danger" style="font-size:small;"><?php echo $user->user->reputation; ?></span>
29 </span>
30 <tbody>
31 <tr>
32 <th>Nick</th>
33 <td colspan="2"><code><?php echo htmlspecialchars($user->name); ?></code></td>
34 <td colspan="2"><button id="nicknotes" class="btn btn-sm btn-secondary fa-solid fa-sticky-note text-nowrap"> <?php echo $numnotes['nick']?></div></button></td>
35 </tr><tr>
36 <th>User ID (UID)</th>
37 <td colspan="2"><code><?php echo htmlspecialchars($user->id); ?></code></td>
38 </tr><tr>
39 <th>Real Host</th>
40 <td colspan="2"><code><?php echo htmlspecialchars($user->hostname); ?></code></td>
41 </tr><tr>
42 <th>IP</th>
43 <td colspan="2">
44 <code><?php echo htmlspecialchars($user->ip); ?></code>
45 <?php
46 if (strlen($cc))
47 {
48 ?> <img src="https://flagcdn.com/48x36/<?php echo htmlspecialchars($cc); ?>.png"
49 width="20"
50 height="15">
51 <?php } ?>
52 <a href="<?php echo htmlspecialchars(get_config("base_url")."tools/ip-whois.php?ip=$user->ip"); ?>"><button class="btn-sm btn-primary">WHOIS IP</button></a>
53 </td>
54 <td><button id="ipnotes" class="btn btn-sm btn-secondary fa-solid fa-sticky-note text-nowrap"> <?php echo $numnotes['ip']?></button></td>
55 </tr><tr>
56 <th>ASN</th>
57 <td colspan="2"><code><?php echo "$asname ($asn)"; ?></code></td>
58 </tr><tr>
59 <th>Ident</th>
60 <td colspan="2"><code><?php echo htmlspecialchars($user->user->username); ?></code></td>
61 </tr><tr>
62 <th>GECOS / Real Name</th>
63 <td colspan="2"><code><?php echo htmlspecialchars($user->user->realname); ?></code></td>
64 </tr><tr>
65 <th>Virtual Host</th>
66 <td colspan="2"><code><?php echo (isset($user->user->vhost)) ? htmlspecialchars($user->user->vhost) : ""; ?></code></td>
67 </tr><tr>
68 <th>Connected to</th>
69 <?php $serverlkup = $rpc->server()->get($user->user->servername); ?>
70
71 <td colspan="2"><a href="<?php echo get_config("base_url")."servers/details.php?server=$serverlkup->id"; ?>"><code><?php echo htmlspecialchars($user->user->servername); ?></code></td>
72
73 </tr>
74 <tr>
75 <th>Logged in as</th>
76 <td colspan="2"><code><?php echo (isset($user->user->account)) ? "<a href=\"".get_config("base_url")."users/?account=".htmlspecialchars($user->user->account)."\">".htmlspecialchars($user->user->account)."</a>" : ""; ?></code></td>
77 <td><button id="account_notes" class="btn btn-sm btn-secondary fa-solid fa-sticky-note text-nowrap"> <?php echo $numnotes['account']?></button></td>
78 </tr>
79 <tr>
80 <th style="background-color: blanchedalmond;border-radius:5px";>Security Groups</th>
81 <td colspan="2"><code><?php
82 echo "<table style=\"margin-left:-15px;
83 height:100%;
84 border-radius:5px;
85 background-color: blanchedalmond\"><tr>";
86 foreach($user->user->{"security-groups"} as $sg)
87 {
88 echo "<th><div class=\"badge badge-secondary rounded-pill\">$sg</th></tr><tr>";
89 }
90 echo "</tr></table>"; ?>
91 </td>
92 </code>
93 </td>
94 </tr>
95
96 </tbody>
97 </table>
98
99 <?php
100 }
101 function generate_html_usersettings($user)
102 {
103 ?>
104
105 <table class="table-sm table-responsive caption-top table-hover">
106 <tbody>
107 <?php
108 for ($i=0; ($mode = (isset($user->user->modes[$i])) ? $user->user->modes[$i] : NULL); $i++)
109 {
110
111 if ($mode == "o")
112 {
113 ?>
114 <tr>
115 <th>Oper</th>
116 <td>
117 <table class="table-sm table-responsive caption-top table-hover">
118 <tr>
119 <td>Oper Login</td>
120 <td><code><?php
121 $operlogin = (isset($user->user->operlogin)) ? $user->user->operlogin : "";
122 echo htmlspecialchars($operlogin);
123 ?></code></td>
124 </tr>
125 <tr>
126 <td>Oper Class</td>
127 <td><?php echo (isset($user->user->operclass)) ? "<span class=\"rounded-pill badge badge-info\">".htmlspecialchars($user->user->operclass)."</span>" : "<span class=\"rounded-pill badge badge-info\">None</span>"; ?></td>
128 </tr>
129 </table>
130 </td>
131 </tr>
132 <?php
133 }
134 elseif ($mode == "S")
135 {
136 ?>
137 <tr>
138 <th>Service Bot</th>
139 <td>
140 This user is a Services Bot.
141 </td>
142 </tr>
143 <?php
144 }
145 elseif ($mode == "d")
146 {
147 ?>
148 <tr>
149 <th>Deaf</th>
150 <td>User is ignoring channel messages.</td>
151 </tr>
152 <?php
153 }
154 elseif ($mode == "i")
155 {
156 ?>
157 <tr>
158 <th>Invisible</th>
159 <td>Not shown in /WHO searches.</td>
160 </tr>
161 <?php
162 }
163 elseif ($mode == "p")
164 {
165 ?>
166 <tr>
167 <th>Private channels</th>
168 <td>Channels hidden in /WHOIS outputs.</td>
169 </tr>
170 <?php
171 }
172 elseif ($mode == "r")
173 {
174 ?>
175 <tr>
176 <th>Registered Nick</th>
177 <td>This user is using a registered nick.</td>
178 </tr>
179 <?php
180 }
181 elseif ($mode == "s")
182 {
183 ?>
184 <tr>
185 <th>Server Notices</th>
186 <td>This user is receiving server notices.</td>
187 </tr>
188 <?php
189 }
190 elseif ($mode == "t")
191 {
192 ?>
193 <tr>
194 <th>Virtual Host</th>
195 <td>Using a custom hostmask</td>
196 </tr>
197 <?php
198 }
199 elseif ($mode == "w")
200 {
201 ?>
202 <tr>
203 <th>Wallops</th>
204 <td>Listening to <code>/WALLOPS</code> notices from IRC Operators.</td>
205 </tr>
206 <?php
207 }
208 elseif ($mode == "x")
209 {
210 ?>
211 <tr>
212 <th>Hostmask</th>
213 <td>Using a hostmask (hiding their IP from non-IRCops).</td>
214 </tr>
215 <?php
216 }
217 elseif ($mode == "z")
218 {
219 ?>
220 <tr>
221 <th>Secure</th>
222 <td>
223 <table class="table-sm table-responsive caption-top table-hover">
224 <tr>
225 <td>Cipher</td>
226 <td><code><?php
227 $cipher = (isset($user->tls->cipher)) ? $user->tls->cipher : "";
228 echo htmlspecialchars($cipher);
229 ?></code></td>
230 </tr>
231 <tr>
232 <td>Cert Fingerprint</td>
233 <td><?php echo (isset($user->tls->certfp)) ? "<code>".htmlspecialchars($user->tls->certfp)."</code>" : "<span class=\"rounded-pill badge badge-info\">None</span>"; ?></td>
234 </tr>
235 </table>
236 </td>
237 </tr>
238 <?php
239 }
240 elseif ($mode == "B")
241 {
242 ?>
243 <tr>
244 <th>Bot</th>
245 <td colspan="2">
246 User is marked as a Bot.
247 </td>
248 </tr>
249 <?php
250 }
251 elseif ($mode == "D")
252 {
253 ?>
254 <tr>
255 <th>PrivDeaf</th>
256 <td colspan="2">
257 User is rejecting incoming private messages.
258 </td>
259 </tr>
260 <?php
261 }
262 elseif ($mode == "G")
263 {
264 ?>
265 <tr>
266 <th>Filter</th>
267 <td colspan="2">
268 User is filtering Bad Words.
269 </td>
270 </tr>
271 <?php
272 }
273 elseif ($mode == "H")
274 {
275 ?>
276 <tr>
277 <th>Hide IRCop</th>
278 <td colspan="2">
279 User is hiding their IRCop status.
280 </td>
281 </tr>
282 <?php
283 }
284 elseif ($mode == "I")
285 {
286 ?>
287 <tr>
288 <th>Hide Idle</th>
289 <td colspan="2">
290 User is hiding their idle time.
291 </td>
292 </tr>
293 <?php
294 }
295 elseif ($mode == "R")
296 {
297 ?>
298 <tr>
299 <th>RegOnly Messages</th>
300 <td colspan="2">
301 User is only accepting private messages from registered users.
302 </td>
303 </tr>
304 <?php
305 }
306 elseif ($mode == "T")
307 {
308 ?>
309 <tr>
310 <th>Deny CTCPs</th>
311 <td colspan="2">
312 Denying CTCP requests.
313 </td>
314 </tr>
315 <?php
316 }
317 elseif ($mode == "W")
318 {
319 ?>
320 <tr>
321 <th>View /WHOIS</th>
322 <td colspan="2">
323 User is receiving notifications when someone does a <code>/WHOIS</code> on them.
324 </td>
325 </tr>
326 <?php
327 }
328 elseif ($mode == "Z")
329 {
330 ?>
331 <tr>
332 <th>Deny Insecure Messages</th>
333 <td colspan="2">
334 User is only accepting messages from users using a secure connection.
335 </td>
336 </tr>
337 <?php
338 }
339 }
340
341
342 ?>
343 </tbody>
344 </table>
345
346 <?php
347 }
348
349
350 function generate_html_userchannels($user)
351 {
352 ?>
353
354 <table class="table-sm table-responsive caption-top table-hover table-striped">
355 <thead class="table-info">
356 <th>
357 Channel
358 </th>
359 <th >
360 Status
361 </th>
362 </thead>
363 <tbody>
364 <?php
365 foreach($user->user->channels as $chan)
366 {
367 ?>
368 <tr>
369 <td><?php echo "<a href=\"".get_config("base_url")."channels/details.php?chan=".urlencode($chan->name)."\">$chan->name</a>"; ?></td>
370 <td>
371
372 <?php
373 for ($i = 0; isset($chan->level[$i]); $i++)
374 {
375 ?><div class="text-nowrap row mb-1"><?php
376 if ($chan->level[$i] == "v")
377 {
378 ?><span class="rounded-pill badge badge-info" value="Voice">Voice</span><?php
379 }
380 if ($chan->level[$i] == "h")
381 {
382 ?><span class="rounded-pill badge badge-info">Half-Op</span><?php
383 }
384 if ($chan->level[$i] == "o")
385 {
386 ?><h6><span class="rounded-pill badge badge-info">Operator</span></h6><?php
387 }
388 if ($chan->level[$i] == "a")
389 {
390 ?><span class="rounded-pill badge badge-info">Admin</span><?php
391 }
392 if ($chan->level[$i] == "q")
393 {
394 ?><span class="rounded-pill badge badge-info">Owner</span><?php
395 }
396 if ($chan->level[$i] == "Y")
397 {
398 ?><span class="rounded-pill badge badge-info">OJOIN</span><?php
399 }
400 ?></div><?php
401 }
402 ?>
403 </td>
404 </tr>
405 <?php
406 }
407 ?>
408 </tbody>
409 </table>
410
411 <?php
412 }