T201704030953

This commit is contained in:
Leander
2017-04-03 09:53:08 +02:00
parent 89e7c0090b
commit 4d657eccf3
3 changed files with 9 additions and 4 deletions

View File

@@ -11,4 +11,5 @@
= start.php = = start.php =
12101 - 0 questions wanted, no game without a question! 12101 - 0 questions wanted, no game without a question!
12102 - More questions wanted then existing 12102 - More questions wanted then existing
12103 - User ID not specified

View File

@@ -61,6 +61,8 @@ class Database
return 'A game without a question is not possible. Please select new game length.'; return 'A game without a question is not possible. Please select new game length.';
case 12102: case 12102:
return 'We only have '.$values[0].' questions. Please select new game length.'; 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: default:
return 'An unknown error occurred.'; return 'An unknown error occurred.';
} }

View File

@@ -10,8 +10,8 @@
$data = ''; $data = '';
$error = 0; $error = 0;
$values = null; $values = null;
$uid = $_GET['uid']; $uid = isset($_GET['uid']) ? $_GET['uid'] : '';
$length = $_GET['length']; $length = isset($_GET['length']) ? $_GET['length'] : '';
$length = (($length === '0') || ($length && gettype(+$length) == 'integer')) ? +$_GET['length'] : 10; $length = (($length === '0') || ($length && gettype(+$length) == 'integer')) ? +$_GET['length'] : 10;
$db = new Database(); $db = new Database();
$questions_count = $db->query('SELECT COUNT(*) FROM "Questions"')['data'][0]['count']; $questions_count = $db->query('SELECT COUNT(*) FROM "Questions"')['data'][0]['count'];
@@ -23,7 +23,9 @@
return array_slice($numbers, 0, $count-1); return array_slice($numbers, 0, $count-1);
} }
if($length == 0) { if($uid = '') {
$error = 12103;
} else if($length == 0) {
$error = 12101; $error = 12101;
} else if($length > $questions_count) { } else if($length > $questions_count) {
$error = 12102; $error = 12102;