projectgungame-roomviewer-php/index.php

71 lines
2.2 KiB
PHP
Raw Normal View History

2023-07-12 12:03:04 +00:00
<!DOCTYPE html>
<?php
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"User-Agent: pgg-room-viewer_php +mailto:magmaus3@disroot.org \r\n"
)
);
$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);
?>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
2023-07-12 12:18:10 +00:00
<link href="index.css" rel="stylesheet">
2023-07-12 12:03:04 +00:00
</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>
<?php
if ($data == false) {
echo "<div class='error'>Request failed. You may want to try to reload the page</div>";
} else {
echo "<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>";
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 "
<tr>
<td colspan=7 class='nogames'>No active games</td>
</tr>";
}
echo "
</tbody>
</table>
";
}
?>
</body>
</html>