I'm working on a project which requires integration of Google Maps with my website. Now, my data (latitude/longitude, etc) are in a MySQL table. A PHP query runs on the MySQL to dynamically generate an XML file. This XML file is then used by the requesting HTML page which then plots these points on the Google Map using JavaScript.
The HTML code snippet which requests this XML file is :
downloadUrl("generatexml.php", function(data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var name = markers[i].getAttribute("name");
var address = markers[i].getAttribute("address");
var type = markers[i].getAttribute("type");
var point = new google.maps.LatLng(
parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
var html = "<b>" + name + "</b> <br/>" + address;
var icon = customIcons[type] || {};
var marker = new google.maps.Marker({
map: map,
position: point,
icon: icon.icon
});
bindInfoWindow(marker, map, infoWindow, html);
}
});
The above mentioned function downloadUrl is defined as:
function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;
request.onreadystatechange = function() {
if (request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};
request.open('GET', url, true);
request.send(null);
}
Now, the problem is, suppose if someone directory types www.mydomain.com/generatexml.php
, then they will be able to see the XML file generated from MySQL data in his browser. This is something which can kill my website! Somebody can easily use my data and all my efforts of data collection will go waste. I'll be using this website for non-profit purposes, but somebody can steal this data via XML and sell it which I do not want to happen.
So, is there as way to hide this file and still the requesting HTML page is able to use it when anyone opens the HTML page?