This commit is contained in:
magmaus3 2023-07-12 14:03:04 +02:00
commit b9210e5965
Signed by: magmaus3
GPG key ID: 966755D3F4A9B251
2 changed files with 118 additions and 0 deletions

48
index.css Normal file
View file

@ -0,0 +1,48 @@
body {
display: flex;
flex-direction: column;
justify-content: center;
background-color: #20202a;
color: white;
font-family: sans-serif;
}
table {
font-size: large;
border-collapse: collapse;
/* color: black */
}
thead {
border-collapse: separate;
background-color: rgba(255, 255, 255, 0.1);
}
th {
border: 1px solid black;
}
td {
padding: 0.2em;
text-align: center;
}
tr {
border: 1px solid black;
background-color: rgba(255, 255, 255, 0.05);
}
tr:hover {
background-color: rgba(255, 255, 255, 0.1);
}
td .nogames {
width: 100%;
}
.status_code {
color: whitesmoke;
padding: 0.2em;
}
.error {
font-size: larger;
font-weight: 900;
}

70
index.php Normal file
View file

@ -0,0 +1,70 @@
<!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">
<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>
<?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>