Some small changes to make it work with mysql

This commit is contained in:
Lukas Rieger (Blue) 2023-11-18 22:01:01 +01:00
parent 97781a229b
commit 51f0c78102
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2
1 changed files with 19 additions and 6 deletions

View File

@ -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 @@ $hiresCompression = 'gzip';
// !!! 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 @@ if (startsWith($path, "/maps/")) {
} else {
header("Content-Type: image/png");
}
fpassthru($line["data"]);
send($line["data"]);
exit;
}
@ -187,9 +200,9 @@ if (startsWith($path, "/maps/")) {
$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"); }