3 * List games from the "push to my OUYA" list
5 * Pushes are stored in the sqlite3 database in push-to-my-ouya.php
7 * @author Christian Weiske <cweiske@cweiske.de>
9 $dbFile = __DIR__ . '/../../../data/push-to-my-ouya.sqlite3';
10 $apiGameDir = __DIR__ . '/details-data/';
12 require_once __DIR__ . '/../../../src/push-to-my-ouya-helpers.php';
14 $ip = $_SERVER['REMOTE_ADDR'];
17 header('X-Fail-Reason: empty ip address');
18 header('Content-type: application/json');
19 echo file_get_contents('queued_downloads');
25 $db = new SQLite3($dbFile, SQLITE3_OPEN_READONLY);
26 } catch (Exception $e) {
28 header('X-Fail-Reason: database file not found');
29 header('Content-type: application/json');
30 echo file_get_contents('queued_downloads');
35 'SELECT * FROM pushes'
36 . ' WHERE ip = \'' . SQLite3::escapeString($ip) . '\''
39 while ($row = $res->fetchArray(SQLITE3_ASSOC)) {
40 $apiGameFile = $apiGameDir . $row['game'] . '.json';
41 if (!file_exists($apiGameFile)) {
45 $json = json_decode(file_get_contents($apiGameFile));
48 'title' => $json->title,
50 'uuid' => $row['game'],
54 header('Content-type: application/json');
55 echo json_encode(['queue' => $queue]) . "\n";