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