projectgungame-roomviewer-php/index.php
2024-07-17 20:56:28 +02:00

81 lines
2.8 KiB
PHP

<!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(
'method'=>"GET",
'header'=>"User-Agent: pgg-room-viewer_php +https://git.magmaus3.eu.org/magmaus3/projectgungame-roomviewer-php \r\n"
)
);
$context = stream_context_create($opts);
// Here you can change the URL of the server
$data = file_get_contents("http://projectgungame.top/scripts/getrooms.php", false, $context);
parse_str($data, $arr);
?>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="index.css" rel="stylesheet">
</head>
<body>
<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>
<table>
<thead>
<th>Name</td>
<th>Players</td>
<th>Password</td>
<th>PvP</td>
<th>Edit</td>
<th>Country</td>
<th>Gamemode</td>
</thead>
<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>
<?php endif; ?>
</tbody>
</table>
<footer>
<a href="https://git.magmaus3.eu.org/magmaus3/projectgungame-roomviewer-php">Source code</a>
</footer>
</body>
</html>