]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - misc/server-lookup-misc.php
1aaa6abbf9f7abdf9e914df47fbc0921c54af498
[irc/unrealircd/unrealircd-webpanel.git] / misc / server-lookup-misc.php
1 <?php
2
3
4 function generate_html_servermodes($server)
5 {
6 include UPATH . "/Classes/class-cmodes.php";
7 ?>
8 <table class="table-sm table-responsive caption-top table-hover">
9 <thead>
10 <th>Name</th>
11 <th>Description</th>
12 <th>Requires</th>
13 </thead>
14 <?php
15
16 foreach ($server->server->features->chanmodes as $set)
17 {
18 if (!$set)
19 break;
20 for ($i = 0; isset($set[$i]); $i++)
21 {
22 $mode = $set[$i];
23 if (isset(IRCList::$cmodes[$mode])) {
24 ?>
25 <tr>
26 <th><?php echo IRCList::$cmodes[$mode]['name']; ?></th>
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 }
45
46 function sinfo_conv_version_string($server) : string
47 {
48 $string = (isset($server->server->features->software)) ? $server->server->features->software : "";
49 $return = "";
50 if (strlen($string) && strpos($string,"-"))
51 {
52 $tok = split($string, "-");
53 $tooltip = ($tok[2] == "git") ? "Installed from GitHub" : NULL;
54 if (!$tooltip)
55 {
56 $tooltip = (substr($tok[2],0,2) == "rc") ? "Release Candidate/Beta Version" : "";
57 }
58 $return = "<span data-toggle=\"tooltip\" data-placement=\"bottom\" title=\"$tooltip\"><code>" . $tok[1] . "</code> <div class=\"badge rounded-pill badge-dark\">" . $tok[2] . "</div></a>";
59 }
60 if ($server->server->ulined)
61 $return .= "<div class=\"badge rounded-pill badge-warning\">Services</div>";
62 return $return;
63 }
64
65 function generate_html_serverinfo($server)
66 {
67 ?>
68 <table class="table-sm table-responsive caption-top table-hover">
69 <tbody>
70 <tr>
71 <th>Name</th>
72 <td colspan="2"><code><?php echo $server->name; ?></code></td>
73 </tr><tr>
74 <th>Server ID (SID)</th>
75 <td colspan="2"><code><?php echo $server->id; ?></code></td>
76 </tr><tr>
77 <th>Info</th>
78 <td colspan="2"><code><?php echo $server->server->info; ?></code></td>
79 </tr><tr>
80 <th>Uplink</th>
81 <td colspan="2"><code><?php echo "<a href=\"".BASE_URL."servers/details.php?server=".$server->server->uplink."\">".$server->server->uplink."</a>"; ?></code></td>
82 </tr><tr>
83 <th>User count</th>
84 <td colspan="2"><code><?php echo $server->server->num_users; ?></code></td>
85 </tr><tr>
86 <th>Version</th>
87 <td colspan="2"><?php echo sinfo_conv_version_string($server); ?></td>
88 </tr>
89 </tbody>
90 </table>
91
92 <?php
93 }
94 function generate_html_modlist($srv)
95 {
96 global $rpc;
97 $modules = $rpc->server()->module_list($srv->id);
98 if (!$modules || !$modules->list)
99 {
100 echo $rpc->error;
101 } else {
102 ?>
103
104 <table class="table table-sm table-responsive table-hover">
105 <thead class="table-info">
106 <th>Name</th>
107 <th>Description</th>
108 <th>Source</th>
109 <th>Author</th>
110 <th>Version</th>
111 </thead>
112 <tbody>
113 <?php
114 foreach ($modules->list as $module) {
115 echo "<tr>\n";
116 echo "<td><code>$module->name</code></td>";
117 $desc = $module->description;
118 $short_desc = substr($desc, 0, 70); // truncate to 80 chars
119 if (strlen($desc) > strlen($short_desc))
120 $short_desc .= "...";
121 echo "<td><span href='#' data-toggle='tooltip' title=\"$desc\">$short_desc</span></td>";
122 $source = (!$module->third_party) ? "<div class=\"badge rounded-pill badge-success\">Official</div>" : "<div class=\"badge rounded-pill badge-info\">Third-Party</div>";
123 echo "<td>$source</td>";
124 echo "<td>$module->author</td>";
125 echo "<td>$module->version</td>";
126 }
127 }
128 ?>
129 </tbody>
130 </table>
131
132 <?php
133 }