]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blame - misc/server-lookup-misc.php
Shut up some errors
[irc/unrealircd/unrealircd-webpanel.git] / misc / server-lookup-misc.php
CommitLineData
ab23a935
VP
1<?php
2
3
fb27b14a 4function generate_html_servermodes($server)
ab23a935
VP
5{
6 ?>
fb27b14a
VP
7 <table class="table-sm table-responsive caption-top table-hover">
8 <thead>
9 <th>Name</th>
ac50314f 10 <th>Mode</th>
fb27b14a
VP
11 <th>Description</th>
12 <th>Requires</th>
13 </thead>
14 <?php
22bfef89
VP
15 if (isset($server->server->features->chanmodes))
16 {
17 foreach ($server->server->features->chanmodes as $set)
fb27b14a 18 {
22bfef89
VP
19 if (!$set)
20 break;
21 for ($i = 0; isset($set[$i]); $i++)
22 {
23 $mode = $set[$i];
24 if (isset(IRCList::$cmodes[$mode])) {
fb27b14a
VP
25 ?>
26 <tr>
22bfef89
VP
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 }
fb27b14a 41 }
fb27b14a 42 }
22bfef89 43 }
fb27b14a
VP
44 ?>
45 </table><?php
46}
ab23a935 47
fb27b14a
VP
48function sinfo_conv_version_string($server) : string
49{
50 $string = (isset($server->server->features->software)) ? $server->server->features->software : "";
dca62e70 51 $return = "";
2464d35e
BM
52 $tooltip = "";
53 $badge = "";
54 $display_string = $string;
55
fb27b14a
VP
56 if (strlen($string) && strpos($string,"-"))
57 {
58 $tok = split($string, "-");
2464d35e 59 if (($tok[0] == "UnrealIRCd") && isset($tok[2]))
792e0ffc 60 {
2464d35e
BM
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 }
11b7f7e4
BM
80 $tooltip = htmlspecialchars($tooltip);
81 $display_string = htmlspecialchars($display_string);
792e0ffc 82 }
2464d35e 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>";
fb27b14a 84 }
a9fac1f0 85 if (isset($server->server->ulined) && $server->server->ulined)
dca62e70 86 $return .= "<div class=\"badge rounded-pill badge-warning\">Services</div>";
fb27b14a
VP
87 return $return;
88}
89
90function generate_html_serverinfo($server)
91{
a8296a5e 92 global $rpc;
fb27b14a 93 ?>
ab23a935
VP
94 <table class="table-sm table-responsive caption-top table-hover">
95 <tbody>
96 <tr>
97 <th>Name</th>
11b7f7e4 98 <td colspan="2"><code><?php echo htmlspecialchars($server->name); ?></code></td>
ab23a935
VP
99 </tr><tr>
100 <th>Server ID (SID)</th>
11b7f7e4 101 <td colspan="2"><code><?php echo htmlspecialchars($server->id); ?></code></td>
fb27b14a
VP
102 </tr><tr>
103 <th>Info</th>
11b7f7e4 104 <td colspan="2"><code><?php echo htmlspecialchars($server->server->info); ?></code></td>
ab23a935 105 </tr><tr>
fb27b14a 106 <th>Uplink</th>
22bfef89
VP
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>
ab23a935 109 </tr><tr>
fb27b14a 110 <th>User count</th>
11b7f7e4 111 <td colspan="2"><code><?php echo htmlspecialchars($server->server->num_users); ?></code></td>
ab23a935 112 </tr><tr>
fb27b14a
VP
113 <th>Version</th>
114 <td colspan="2"><?php echo sinfo_conv_version_string($server); ?></td>
ab23a935 115 </tr>
ab23a935
VP
116 </tbody>
117 </table>
118
119 <?php
ac50314f
VP
120}
121
122function generate_html_usermodes($server)
123{
22bfef89 124 $modes = $server->server->features->usermodes ?? NULL;
ac50314f 125 echo "<table class=\"table-sm table-responsive caption-top table-hover\">";
22bfef89
VP
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++)
ac50314f 130 {
22bfef89
VP
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 }
ac50314f
VP
336 }
337 }
338 echo "</table>";
339}
340
341function 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>
22bfef89 348 <td colspan="2"><code><?php echo (($server->ip) ? htmlspecialchars($server->ip) : "Unable to detect IP"); ?></code></td>
ac50314f
VP
349 </tr><tr>
350 <th>Boot time</th>
88a02fe4 351 <td colspan="2"><code><?php echo (($server->server->boot_time) ? htmlspecialchars($server->server->boot_time) : "Not available"); ?></code></td>
ac50314f
VP
352 </tr><tr>
353 <th>U-Lined</th>
8284a4e0 354 <td colspan="2"><?php echo (isset($server->server->ulined) && $server->server->ulined) ? "<span class=\"badge rounded-pill badge-success\">Yes</span>" : "<span class=\"badge rounded-pill badge-danger\">No</span>"; ?></td>
ac50314f
VP
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>
d32879c2
BM
358 </tr>
359<?php if (property_exists($server, "tls")) { ?>
360 <tr>
ac50314f 361 <th>TLS</th>
ac50314f
VP
362 <td colspan="2">
363 <table>
364 <tr>
365 <th>Cert Fingerprint</th>
cd26522b 366 <td><?php echo (isset($server->tls->certfp) ? "<span class=\"badge rounded-pill badge-info\">".htmlspecialchars($server->tls->certfp). "</span>" : "none"); ?></td>
ac50314f
VP
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>
d32879c2 375<?php } ?>
ac50314f
VP
376 </tbody>
377 </table>
378 <?php
ab23a935
VP
379}
380function generate_html_modlist($srv)
381{
382 global $rpc;
383 $modules = $rpc->server()->module_list($srv->id);
fb27b14a
VP
384 if (!$modules || !$modules->list)
385 {
386 echo $rpc->error;
387 } else {
388 ?>
ab23a935
VP
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
fb27b14a
VP
400 foreach ($modules->list as $module) {
401 echo "<tr>\n";
11b7f7e4 402 echo "<td><code>".htmlspecialchars($module->name)."</code></td>";
fb27b14a
VP
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 .= "...";
11b7f7e4 407 echo "<td><span href='#' data-toggle='tooltip' title=\"".htmlspecialchars($desc)."\">".htmlspecialchars($short_desc)."</span></td>";
fb27b14a 408 $source = (!$module->third_party) ? "<div class=\"badge rounded-pill badge-success\">Official</div>" : "<div class=\"badge rounded-pill badge-info\">Third-Party</div>";
3e96094f 409 echo "<td>$source</td>";
11b7f7e4
BM
410 echo "<td>".htmlspecialchars($module->author)."</td>";
411 echo "<td>".htmlspecialchars($module->version)."</td>";
fb27b14a
VP
412 }
413 }
ab23a935
VP
414 ?>
415 </tbody>
416 </table>
417
418 <?php
d72d1923
VP
419}
420
421
422function 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'];
ab23a935 444}