IPv6 support #2
authorChristian Weiske <cweiske@cweiske.de>
Thu, 14 May 2020 18:52:20 +0000 (20:52 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Thu, 14 May 2020 18:52:20 +0000 (20:52 +0200)
www/api/v1/queued_downloads.php
www/api/v1/queued_downloads_delete.php

index dd52bcd05622f2b586fe01cd38101c62a44e9189..6edeaad2534a7f2d6e020c65f1ac126d985d6b9d 100644 (file)
@@ -12,8 +12,9 @@ $apiGameDir = __DIR__ . '/details-data/';
 require_once __DIR__ . '/../../../src/push-to-my-ouya-helpers.php';
 
 $ip = $_SERVER['REMOTE_ADDR'];
 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);
     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
     $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);
     header('Content-type: application/json');
     echo file_get_contents('queued_downloads');
     exit(1);
index 3861f93f060187d5bd563082aea65c64cabacd7c..43f7440054200655010d45600d61c400295b44ec 100644 (file)
@@ -12,8 +12,9 @@ $apiGameDir = __DIR__ . '/details-data/';
 require_once __DIR__ . '/../../../src/push-to-my-ouya-helpers.php';
 
 $ip = $_SERVER['REMOTE_ADDR'];
 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);
 }
     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
     $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);
 }
     header('HTTP/1.0 204 No Content');
     exit(1);
 }