]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - misc/server-lookup-misc.php
Fix errors about servers linked when they don't tell us any usermodes
[irc/unrealircd/unrealircd-webpanel.git] / misc / server-lookup-misc.php
1 <?php
2
3
4 function generate_html_servermodes($server)
5 {
6 ?>
7 <table class="table-sm table-responsive caption-top table-hover">
8 <thead>
9 <th>Name</th>
10 <th>Mode</th>
11 <th>Description</th>
12 <th>Requires</th>
13 </thead>
14 <?php
15 if (isset($server->server->features->chanmodes))
16 {
17 foreach ($server->server->features->chanmodes as $set)
18 {
19 if (!$set)
20 break;
21 for ($i = 0; isset($set[$i]); $i++)
22 {
23 $mode = $set[$i];
24 if (isset(IRCList::$cmodes[$mode])) {
25 ?>
26 <tr>
27 <th><?php echo IRCList::$cmodes[$mode]['name']; ?></th>
28 <th><code><?php echo $mode; ?></code></th>
29 <td><?php echo IRCList::$cmodes[$mode]['description']; ?></td>
30 <td><div class="badge rounded-pill badge-dark"><?php echo IRCList::$cmodes[$mode]['requires']; ?></div></td>
31 </tr><?php
32 }
33 else {
34 ?>
35 <tr>
36 <th>Unknown</th>
37 <td>Mode "<?php echo $mode; ?>"</td>
38 <td></td>
39 </tr><?php
40 }
41 }
42 }
43 }
44 ?>
45 </table><?php
46 }
47
48 function sinfo_conv_version_string($server) : string
49 {
50 $string = (isset($server->server->features->software)) ? $server->server->features->software : "";
51 $return = "";
52 $tooltip = "";
53 $badge = "";
54 $display_string = $string;
55
56 if (strlen($string) && strpos($string,"-"))
57 {
58 $tok = split($string, "-");
59 if (($tok[0] == "UnrealIRCd") && isset($tok[2]))
60 {
61 if ($tok[2] == "git")
62 {
63 if (!empty($tok[3]))
64 $badge = "git:".$tok[3];
65 else
66 $badge = "git";
67 $tooltip = "Installed from GitHub";
68 $display_string = $tok[0]."-".$tok[1]."-".$tok[2];
69 } else if (substr($tok[2],0,2) == "rc")
70 {
71 $tooltip = "Release Candidate/Beta Version";
72 $badge = "rc";
73 } else if (strlen($tok[2]) == 9)
74 {
75 /* Guess that this is a commit id :D */
76 $badge = "git:".$tok[2];
77 $tooltip = "Installed from GitHub";
78 $display_string = $tok[0]."-".$tok[1];
79 }
80 $tooltip = htmlspecialchars($tooltip);
81 $display_string = htmlspecialchars($display_string);
82 }
83 $return = "<span data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"$tooltip\"><code>" . $display_string . "</code> <div class=\"badge rounded-pill badge-dark\">$badge</div></a>";
84 }
85 if (isset($server->server->ulined) && $server->server->ulined)
86 $return .= "<div class=\"badge rounded-pill badge-warning\">Services</div>";
87 return $return;
88 }
89
90 function generate_html_serverinfo($server)
91 {
92 global $rpc;
93 ?>
94 <table class="table-sm table-responsive caption-top table-hover">
95 <tbody>
96 <tr>
97 <th>Name</th>
98 <td colspan="2"><code><?php echo htmlspecialchars($server->name); ?></code></td>
99 </tr><tr>
100 <th>Server ID (SID)</th>
101 <td colspan="2"><code><?php echo htmlspecialchars($server->id); ?></code></td>
102 </tr><tr>
103 <th>Info</th>
104 <td colspan="2"><code><?php echo htmlspecialchars($server->server->info); ?></code></td>
105 </tr><tr>
106 <th>Uplink</th>
107 <?php $serverlkup = (isset($server->server->uplink)) ? $rpc->server()->get($server->server->uplink) : NULL; ?>
108 <td colspan="2"><code><?php echo ($serverlkup) ? "<a href=\"".get_config("base_url")."servers/details.php?server=".htmlspecialchars($serverlkup->id)."\">".htmlspecialchars($server->server->uplink)."</a>" : "No uplink"; ?></code></td>
109 </tr><tr>
110 <th>User count</th>
111 <td colspan="2"><code><?php echo htmlspecialchars($server->server->num_users); ?></code></td>
112 </tr><tr>
113 <th>Version</th>
114 <td colspan="2"><?php echo sinfo_conv_version_string($server); ?></td>
115 </tr>
116 </tbody>
117 </table>
118
119 <?php
120 }
121
122 function generate_html_usermodes($server)
123 {
124 $modes = $server->server->features->usermodes ?? NULL;
125 echo "<table class=\"table-sm table-responsive caption-top table-hover\">";
126 if (!$modes)
127 echo "<tr><td>There are no usermodes for this server</td></tr>";
128 else {
129 for ($i=0; ($mode = (isset($modes[$i])) ? $modes[$i] : NULL); $i++)
130 {
131
132 if ($mode == "o")
133 {
134 ?>
135 <tr>
136 <th>Oper</th>
137 <td>
138 User is an IRC Operator.
139 </td>
140 </tr>
141 <?php
142 }
143 elseif ($mode == "S")
144 {
145 ?>
146 <tr>
147 <th>Service Bot</th>
148 <td>
149 User is a Services Bot.
150 </td>
151 </tr>
152 <?php
153 }
154 elseif ($mode == "d")
155 {
156 ?>
157 <tr>
158 <th>Deaf</th>
159 <td>User is ignoring channel messages.</td>
160 </tr>
161 <?php
162 }
163 elseif ($mode == "i")
164 {
165 ?>
166 <tr>
167 <th>Invisible</th>
168 <td>Not shown in /WHO searches.</td>
169 </tr>
170 <?php
171 }
172 elseif ($mode == "p")
173 {
174 ?>
175 <tr>
176 <th>Private channels</th>
177 <td>Channels hidden in /WHOIS outputs.</td>
178 </tr>
179 <?php
180 }
181 elseif ($mode == "r")
182 {
183 ?>
184 <tr>
185 <th>Registered Nick</th>
186 <td>User is using a registered nick.</td>
187 </tr>
188 <?php
189 }
190 elseif ($mode == "s")
191 {
192 ?>
193 <tr>
194 <th>Server Notices</th>
195 <td>User is receiving server notices.</td>
196 </tr>
197 <?php
198 }
199 elseif ($mode == "t")
200 {
201 ?>
202 <tr>
203 <th>Virtual Host</th>
204 <td>Using a custom hostmask.</td>
205 </tr>
206 <?php
207 }
208 elseif ($mode == "w")
209 {
210 ?>
211 <tr>
212 <th>Wallops</th>
213 <td>Listening to <code>/WALLOPS</code> notices from IRC Operators.</td>
214 </tr>
215 <?php
216 }
217 elseif ($mode == "x")
218 {
219 ?>
220 <tr>
221 <th>Hostmask</th>
222 <td>Using a hostmask (hiding their IP from non-IRCops).</td>
223 </tr>
224 <?php
225 }
226 elseif ($mode == "z")
227 {
228 ?>
229 <tr>
230 <th>Secure</th>
231 <td>
232 User is using a secure connection.
233 </td>
234 </tr>
235 <?php
236 }
237 elseif ($mode == "B")
238 {
239 ?>
240 <tr>
241 <th>Bot</th>
242 <td colspan="2">
243 User is marked as a Bot.
244 </td>
245 </tr>
246 <?php
247 }
248 elseif ($mode == "D")
249 {
250 ?>
251 <tr>
252 <th>PrivDeaf</th>
253 <td colspan="2">
254 User is rejecting incoming private messages.
255 </td>
256 </tr>
257 <?php
258 }
259 elseif ($mode == "G")
260 {
261 ?>
262 <tr>
263 <th>Filter</th>
264 <td colspan="2">
265 User is filtering Bad Words.
266 </td>
267 </tr>
268 <?php
269 }
270 elseif ($mode == "H")
271 {
272 ?>
273 <tr>
274 <th>Hide IRCop</th>
275 <td colspan="2">
276 User is hiding their IRCop status.
277 </td>
278 </tr>
279 <?php
280 }
281 elseif ($mode == "I")
282 {
283 ?>
284 <tr>
285 <th>Hide Idle</th>
286 <td colspan="2">
287 User is hiding their idle time.
288 </td>
289 </tr>
290 <?php
291 }
292 elseif ($mode == "R")
293 {
294 ?>
295 <tr>
296 <th>RegOnly Messages</th>
297 <td colspan="2">
298 User is only accepting private messages from registered users.
299 </td>
300 </tr>
301 <?php
302 }
303 elseif ($mode == "T")
304 {
305 ?>
306 <tr>
307 <th>Deny CTCPs</th>
308 <td colspan="2">
309 Denying CTCP requests.
310 </td>
311 </tr>
312 <?php
313 }
314 elseif ($mode == "W")
315 {
316 ?>
317 <tr>
318 <th>View /WHOIS</th>
319 <td colspan="2">
320 User is receiving notifications when someone does a <code>/WHOIS</code> on them.
321 </td>
322 </tr>
323 <?php
324 }
325 elseif ($mode == "Z")
326 {
327 ?>
328 <tr>
329 <th>Deny Insecure Messages</th>
330 <td colspan="2">
331 User is only accepting messages from users using a secure connection.
332 </td>
333 </tr>
334 <?php
335 }
336 }
337 }
338 echo "</table>";
339 }
340
341 function generate_html_extserverinfo($server)
342 {
343 ?>
344 <table class="table-sm table-responsive caption-top table-hover">
345 <tbody>
346 <tr>
347 <th>IP</th>
348 <td colspan="2"><code><?php echo (($server->ip) ? htmlspecialchars($server->ip) : "Unable to detect IP"); ?></code></td>
349 </tr><tr>
350 <th>Boot time</th>
351 <td colspan="2"><code><?php echo (($server->server->boot_time) ? htmlspecialchars($server->server->boot_time) : "Not available"); ?></code></td>
352 </tr><tr>
353 <th>U-Lined</th>
354 <td colspan="2"><?php echo ($server->server->ulined) ? "<span class=\"badge rounded-pill badge-success\">Yes</span>" : "<span class=\"badge rounded-pill badge-danger\">No</span>"; ?></td>
355 </tr><tr>
356 <th>Protocol</th>
357 <td colspan="2"><a href="https://www.unrealircd.org/docs/Server_protocol:Protocol_version"><code><?php echo htmlspecialchars($server->server->features->protocol); ?></code></a></td>
358 </tr>
359 <?php if (property_exists($server, "tls")) { ?>
360 <tr>
361 <th>TLS</th>
362 <td colspan="2">
363 <table>
364 <tr>
365 <th>Cert Fingerprint</th>
366 <td><?php echo "<span class=\"badge rounded-pill badge-info\">".htmlspecialchars($server->tls->certfp)."</span>"; ?></td>
367 </tr><tr>
368 <th>TLS Cipher</th>
369 <td><?php echo "<span class=\"badge rounded-pill badge-info\">".htmlspecialchars($server->tls->cipher)."</span>"; ?></td>
370 </tr>
371
372 </table>
373 </td>
374 </tr>
375 <?php } ?>
376 </tbody>
377 </table>
378 <?php
379 }
380 function generate_html_modlist($srv)
381 {
382 global $rpc;
383 $modules = $rpc->server()->module_list($srv->id);
384 if (!$modules || !$modules->list)
385 {
386 echo $rpc->error;
387 } else {
388 ?>
389
390 <table class="table table-sm table-responsive table-hover">
391 <thead class="table-info">
392 <th>Name</th>
393 <th>Description</th>
394 <th>Source</th>
395 <th>Author</th>
396 <th>Version</th>
397 </thead>
398 <tbody>
399 <?php
400 foreach ($modules->list as $module) {
401 echo "<tr>\n";
402 echo "<td><code>".htmlspecialchars($module->name)."</code></td>";
403 $desc = $module->description;
404 $short_desc = substr($desc, 0, 70); // truncate to 80 chars
405 if (strlen($desc) > strlen($short_desc))
406 $short_desc .= "...";
407 echo "<td><span href='#' data-toggle='tooltip' title=\"".htmlspecialchars($desc)."\">".htmlspecialchars($short_desc)."</span></td>";
408 $source = (!$module->third_party) ? "<div class=\"badge rounded-pill badge-success\">Official</div>" : "<div class=\"badge rounded-pill badge-info\">Third-Party</div>";
409 echo "<td>$source</td>";
410 echo "<td>".htmlspecialchars($module->author)."</td>";
411 echo "<td>".htmlspecialchars($module->version)."</td>";
412 }
413 }
414 ?>
415 </tbody>
416 </table>
417
418 <?php
419 }
420
421
422 function get_unreal_latest_version()
423 {
424 $url = "https://www.unrealircd.org/downloads/list.json";
425 $contents = file_get_contents($url);
426 if (!$contents)
427 {
428 Message::Fail("Could not get latest version of UnrealIRCd. Please check again later.");
429 return NULL;
430 }
431 $arr = json_decode($contents, true);
432 $biggest = 0;
433 foreach($arr as $key => $value)
434 {
435 if ($key > $biggest)
436 $biggest = $key;
437 }
438 if (!$biggest)
439 {
440 Message::Fail("Could not get latest version of UnrealIRCd. Please check again later.");
441 return NULL;
442 }
443 return $arr[$biggest]['Stable']['version'];
444 }