add license, make php source more readable, add source code link, etc.

This commit is contained in:
magmaus3 2023-07-14 13:27:35 +02:00
parent 192f2cfad4
commit fbb81b8d79
Signed by: magmaus3
GPG key ID: 966755D3F4A9B251
3 changed files with 73 additions and 33 deletions

View file

@ -1,5 +1,24 @@
# Simple active room listing for Project Gungame # Simple active room listing for Project Gungame
Warning: I don't know how to program in php, and the script's source might be the worst thing you ever seen. Warning: I don't know how to program in php,
and the script's source might be the worst thing you ever seen.
Source code is available at [magmaus3/projectgungame-roomviewer-php](https://git.magmaus3.eu.org/magmaus3/projectgungame-roomviewer-php) Source code is available at [magmaus3/projectgungame-roomviewer-php](https://git.magmaus3.eu.org/magmaus3/projectgungame-roomviewer-php)
## License
```
Copyright 2023 magmaus3 <magmaus3@disroot.org>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```

View file

@ -4,7 +4,17 @@ body {
justify-content: center; justify-content: center;
background-color: #20202a; background-color: #20202a;
color: white; color: white;
font-family: sans-serif; font-family: monospace;
}
a, a:visited {
color: cyan;
text-decoration: none;
}
footer {
display: flex;
margin-top: 2em;
} }
table { table {

View file

@ -1,5 +1,20 @@
<!DOCTYPE html> <!DOCTYPE html>
<?php <!--
Copyright 2023 magmaus3 <magmaus3@disroot.org>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<?php
$opts = array( $opts = array(
'http'=>array( 'http'=>array(
'method'=>"GET", 'method'=>"GET",
@ -11,6 +26,7 @@ $context = stream_context_create($opts);
// Here you can change the URL of the server // Here you can change the URL of the server
$data = file_get_contents("http://pgg-server.glitch.me/scripts/getrooms.php", false, $context); $data = file_get_contents("http://pgg-server.glitch.me/scripts/getrooms.php", false, $context);
parse_str($data, $arr);
?> ?>
<html lang="en"> <html lang="en">
<head> <head>
@ -23,11 +39,7 @@ $data = file_get_contents("http://pgg-server.glitch.me/scripts/getrooms.php", fa
<h1>List of active games.</h1> <h1>List of active games.</h1>
<h2>Note that if a person exits their flash player without exiting the room first, <h2>Note that if a person exits their flash player without exiting the room first,
the room will be visible on the list but it'll be impossible to join it.</h2> the room will be visible on the list but it'll be impossible to join it.</h2>
<?php <table>
if ($data == false) {
echo "<div class='error'>Request failed. You may want to try to reload the page</div>";
} else {
echo "<table>
<thead> <thead>
<th>Name</td> <th>Name</td>
<th>Players</td> <th>Players</td>
@ -37,34 +49,33 @@ if ($data == false) {
<th>Country</td> <th>Country</td>
<th>Gamemode</td> <th>Gamemode</td>
</thead> </thead>
<tbody>"; <tbody>
<?php
parse_str($data, $arr); // php tags are indented in this way to
if ($arr['cant'] != "0") { // prevent an issue with the whitespace on the
foreach (range(0, $arr['cant']-1) as $i) { // resulting html
$i = strval($i); ?>
echo " <?php if ($arr['cant'] != "0") : ?>
<tr> <?php foreach (range(0, $arr['cant']-1) as $i): ?>
<td class='roomname'>" . $arr["roomname$i"] . "</td> <tr>
<td class='players'>" . $arr["players$i"] . "/" . $arr["maxplayers$i"] ."</td> <td class='roomname'><?= $arr["roomname$i"]?></td>
<td class='passwd'>idk</td> <td class='players'><?= $arr["players$i"] . "/" . $arr["maxplayers$i"] ?></td>
<td class='pvp'>" . $arr["pvp$i"] . "</td> <td class='passwd'>idk</td>
<td class='edit'>" . $arr["edit$i"]. "</td> <td class='pvp'><?= $arr["pvp$i"] ?></td>
<td class='country'>" . $arr["country$i"] . "</td> <td class='edit'><?= $arr["edit$i"] ?></td>
<td class='gamemode'>" . $arr["gamemode$i"] . "</td> <td class='country'><?= $arr["country$i"] ?></td>
</tr>"; <td class='gamemode'><?= $arr["gamemode$i"] ?></td>
}; </tr>
} else { <?php endforeach; ?>
echo " <?php else : ?>
<tr> <tr>
<td colspan=7 class='nogames'>No active games</td> <td colspan=7 class='nogames'>No active games</td>
</tr>"; </tr>
} <?php endif; ?>
echo "
</tbody> </tbody>
</table> </table>
"; <footer>
} <a href="https://git.magmaus3.eu.org/magmaus3/projectgungame-roomviewer-php">Source code</a>
?> </footer>
</body> </body>
</html> </html>