diff --git a/Config.txt b/Config.txt index 02b5003..e53f9ed 100644 --- a/Config.txt +++ b/Config.txt @@ -24,3 +24,6 @@ = rename.php = 14101 - User name doesn't match rules 14102 - User name already exists + += highscores.php = +15101 - User ID not specified diff --git a/Database.php b/Database.php index 3d26a8c..00e337e 100644 --- a/Database.php +++ b/Database.php @@ -64,6 +64,7 @@ class Database return 'User name already exists. Please pick a different name.'; case 12101: case 13101: + case 15101: return 'User ID not specified. This is an internal error.'; case 12102: return 'A game without a question is not possible. Please select new game length.'; diff --git a/highscores.php b/highscores.php index 2bf294f..a3866ce 100644 --- a/highscores.php +++ b/highscores.php @@ -10,6 +10,7 @@ require_once('includes.inc.php'); $data = ''; $error = 0; $uid = isset($_GET['uid']) ? $_GET['uid'] : ''; +$db = new Database(); $categories[] = array('id' => 1, 'name' => "BWL", 'score' => 321, 'place' => 123); $categories[] = array('id' => 2, 'name' => "Mathematik", 'score' => 1454, 'place' => 1); @@ -18,4 +19,15 @@ $info = array('score' => 3253, 'place' => 122, 'all' => 321, 'categories' => $ca $response = Database::create_response($info, $error); print_r($response); +if($uid == '') { + $error = 15101; +} else if($db->query('SELECT EXISTS (SELECT 1 FROM "Users" WHERE "ID" = $1)', array($uid)) + ['data']['0']['exists'] == 'f') { + + $score = $db->query('SELECT "highscore" FROM "Users" WHERE "ID" = $1', array($uid))['data'][0]['highscore']; + $all = $db->query('SELECT COUNT (*) FROM "Users"')['data']['0']['count']; + print 'Score: '.$score; + print 'All: '.$all; +} + ?> \ No newline at end of file