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'];
15 if ($ip == '' || strpos($ip, ':') !== false) {
17 header('HTTP/1.0 204 No Content');
22 $game = $_GET['game'];
23 $cleanGame = preg_replace('#[^a-zA-Z0-9.]#', '', $game);
24 if ($game != $cleanGame || $game == '') {
25 header('HTTP/1.0 400 Bad Request');
26 header('Content-type: text/plain');
27 echo 'Invalid game' . "\n";
32 $db = new SQLite3($dbFile, SQLITE3_OPEN_READWRITE);
33 } catch (Exception $e) {
35 header('HTTP/1.0 204 No Content');
39 $rowId = $db->querySingle(
40 'SELECT id FROM pushes'
41 . ' WHERE ip = \'' . SQLite3::escapeString($ip) . '\''
42 . ' AND game =\'' . SQLite3::escapeString($game) . '\''
44 if ($rowId === null) {
45 header('HTTP/1.0 404 Not Found');
46 header('Content-type: text/plain');
47 echo 'Game not queued' . "\n";
51 $db->exec('DELETE FROM pushes WHERE id = ' . intval($rowId));
52 header('HTTP/1.0 204 No Content');