Skip to content

Commit

Permalink
Fix sql.php problems
Browse files Browse the repository at this point in the history
  • Loading branch information
TBlueF committed Jun 3, 2024
1 parent 6392b67 commit 33d40b8
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions BlueMapCommon/webapp/public/sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
"bluemap:deflate" => "deflate",
"bluemap:zstd" => "zstd",
"bluemap:lz4" => "lz4"
]
];

// meta files
$metaFileKeys = [
"settings.json" => "bluemap:settings",
"textures.json" => "bluemap:textures",
"live/markers.json" => "bluemap:markers",
"live/players.json" => "bluemap:players",
]
];

// mime-types for meta-files
$mimeDefault = "application/octet-stream";
Expand Down Expand Up @@ -125,7 +125,7 @@ function send($data) {
$uriPath = $_SERVER['REQUEST_URI'];
$path = substr($uriPath, strlen($root));

// add /
// add /
if ($path === "") {
header("Location: $uriPath/");
exit;
Expand Down Expand Up @@ -157,14 +157,14 @@ function send($data) {
// parse tile-coordinates
preg_match_all("/tiles\/([\d\/]+)\/x(-?[\d\/]+)z(-?[\d\/]+).*/", $mapPath, $matches);
$lod = intval($matches[1][0]);
$storage = $lod === 0 ? "bluemap:hires" : "bluemap:lowres/".$lod
$storage = $lod === 0 ? "bluemap:hires" : "bluemap:lowres/".$lod;
$tileX = intval(str_replace("/", "", $matches[2][0]));
$tileZ = intval(str_replace("/", "", $matches[3][0]));

// query for tile
try {
$statement = $sql->prepare("
SELECT d.data, c.compression
SELECT d.data, c.key
FROM bluemap_grid_storage_data d
INNER JOIN bluemap_map m
ON d.map = m.id
Expand All @@ -181,7 +181,6 @@ function send($data) {
$statement->bindParam( ':storage', $storage, PDO::PARAM_STR );
$statement->bindParam( ':x', $tileX, PDO::PARAM_INT );
$statement->bindParam( ':z', $tileZ, PDO::PARAM_INT );
$statement->bindParam( ':compression', $compression, PDO::PARAM_STR );
$statement->setFetchMode(PDO::FETCH_ASSOC);
$statement->execute();

Expand All @@ -200,7 +199,7 @@ function send($data) {
exit;
}

} catch (PDOException $e) { error(500, "Failed to fetch data"); }
} catch (PDOException $e) { error(500, "Failed to fetch data"); }

// no content if nothing found
http_response_code(204);
Expand All @@ -215,7 +214,7 @@ function send($data) {
if ($storage !== null) {
try {
$statement = $sql->prepare("
SELECT d.data, c.compression
SELECT d.data, c.key
FROM bluemap_item_storage_data d
INNER JOIN bluemap_map m
ON d.map = m.id
Expand Down

0 comments on commit 33d40b8

Please sign in to comment.