add license, make php source more readable, add source code link, etc.
This commit is contained in:
parent
192f2cfad4
commit
fbb81b8d79
3 changed files with 73 additions and 33 deletions
21
README.md
21
README.md
|
@ -1,5 +1,24 @@
|
|||
# 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)
|
||||
|
||||
## 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.
|
||||
```
|
||||
|
|
12
index.css
12
index.css
|
@ -4,7 +4,17 @@ body {
|
|||
justify-content: center;
|
||||
background-color: #20202a;
|
||||
color: white;
|
||||
font-family: sans-serif;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
a, a:visited {
|
||||
color: cyan;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
footer {
|
||||
display: flex;
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
table {
|
||||
|
|
71
index.php
71
index.php
|
@ -1,4 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<!--
|
||||
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(
|
||||
'http'=>array(
|
||||
|
@ -11,6 +26,7 @@ $context = stream_context_create($opts);
|
|||
|
||||
// Here you can change the URL of the server
|
||||
$data = file_get_contents("http://pgg-server.glitch.me/scripts/getrooms.php", false, $context);
|
||||
parse_str($data, $arr);
|
||||
?>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
@ -23,11 +39,7 @@ $data = file_get_contents("http://pgg-server.glitch.me/scripts/getrooms.php", fa
|
|||
<h1>List of active games.</h1>
|
||||
<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>
|
||||
<?php
|
||||
if ($data == false) {
|
||||
echo "<div class='error'>Request failed. You may want to try to reload the page</div>";
|
||||
} else {
|
||||
echo "<table>
|
||||
<table>
|
||||
<thead>
|
||||
<th>Name</td>
|
||||
<th>Players</td>
|
||||
|
@ -37,34 +49,33 @@ if ($data == false) {
|
|||
<th>Country</td>
|
||||
<th>Gamemode</td>
|
||||
</thead>
|
||||
<tbody>";
|
||||
|
||||
parse_str($data, $arr);
|
||||
if ($arr['cant'] != "0") {
|
||||
foreach (range(0, $arr['cant']-1) as $i) {
|
||||
$i = strval($i);
|
||||
echo "
|
||||
<tr>
|
||||
<td class='roomname'>" . $arr["roomname$i"] . "</td>
|
||||
<td class='players'>" . $arr["players$i"] . "/" . $arr["maxplayers$i"] ."</td>
|
||||
<td class='passwd'>idk</td>
|
||||
<td class='pvp'>" . $arr["pvp$i"] . "</td>
|
||||
<td class='edit'>" . $arr["edit$i"]. "</td>
|
||||
<td class='country'>" . $arr["country$i"] . "</td>
|
||||
<td class='gamemode'>" . $arr["gamemode$i"] . "</td>
|
||||
</tr>";
|
||||
};
|
||||
} else {
|
||||
echo "
|
||||
<tbody>
|
||||
<?php
|
||||
// php tags are indented in this way to
|
||||
// prevent an issue with the whitespace on the
|
||||
// resulting html
|
||||
?>
|
||||
<?php if ($arr['cant'] != "0") : ?>
|
||||
<?php foreach (range(0, $arr['cant']-1) as $i): ?>
|
||||
<tr>
|
||||
<td class='roomname'><?= $arr["roomname$i"]?></td>
|
||||
<td class='players'><?= $arr["players$i"] . "/" . $arr["maxplayers$i"] ?></td>
|
||||
<td class='passwd'>idk</td>
|
||||
<td class='pvp'><?= $arr["pvp$i"] ?></td>
|
||||
<td class='edit'><?= $arr["edit$i"] ?></td>
|
||||
<td class='country'><?= $arr["country$i"] ?></td>
|
||||
<td class='gamemode'><?= $arr["gamemode$i"] ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else : ?>
|
||||
<tr>
|
||||
<td colspan=7 class='nogames'>No active games</td>
|
||||
</tr>";
|
||||
}
|
||||
echo "
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
";
|
||||
}
|
||||
?>
|
||||
<footer>
|
||||
<a href="https://git.magmaus3.eu.org/magmaus3/projectgungame-roomviewer-php">Source code</a>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in a new issue