]>
Commit | Line | Data |
---|---|---|
ab23a935 VP |
1 | <?php |
2 | ||
3 | ||
fb27b14a | 4 | function 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 |
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>"; ?> |
11b7f7e4 | 106 | <td colspan="2"><code><?php echo "<a href=\"".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 | |
118 | } | |
119 | function generate_html_modlist($srv) | |
120 | { | |
121 | global $rpc; | |
122 | $modules = $rpc->server()->module_list($srv->id); | |
fb27b14a VP |
123 | if (!$modules || !$modules->list) |
124 | { | |
125 | echo $rpc->error; | |
126 | } else { | |
127 | ?> | |
ab23a935 VP |
128 | |
129 | <table class="table table-sm table-responsive table-hover"> | |
130 | <thead class="table-info"> | |
131 | <th>Name</th> | |
132 | <th>Description</th> | |
133 | <th>Source</th> | |
134 | <th>Author</th> | |
135 | <th>Version</th> | |
136 | </thead> | |
137 | <tbody> | |
138 | <?php | |
fb27b14a VP |
139 | foreach ($modules->list as $module) { |
140 | echo "<tr>\n"; | |
11b7f7e4 | 141 | echo "<td><code>".htmlspecialchars($module->name)."</code></td>"; |
fb27b14a VP |
142 | $desc = $module->description; |
143 | $short_desc = substr($desc, 0, 70); // truncate to 80 chars | |
144 | if (strlen($desc) > strlen($short_desc)) | |
145 | $short_desc .= "..."; | |
11b7f7e4 | 146 | echo "<td><span href='#' data-toggle='tooltip' title=\"".htmlspecialchars($desc)."\">".htmlspecialchars($short_desc)."</span></td>"; |
fb27b14a | 147 | $source = (!$module->third_party) ? "<div class=\"badge rounded-pill badge-success\">Official</div>" : "<div class=\"badge rounded-pill badge-info\">Third-Party</div>"; |
3e96094f | 148 | echo "<td>$source</td>"; |
11b7f7e4 BM |
149 | echo "<td>".htmlspecialchars($module->author)."</td>"; |
150 | echo "<td>".htmlspecialchars($module->version)."</td>"; | |
fb27b14a VP |
151 | } |
152 | } | |
ab23a935 VP |
153 | ?> |
154 | </tbody> | |
155 | </table> | |
156 | ||
157 | <?php | |
d72d1923 VP |
158 | } |
159 | ||
160 | ||
161 | function get_unreal_latest_version() | |
162 | { | |
163 | $url = "https://www.unrealircd.org/downloads/list.json"; | |
164 | $contents = file_get_contents($url); | |
165 | if (!$contents) | |
166 | { | |
167 | Message::Fail("Could not get latest version of UnrealIRCd. Please check again later."); | |
168 | return NULL; | |
169 | } | |
170 | $arr = json_decode($contents, true); | |
171 | $biggest = 0; | |
172 | foreach($arr as $key => $value) | |
173 | { | |
174 | if ($key > $biggest) | |
175 | $biggest = $key; | |
176 | } | |
177 | if (!$biggest) | |
178 | { | |
179 | Message::Fail("Could not get latest version of UnrealIRCd. Please check again later."); | |
180 | return NULL; | |
181 | } | |
182 | return $arr[$biggest]['Stable']['version']; | |
ab23a935 | 183 | } |