3 * Delete a game 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('HTTP/1.0 204 No Content');
23 $game = $_GET['game'];
24 $cleanGame = preg_replace('#[^a-zA-Z0-9._]#', '', $game);
25 if ($game != $cleanGame || $game == '') {
26 header('HTTP/1.0 400 Bad Request');
27 header('Content-type: text/plain');
28 echo 'Invalid game' . "\n";
33 $db = new SQLite3($dbFile, SQLITE3_OPEN_READWRITE);
34 } catch (Exception $e) {
36 header('X-Fail-Reason: database file not found');
37 header('HTTP/1.0 204 No Content');
41 $rowId = $db->querySingle(
42 'SELECT id FROM pushes'
43 . ' WHERE ip = \'' . SQLite3::escapeString($ip) . '\''
44 . ' AND game =\'' . SQLite3::escapeString($game) . '\''
46 if ($rowId === null) {
47 header('HTTP/1.0 404 Not Found');
48 header('Content-type: text/plain');
49 echo 'Game not queued' . "\n";
53 $db->exec('DELETE FROM pushes WHERE id = ' . intval($rowId));
54 header('HTTP/1.0 204 No Content');