forked from OpenRA/OpenRAMasterServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.php
30 lines (28 loc) · 935 Bytes
/
list.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
date_default_timezone_set('UTC');
header( 'Content-type: text/plain' );
try
{
$db = new PDO('sqlite:db/openra.db');
$stale = 60 * 5;
$result = $db->query('SELECT * FROM servers WHERE (' . time() . ' - ts < ' . $stale . ') ORDER BY name');
$n = 0;
foreach ( $result as $row )
{
echo "Game@" . $n++ . ":\n";
echo "\tId: " . $row['id'] . "\n";
echo "\tName: " . $row['name'] . "\n";
echo "\tAddress: " . $row['address'] . "\n";
echo "\tState: " . $row['state'] . "\n";
echo "\tPlayers: " . $row['players'] . "\n";
echo "\tMap: " . $row['map'] . "\n";
echo "\tMods: " . $row['mods'] . "\n";
echo "\tTTL: " . ($stale - (time() - $row['ts'])) . "\n";
}
$db = null;
}
catch (PDOException $e)
{
echo $e->getMessage();
}
?>