From: Christian Weiske Date: Thu, 14 May 2020 18:52:20 +0000 (+0200) Subject: IPv6 support #2 X-Git-Tag: v2.0.0~1 X-Git-Url: https://git.cweiske.de/stouyapi.git/commitdiff_plain/d648b848012e6eb3a528e6b295b0ee6d0515332e IPv6 support #2 --- diff --git a/www/api/v1/queued_downloads.php b/www/api/v1/queued_downloads.php index dd52bcd..6edeaad 100644 --- a/www/api/v1/queued_downloads.php +++ b/www/api/v1/queued_downloads.php @@ -12,8 +12,9 @@ $apiGameDir = __DIR__ . '/details-data/'; require_once __DIR__ . '/../../../src/push-to-my-ouya-helpers.php'; $ip = $_SERVER['REMOTE_ADDR']; -if ($ip == '' || strpos($ip, ':') !== false) { - //empty or IPv6 +if ($ip == '') { + //empty ip + header('X-Fail-Reason: empty ip address'); header('Content-type: application/json'); echo file_get_contents('queued_downloads'); exit(1); @@ -24,6 +25,7 @@ try { $db = new SQLite3($dbFile, SQLITE3_OPEN_READONLY); } catch (Exception $e) { //db file not found + header('X-Fail-Reason: database file not found'); header('Content-type: application/json'); echo file_get_contents('queued_downloads'); exit(1); diff --git a/www/api/v1/queued_downloads_delete.php b/www/api/v1/queued_downloads_delete.php index 3861f93..43f7440 100644 --- a/www/api/v1/queued_downloads_delete.php +++ b/www/api/v1/queued_downloads_delete.php @@ -12,8 +12,9 @@ $apiGameDir = __DIR__ . '/details-data/'; require_once __DIR__ . '/../../../src/push-to-my-ouya-helpers.php'; $ip = $_SERVER['REMOTE_ADDR']; -if ($ip == '' || strpos($ip, ':') !== false) { - //empty or IPv6 +if ($ip == '') { + //empty ip + header('X-Fail-Reason: empty ip address'); header('HTTP/1.0 204 No Content'); exit(1); } @@ -32,6 +33,7 @@ try { $db = new SQLite3($dbFile, SQLITE3_OPEN_READWRITE); } catch (Exception $e) { //db file not found + header('X-Fail-Reason: database file not found'); header('HTTP/1.0 204 No Content'); exit(1); }