]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blame - misc/server-lookup-misc.php
Add some badges
[irc/unrealircd/unrealircd-webpanel.git] / misc / server-lookup-misc.php
CommitLineData
ab23a935
VP
1<?php
2
3
fb27b14a 4function generate_html_servermodes($server)
ab23a935 5{
fb27b14a 6 include UPATH . "/Classes/class-cmodes.php";
ab23a935 7 ?>
fb27b14a
VP
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}
ab23a935 45
fb27b14a
VP
46function sinfo_conv_version_string($server) : string
47{
48 $string = (isset($server->server->features->software)) ? $server->server->features->software : "";
dca62e70 49 $return = "";
fb27b14a
VP
50 if (strlen($string) && strpos($string,"-"))
51 {
52 $tok = split($string, "-");
792e0ffc
VP
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>";
fb27b14a
VP
59 }
60 if ($server->server->ulined)
dca62e70 61 $return .= "<div class=\"badge rounded-pill badge-warning\">Services</div>";
fb27b14a
VP
62 return $return;
63}
64
65function generate_html_serverinfo($server)
66{
67 ?>
ab23a935
VP
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>
fb27b14a
VP
76 </tr><tr>
77 <th>Info</th>
78 <td colspan="2"><code><?php echo $server->server->info; ?></code></td>
ab23a935 79 </tr><tr>
fb27b14a
VP
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>
ab23a935 82 </tr><tr>
fb27b14a
VP
83 <th>User count</th>
84 <td colspan="2"><code><?php echo $server->server->num_users; ?></code></td>
ab23a935 85 </tr><tr>
fb27b14a
VP
86 <th>Version</th>
87 <td colspan="2"><?php echo sinfo_conv_version_string($server); ?></td>
ab23a935 88 </tr>
ab23a935
VP
89 </tbody>
90 </table>
91
92 <?php
93}
94function generate_html_modlist($srv)
95{
96 global $rpc;
97 $modules = $rpc->server()->module_list($srv->id);
fb27b14a
VP
98 if (!$modules || !$modules->list)
99 {
100 echo $rpc->error;
101 } else {
102 ?>
ab23a935
VP
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
fb27b14a
VP
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 }
ab23a935
VP
128 ?>
129 </tbody>
130 </table>
131
132 <?php
133}