3 * Return user data with dynamic username that has been saved during login
5 * @author Christian Weiske <cweiske@cweiske.de>
8 $dbFile = __DIR__ . '/../../../../data/usernames.sqlite3';
10 $ip = $_SERVER['REMOTE_ADDR'];
13 header('X-Fail-Reason: empty ip address');
14 header('Content-type: application/json');
15 echo file_get_contents('me.json');
20 $db = new SQLite3($dbFile, SQLITE3_OPEN_READONLY);
21 } catch (Exception $e) {
23 header('X-Fail-Reason: database file not found');
24 header('Content-type: application/json');
25 echo file_get_contents('me.json');
29 $stmt = $db->prepare('SELECT * FROM usernames WHERE ip = :ip');
30 $stmt->bindValue(':ip', $ip);
31 $res = $stmt->execute();
32 $row = $res->fetchArray(SQLITE3_ASSOC);
36 header('Content-type: application/json');
37 echo file_get_contents('me.json');
41 $data = json_decode(file_get_contents('me.json'));
42 $data->gamer->username = $row['username'];
44 switch (strtolower($row['username'])) {
47 $data->gamer->founder = true;
50 header('Content-type: application/json');
51 echo json_encode($data) . "\n";