From 4d657eccf32bc4a3541bfe3d930ec9c63d3dac1e Mon Sep 17 00:00:00 2001 From: Leander Date: Mon, 3 Apr 2017 09:53:08 +0200 Subject: [PATCH] T201704030953 --- Config.txt | 3 ++- Database.php | 2 ++ start.php | 8 +++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Config.txt b/Config.txt index 6f058b0..489039f 100644 --- a/Config.txt +++ b/Config.txt @@ -11,4 +11,5 @@ = start.php = 12101 - 0 questions wanted, no game without a question! -12102 - More questions wanted then existing \ No newline at end of file +12102 - More questions wanted then existing +12103 - User ID not specified \ No newline at end of file diff --git a/Database.php b/Database.php index 7896925..e3b7fc7 100644 --- a/Database.php +++ b/Database.php @@ -61,6 +61,8 @@ class Database return 'A game without a question is not possible. Please select new game length.'; case 12102: return 'We only have '.$values[0].' questions. Please select new game length.'; + case 12103: + return 'No user ID specified. Sebastian, please fix the app.'; default: return 'An unknown error occurred.'; } diff --git a/start.php b/start.php index 8862a2d..b7a6722 100644 --- a/start.php +++ b/start.php @@ -10,8 +10,8 @@ $data = ''; $error = 0; $values = null; - $uid = $_GET['uid']; - $length = $_GET['length']; + $uid = isset($_GET['uid']) ? $_GET['uid'] : ''; + $length = isset($_GET['length']) ? $_GET['length'] : ''; $length = (($length === '0') || ($length && gettype(+$length) == 'integer')) ? +$_GET['length'] : 10; $db = new Database(); $questions_count = $db->query('SELECT COUNT(*) FROM "Questions"')['data'][0]['count']; @@ -23,7 +23,9 @@ return array_slice($numbers, 0, $count-1); } - if($length == 0) { + if($uid = '') { + $error = 12103; + } else if($length == 0) { $error = 12101; } else if($length > $questions_count) { $error = 12102;