Skip to content

Commit

Permalink
Some small changes to make it work with mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
TBlueF committed Nov 18, 2023
1 parent 37feb5d commit 3d53ef0
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions BlueMapCommon/webapp/public/sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -16,6 +16,11 @@
// !!! END - DONT CHANGE ANYTHING AFTER THIS LINE !!!







// some helper functions
function error($code, $message = null) {
global $path;
Expand Down Expand Up @@ -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 = "";
Expand Down Expand Up @@ -159,7 +172,7 @@ function getMimeType($path) {
} else {
header("Content-Type: image/png");
}
fpassthru($line["data"]);
send($line["data"]);
exit;
}

Expand Down Expand Up @@ -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"); }

Expand Down

0 comments on commit 3d53ef0

Please sign in to comment.