Update to v2 manifest
This commit is contained in:
1 file changed
+44
-2
@@ -3,11 +3,53 @@ require __DIR__ . '/../../incl/util.php';
|
|||||||
header("Content-Type: application/json");
|
header("Content-Type: application/json");
|
||||||
$conn = newConnection(0);
|
$conn = newConnection(0);
|
||||||
|
|
||||||
$stmt = $conn->prepare("SELECT * FROM launcherversionmanifest WHERE hidden = 0 AND game = 1 ORDER BY id DESC");
|
$stmt = $conn->prepare("SELECT id, versionName, downloads, place FROM launcherversionmanifest WHERE hidden = 0 AND game = 1 ORDER BY id DESC");
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
$result_versions = $stmt->get_result();
|
$result_versions = $stmt->get_result();
|
||||||
$versions = array_map(fn($row) => ['id' => $row['id'], 'version' => $row['downloadUrlVersion'], 'displayName' => $row['downloadUrlVersion'], 'platforms' => json_decode($row['platforms']), 'downloadUrls' => json_decode(str_replace("%version%", $row["downloadUrlVersion"], $row["downloadUrls"])), 'executables' => json_decode($row['executables'])], $result_versions->fetch_all(MYSQLI_ASSOC));
|
$versions = array_map(function($row) use ($conn) {
|
||||||
|
$downloads = json_decode($row['downloads'], true);
|
||||||
|
|
||||||
|
$downloads = array_combine(
|
||||||
|
array_map(fn($k) => match($k) {
|
||||||
|
'windows-x86' => 'windows',
|
||||||
|
'windows-x64' => 'windows',
|
||||||
|
'linux-x64' => 'linux',
|
||||||
|
'macos-universal' => 'macos',
|
||||||
|
default => $k
|
||||||
|
}, array_keys($downloads)),
|
||||||
|
array_values($downloads)
|
||||||
|
);
|
||||||
|
|
||||||
|
$platforms = array_keys($downloads);
|
||||||
|
|
||||||
|
$downloadUrls = [];
|
||||||
|
foreach ($downloads as $platform => $fileId) {
|
||||||
|
$cdnStmt = $conn->prepare("SELECT path FROM cdnfiles WHERE id = ?");
|
||||||
|
$cdnStmt->bind_param("i", $fileId);
|
||||||
|
$cdnStmt->execute();
|
||||||
|
$cdnResult = $cdnStmt->get_result()->fetch_assoc();
|
||||||
|
$downloadUrls[] = $cdnResult ? "https://games-r2.lncvrt.xyz/" . $cdnResult['path'] : null;
|
||||||
|
$cdnStmt->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'id' => $row['id'],
|
||||||
|
'version' => $row['versionName'],
|
||||||
|
'displayName' => $row['versionName'],
|
||||||
|
'platforms' => $platforms,
|
||||||
|
'downloadUrls' => $downloadUrls,
|
||||||
|
'executables' => array_map(function($platform) use ($row) {
|
||||||
|
return match(true) {
|
||||||
|
in_array($platform, ['windows', 'windows-arm64']) => $row['place'] >= 16 ? 'Berry Dash.exe' : 'Foodie Dash.exe',
|
||||||
|
$platform === 'macos' => 'Berry Dash.app',
|
||||||
|
$platform === 'linux' => 'Berry Dash.x86_64',
|
||||||
|
in_array($platform, ['android', 'ios']) => null,
|
||||||
|
default => null
|
||||||
|
};
|
||||||
|
}, $platforms)
|
||||||
|
];
|
||||||
|
}, $result_versions->fetch_all(MYSQLI_ASSOC));
|
||||||
|
|
||||||
echo json_encode($versions);
|
echo json_encode($versions);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user