From 3d53ef07b61e2d5ddc8ec5e3b32980bf272b4407 Mon Sep 17 00:00:00 2001 From: "Lukas Rieger (Blue)" Date: Sat, 18 Nov 2023 22:01:01 +0100 Subject: [PATCH] Some small changes to make it work with mysql --- BlueMapCommon/webapp/public/sql.php | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/BlueMapCommon/webapp/public/sql.php b/BlueMapCommon/webapp/public/sql.php index 14ebeabb5..0a0e1e48f 100644 --- a/BlueMapCommon/webapp/public/sql.php +++ b/BlueMapCommon/webapp/public/sql.php @@ -2,9 +2,9 @@ // !!! SET YOUR SQL-CONNECTION SETTINGS HERE: !!! -$driver = 'mysql'; //PDO driver name, check the PDO documentation for available drivers at https://www.php.net/manual/en/pdo.drivers.php. Common ones are 'pgsql' or 'mysql'. +$driver = 'mysql'; // 'mysql' (MySQL) or 'pgsql' (PostgreSQL) $hostname = '127.0.0.1'; -$port = 3306; // Remember to change this value to match your database configuration +$port = 3306; $username = 'root'; $password = ''; $database = 'bluemap'; @@ -16,6 +16,11 @@ // !!! END - DONT CHANGE ANYTHING AFTER THIS LINE !!! + + + + + // some helper functions function error($code, $message = null) { global $path; @@ -84,6 +89,14 @@ function getMimeType($path) { return $mimeDefault; } +function send($data) { + if (is_resource($data)) { + fpassthru($data); + } else { + echo $data; + } +} + // determine relative request-path $root = dirname($_SERVER['PHP_SELF']); if ($root === "/" || $root === "\\") $root = ""; @@ -159,7 +172,7 @@ function getMimeType($path) { } else { header("Content-Type: image/png"); } - fpassthru($line["data"]); + send($line["data"]); exit; } @@ -187,9 +200,9 @@ function getMimeType($path) { $statement->execute(); if ($line = $statement->fetch()) { - header("Content-Type: ".getMimeType($mapPath)); - fpassthru($line["value"]); - exit; + header("Content-Type: ".getMimeType($mapPath)); + send($line["value"]); + exit; } } catch (PDOException $e) { error(500, "Failed to fetch data"); }