1){ $id = $query[0]; } else{ // Id is mandatory, a list can be retrieved header("HTTP/1.1 403 A list of profiles cant be retrieved. Please specify a profile ID or player name."); syslog(LOG_INFO, "[APIv3] HTTP/1.1 403 A list of profiles cant be retrieved. Please specify a profile ID or player name."); return 403; } // Get player $statement = $db->prepare("SELECT * FROM player WHERE uid = :uid OR upper(name) = upper(:uid);"); $statement->bindValue(":uid", $id, SQLITE3_INTEGER); $r = $statement->execute()->fetchArray(SQLITE3_ASSOC); if ($r == null){ // No player found header("HTTP/1.1 404 Player not found."); syslog(LOG_INFO, "[APIv3] HTTP/1.1 404 Player not found."); return 403; } if ($r["public"] != 1 && $r["key"] != filter_input(INPUT_GET, "key")){ header("HTTP/1.1 403 The profile is not public."); syslog(LOG_INFO, "[APIv3] HTTP/1.1 403 The profile is not public."); return 403; } // Build array $player = [ "username" => $r["name"], "level" => $r["level"], "public" => "1" ]; echo(json_encode($player)); header("HTTP/1.1 200 Success."); syslog(LOG_INFO, "[APIv3] HTTP/1.1 200 Success."); return 200; } catch(Exception $e) { header("HTTP/1.1 500 Unexpeced error: " . $e->getMessage()); syslog(LOG_ERR, "[APIv3] HTTP/1.1 500 Unexpected error: " . $e->getMessage()); return 500; } ?>