Add access.php - Users should make sure that ths is behind some sort of authentication...

This commit is contained in:
Klaus-Uwe Mitterer 2016-08-07 22:07:00 +02:00
parent d2a9dd41c3
commit 02d23237d4

51
access.php Normal file
View file

@ -0,0 +1,51 @@
<?php
include_once("config.php");
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT ts, lat, lon FROM tracker ORDER BY ts ASC;";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
header('Content-Type: application/vnd.google-earth.kml+xml');
header('Content-Disposition: attachment; filename="export.kml"');
echo '<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Style id="yellowPoly">
<LineStyle>
<color>7f00ffff</color>
<width>4</width>
</LineStyle>
<PolyStyle>
<color>7f00ff00</color>
</PolyStyle>
</Style>
<Placemark><styleUrl>#yellowPoly</styleUrl>
<LineString>
<extrude>1</extrude>
<tesselate>1</tesselate>
<altitudeMode>absolute</altitudeMode>
<coordinates>
';
while($row = $result->fetch_assoc()) {
echo $row["lon"] . "," . $row["lat"] . "\n";
}
echo '</coordinates>
</LineString></Placemark>
</Document></kml>';
} else {
die("No records found.");
}
$conn->close();
?>