Fix: some resources were insecure when using ssl

This commit is contained in:
Bartek Fabiszewski 2016-10-29 14:05:13 +02:00
parent 1fce3f8718
commit 70eecac6be
13 changed files with 315 additions and 313 deletions

View File

@ -121,10 +121,10 @@ function setMarker(p,i,posLen) {
position: p.coordinates,
title: p.dateoccured
});
if (latest==1) { marker.setIcon('http://maps.google.com/mapfiles/dd-end.png') }
else if (i==0) { marker.setIcon('http://maps.google.com/mapfiles/marker_greenA.png') }
else if (i==posLen-1) { marker.setIcon('http://maps.google.com/mapfiles/markerB.png') }
else { marker.setIcon('http://labs.google.com/ridefinder/images/mm_20_gray.png') }
if (latest==1) { marker.setIcon('//maps.google.com/mapfiles/dd-end.png') }
else if (i==0) { marker.setIcon('//maps.google.com/mapfiles/marker_greenA.png') }
else if (i==posLen-1) { marker.setIcon('//maps.google.com/mapfiles/markerB.png') }
else { marker.setIcon('//maps.gstatic.com/mapfiles/ridefinder-images/mm_20_gray.png') }
// popup
var content = '<div id="popup">'+
'<div id="pheader">'+lang_user+': '+p.username.toUpperCase()+'<br />'+lang_track+': '+p.trackname.toUpperCase()+
@ -155,31 +155,31 @@ function setMarker(p,i,posLen) {
}
function addChartEvent(chart) {
google.visualization.events.addListener(chart, 'select', function() {
if (popup) {popup.close(); clearTimeout(altTimeout);}
var selection = chart.getSelection()[0];
if (selection) {
var id = selection.row;
var icon = markers[id].getIcon();
markers[id].setIcon('http://maps.google.com/mapfiles/marker_orange.png');
altTimeout = setTimeout(function() { markers[id].setIcon(icon); },2000);
}
});
google.visualization.events.addListener(chart, 'select', function() {
if (popup) {popup.close(); clearTimeout(altTimeout);}
var selection = chart.getSelection()[0];
if (selection) {
var id = selection.row;
var icon = markers[id].getIcon();
markers[id].setIcon('//maps.google.com/mapfiles/marker_orange.png');
altTimeout = setTimeout(function() { markers[id].setIcon(icon); },2000);
}
});
}
//((52.20105108685229, 20.789387865580238), (52.292069558807135, 21.172192736185707))
function getBounds() {
var b = map.getBounds().toString();
var bounds = b.split(',',4);
var lat_sw = bounds[0].replace(/\(/g,'');
var lon_sw = bounds[1].replace(/[ )]/g,'');
var lat_ne = bounds[2].replace(/[ (]/g,'');
var lon_ne = bounds[3].replace(/[ )]/g,'');
return [lon_sw,lat_sw,lon_ne,lat_ne];
var b = map.getBounds().toString();
var bounds = b.split(',',4);
var lat_sw = bounds[0].replace(/\(/g,'');
var lon_sw = bounds[1].replace(/[ )]/g,'');
var lat_ne = bounds[2].replace(/[ (]/g,'');
var lon_ne = bounds[3].replace(/[ )]/g,'');
return [lon_sw,lat_sw,lon_ne,lat_ne];
}
function zoomToBounds(b) {
var sw = new google.maps.LatLng(b[1],b[0]);
var ne = new google.maps.LatLng(b[3],b[2]);
var sw = new google.maps.LatLng(b[1],b[0]);
var ne = new google.maps.LatLng(b[3],b[2]);
var bounds = new google.maps.LatLngBounds(sw,ne);
map.fitBounds(bounds);
map.fitBounds(bounds);
}

View File

@ -26,60 +26,63 @@ var wgs84;
var mercator;
var loadedAPI = 'openlayers';
function init() {
wgs84 = new OpenLayers.Projection('EPSG:4326'); // from WGS 1984
mercator = new OpenLayers.Projection('EPSG:900913'); // to Mercator
var options = { controls: [
new OpenLayers.Control.ArgParser(), // default
new OpenLayers.Control.Attribution(), // default
new OpenLayers.Control.LayerSwitcher(),
new OpenLayers.Control.Navigation(), // default
new OpenLayers.Control.PanZoomBar(),// do we need it?
new OpenLayers.Control.ScaleLine()
]
};
map = new OpenLayers.Map('map-canvas', options);
// default layer: OpenStreetMap
var mapnik = new OpenLayers.Layer.OSM();
map.addLayer(mapnik);
if (layer_ocm==1) {
// OpenCycleMap
wgs84 = new OpenLayers.Projection('EPSG:4326'); // from WGS 1984
mercator = new OpenLayers.Projection('EPSG:900913'); // to Mercator
var options = { controls: [
new OpenLayers.Control.ArgParser(), // default
new OpenLayers.Control.Attribution(), // default
new OpenLayers.Control.LayerSwitcher(),
new OpenLayers.Control.Navigation(), // default
new OpenLayers.Control.PanZoomBar(),// do we need it?
new OpenLayers.Control.ScaleLine()
]
};
map = new OpenLayers.Map('map-canvas', options);
// default layer: OpenStreetMap
var mapnik = new OpenLayers.Layer.OSM('OpenStreetMap',
['//a.tile.openstreetmap.org/${z}/${x}/${y}.png',
'//b.tile.openstreetmap.org/${z}/${x}/${y}.png',
'//c.tile.openstreetmap.org/${z}/${x}/${y}.png']);
map.addLayer(mapnik);
if (layer_ocm==1) {
// OpenCycleMap
var ocm = new OpenLayers.Layer.OSM('OpenCycleMap',
['http://a.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png',
'http://b.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png',
'http://c.tile.opencyclemap.org/cycle/${z}/${x}/${y}.png']);
['//a.tile.thunderforest.com/cycle/${z}/${x}/${y}.png',
'//b.tile.thunderforest.com/cycle/${z}/${x}/${y}.png',
'//c.tile.thunderforest.com/cycle/${z}/${x}/${y}.png']);
map.addLayer(ocm);
}
if (layer_mq==1) {
// MapQuest-OSM
if (layer_mq==1) {
// MapQuest-OSM
var mq = new OpenLayers.Layer.OSM('MapQuest-OSM',
['http://otile1.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg',
'http://otile2.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg',
'http://otile3.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg',
'http://otile4.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg']);
['//otile1.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg',
'//otile2.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg',
'//otile3.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg',
'//otile4.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg']);
map.addLayer(mq);
}
if (layer_osmapa==1) {
// osmapa.pl
if (layer_osmapa==1) {
// osmapa.pl
var osmapa = new OpenLayers.Layer.OSM('osmapa.pl',
['http://a.osm.trail.pl/osmapa.pl/${z}/${x}/${y}.png',
'http://b.osm.trail.pl/osmapa.pl/${z}/${x}/${y}.png',
'http://c.osm.trail.pl/osmapa.pl/${z}/${x}/${y}.png']);
['//a.osm.trail.pl/osmapa.pl/${z}/${x}/${y}.png',
'//b.osm.trail.pl/osmapa.pl/${z}/${x}/${y}.png',
'//c.osm.trail.pl/osmapa.pl/${z}/${x}/${y}.png']);
map.addLayer(osmapa);
}
if (layer_ump==1) {
// UMP
if (layer_ump==1) {
// UMP
var ump = new OpenLayers.Layer.OSM('UMP',
['http://1.tiles.ump.waw.pl/ump_tiles/${z}/${x}/${y}.png',
'http://2.tiles.ump.waw.pl/ump_tiles/${z}/${x}/${y}.png',
'http://3.tiles.ump.waw.pl/ump_tiles/${z}/${x}/${y}.png']);
['//1.tiles.ump.waw.pl/ump_tiles/${z}/${x}/${y}.png',
'//2.tiles.ump.waw.pl/ump_tiles/${z}/${x}/${y}.png',
'//3.tiles.ump.waw.pl/ump_tiles/${z}/${x}/${y}.png']);
map.addLayer(ump);
}
var position = new OpenLayers.LonLat(init_longitude,init_latitude).transform(wgs84, mercator);
var zoom = 8;
map.setCenter(position, zoom);
var zoom = 8;
map.setCenter(position, zoom);
// init layers
layerTrack = new OpenLayers.Layer.Vector('Track');
layerMarkers = new OpenLayers.Layer.Markers('Markers');
layerMarkers = new OpenLayers.Layer.Markers('Markers');
}
function displayTrack(xml,update) {
altitudes.length = 0;
@ -104,11 +107,11 @@ function displayTrack(xml,update) {
// save altitudes for chart
altitudes[i] = p.altitude;
}
var lineString = new OpenLayers.Geometry.LineString(points);
var lineFeature = new OpenLayers.Feature.Vector(lineString, null, lineStyle);
layerTrack.addFeatures([lineFeature]);
map.addLayer(layerTrack);
map.addLayer(layerMarkers);
var lineString = new OpenLayers.Geometry.LineString(points);
var lineFeature = new OpenLayers.Feature.Vector(lineString, null, lineStyle);
layerTrack.addFeatures([lineFeature]);
map.addLayer(layerTrack);
map.addLayer(layerMarkers);
if (update) {
map.zoomToExtent(latlngbounds);
if (i==1) {
@ -145,16 +148,16 @@ function setMarker(p,i,posLen) {
var lonLat = new OpenLayers.LonLat(p.longitude,p.latitude).transform(wgs84,mercator);
var size = new OpenLayers.Size(21, 25);
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
if (latest==1) { var icon = new OpenLayers.Icon('http://www.openstreetmap.org/openlayers/img/marker.png',size,offset); }
else if (i==0) { var icon = new OpenLayers.Icon('http://www.openstreetmap.org/openlayers/img/marker-green.png',size,offset); }
else if (i==posLen-1) { var icon = new OpenLayers.Icon('http://www.openstreetmap.org/openlayers/img/marker.png',size,offset); }
if (latest==1) { var icon = new OpenLayers.Icon('//www.openstreetmap.org/openlayers/img/marker.png',size,offset); }
else if (i==0) { var icon = new OpenLayers.Icon('//www.openstreetmap.org/openlayers/img/marker-green.png',size,offset); }
else if (i==posLen-1) { var icon = new OpenLayers.Icon('//www.openstreetmap.org/openlayers/img/marker.png',size,offset); }
else {
size = new OpenLayers.Size(12, 20);
offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
var icon = new OpenLayers.Icon('http://labs.google.com/ridefinder/images/mm_20_gray.png',size,offset);
size = new OpenLayers.Size(12, 20);
offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
var icon = new OpenLayers.Icon('//maps.gstatic.com/mapfiles/ridefinder-images/mm_20_gray.png',size,offset);
}
var marker = new OpenLayers.Marker(lonLat,icon);
layerMarkers.addMarker(marker);
layerMarkers.addMarker(marker);
// popup
@ -172,48 +175,48 @@ function setMarker(p,i,posLen) {
'<b>'+lang_tdistance+':</b> '+(p.totalMeters.toKm()*factor_km).toFixed(2)+' '+unit_km+'<br />'+'</div>'):'')+
'<div id="pfooter">'+lang_point+' '+(i+1)+' '+lang_of+' '+(posLen)+'</div>'+
'</div></div>';
marker.events.register("mousedown", marker, (function() {
return function() {
// remove popups
if (map.popups.length>0) {
for (var j = map.popups.length-1; j>=0; j-- ) {
map.removePopup(map.popups[j])
};
}
// show popup
var popup = new OpenLayers.Popup.FramedCloud("id "+(i+1),lonLat,null,content,icon,true);
map.addPopup(popup);
if (document.getElementById('bottom').style.display=='block') {
chart.setSelection([{row:i,column:null}]);
}
}
marker.events.register("mousedown", marker, (function() {
return function() {
// remove popups
if (map.popups.length>0) {
for (var j = map.popups.length-1; j>=0; j-- ) {
map.removePopup(map.popups[j])
};
}
// show popup
var popup = new OpenLayers.Popup.FramedCloud("id "+(i+1),lonLat,null,content,icon,true);
map.addPopup(popup);
if (document.getElementById('bottom').style.display=='block') {
chart.setSelection([{row:i,column:null}]);
}
}
})());
}
function addChartEvent(chart) {
google.visualization.events.addListener(chart, 'select', function() {
var selection = chart.getSelection()[0];
if (selection) {
var id = selection.row;
var marker = layerMarkers.markers[id];
var url = marker.icon.url;
marker.setUrl('http://www.openstreetmap.org/openlayers/img/marker-gold.png');
altTimeout = setTimeout(function() { marker.setUrl(url); },2000);
}
});
google.visualization.events.addListener(chart, 'select', function() {
var selection = chart.getSelection()[0];
if (selection) {
var id = selection.row;
var marker = layerMarkers.markers[id];
var url = marker.icon.url;
marker.setUrl('//www.openstreetmap.org/openlayers/img/marker-gold.png');
altTimeout = setTimeout(function() { marker.setUrl(url); },2000);
}
});
}
//20.597985430276808,52.15547181298076,21.363595171488573,52.33750879522563
function getBounds() {
var b = map.getExtent().transform(mercator,wgs84).toString();
var bounds = b.split(',',4);
var lon_sw = bounds[0];
var lat_sw = bounds[1];
var lon_ne = bounds[2];
var lat_ne = bounds[3];
return [lon_sw,lat_sw,lon_ne,lat_ne];
var b = map.getExtent().transform(mercator,wgs84).toString();
var bounds = b.split(',',4);
var lon_sw = bounds[0];
var lat_sw = bounds[1];
var lon_ne = bounds[2];
var lat_ne = bounds[3];
return [lon_sw,lat_sw,lon_ne,lat_ne];
}
function zoomToBounds(b) {
var bounds = new OpenLayers.Bounds(b).transform(wgs84,mercator);
map.zoomToExtent(bounds);
var bounds = new OpenLayers.Bounds(b).transform(wgs84,mercator);
map.zoomToExtent(bounds);
}

View File

@ -26,8 +26,8 @@ if (isset($_COOKIE["phpTrackme_interval"])) { $interval = $_COOKIE["phpTrackme_i
require_once("lang.php");
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
$mysqli->set_charset("utf8");
$auth = NULL;

View File

@ -100,7 +100,7 @@ if ($trackid>0 && $userid>0) {
// marker styles
addStyle($xml,"red","http://maps.google.com/mapfiles/markerA.png");
addStyle($xml,"green","http://maps.google.com/mapfiles/marker_greenB.png");
addStyle($xml,"gray","http://labs.google.com/ridefinder/images/mm_20_gray.png");
addStyle($xml,"gray","http://maps.gstatic.com/mapfiles/ridefinder-images/mm_20_gray.png");
$style = "#redStyle"; // for first element
$i = 0;
$totalMeters = 0;

View File

@ -111,7 +111,6 @@ $lang_form = '
<option value="en"'.(($lang=="en")?' selected':'').'>English</option>
<option value="pl"'.(($lang=="pl")?' selected':'').'>Polski</option>
<option value="de"'.(($lang=="de")?' selected':'').'>Deutsch</option>
<option value="hu"'.(($lang=="hu")?' selected':'').'>Magyar</option>
</select>
</form>
';
@ -165,13 +164,13 @@ print
';
if ($mapapi == "gmaps") {
print
' <script type="text/javascript" src="//maps.googleapis.com/maps/api/js?'.(isset($gkey)?'key='.$gkey.'&':'').'sensor=false"></script>
' <script type="text/javascript" src="//maps.googleapis.com/maps/api/js'.(isset($gkey)?'?key='.$gkey:'').'"></script>
<script type="text/javascript" src="api_gmaps.js"></script>
';
}
else {
print
' <script type="text/javascript" src="http://openlayers.org/api/OpenLayers.js"></script>
' <script type="text/javascript" src="//openlayers.org/api/OpenLayers.js"></script>
<script type="text/javascript" src="api_openlayers.js"></script>
';
}

114
main.js
View File

@ -306,88 +306,88 @@ function setTime() {
autoReload();
}
// save current state as default
setCookie('interval',interval,30);
setCookie('interval',interval,30);
}
}
// dynamic change of map api
var savedBounds;
function loadMapAPI(api) {
savedBounds = getBounds();
document.getElementById("map-canvas").innerHTML = '';
var url = new Array();
if (api=='gmaps') {
url.push('api_gmaps.js');
url.push('//maps.googleapis.com/maps/api/js?'+((gkey!==null)?('key='+gkey+'&'):'')+'sensor=false&callback=init');
}
else {
url.push('api_openlayers.js');
url.push('http://openlayers.org/api/OpenLayers.js');
}
addScript(url[0]);
waitAndLoad(api,url);
savedBounds = getBounds();
document.getElementById("map-canvas").innerHTML = '';
var url = new Array();
if (api=='gmaps') {
url.push('api_gmaps.js');
url.push('//maps.googleapis.com/maps/api/js?'+((gkey!==null)?('key='+gkey+'&'):'')+'callback=init');
}
else {
url.push('api_openlayers.js');
url.push('//openlayers.org/api/OpenLayers.js');
}
addScript(url[0]);
waitAndLoad(api,url);
}
var loadTime = 0;
function waitAndLoad(api,url) {
// wait till first script loaded
if (loadTime>5000) { loadTime = 0; alert('Sorry, can\'t load '+api+' API'); return; }
if (loadedAPI!==api) {
setTimeout(function() { loadTime += 50; waitAndLoad(api,url); }, 50);
return;
}
if(!isScriptLoaded(url[1])){
addScript(url[1]);
}
loadTime = 0;
waitAndInit(api);
// wait till first script loaded
if (loadTime>5000) { loadTime = 0; alert('Sorry, can\'t load '+api+' API'); return; }
if (loadedAPI!==api) {
setTimeout(function() { loadTime += 50; waitAndLoad(api,url); }, 50);
return;
}
if(!isScriptLoaded(url[1])){
addScript(url[1]);
}
loadTime = 0;
waitAndInit(api);
}
function waitAndInit(api) {
// wait till main api loads
if (loadTime>10000) { loadTime = 0; alert('Sorry, can\'t load '+api+' API'); return; }
try {
init();
}
catch(e) {
setTimeout(function() { loadTime += 50; waitAndInit(api); }, 50);
return;
}
loadTime = 0;
zoomToBounds(savedBounds);
loadTrack(userid,trackid,0);
// save current api as default
setCookie('api',api,30);
// wait till main api loads
if (loadTime>10000) { loadTime = 0; alert('Sorry, can\'t load '+api+' API'); return; }
try {
init();
}
catch(e) {
setTimeout(function() { loadTime += 50; waitAndInit(api); }, 50);
return;
}
loadTime = 0;
zoomToBounds(savedBounds);
loadTrack(userid,trackid,0);
// save current api as default
setCookie('api',api,30);
}
function addScript(url) {
var tag = document.createElement('script');
tag.setAttribute('type','text/javascript');
tag.setAttribute('src', url);
if (typeof tag!='undefined') {
document.getElementsByTagName('head')[0].appendChild(tag);
}
var tag = document.createElement('script');
tag.setAttribute('type','text/javascript');
tag.setAttribute('src', url);
if (typeof tag!='undefined') {
document.getElementsByTagName('head')[0].appendChild(tag);
}
}
function isScriptLoaded(url) {
scripts = document.getElementsByTagName('script');
for (var i = scripts.length; i--;) {
// check if url matches src
var scriptUrl = scripts[i].src.replace(/https?:/,'');
if (scriptUrl != '' && url.indexOf(scriptUrl) !== -1) return true;
}
return false;
scripts = document.getElementsByTagName('script');
for (var i = scripts.length; i--;) {
// check if url matches src
var scriptUrl = scripts[i].src.replace(/https?:/,'');
if (scriptUrl != '' && url.indexOf(scriptUrl) !== -1) return true;
}
return false;
}
function setCookie(name,value,days) {
if (days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = '; expires='+date.toGMTString();
}
else {
}
else {
var expires = '';
}
document.cookie = 'phpTrackme_'+name+'='+value+expires+'; path=/';
}
document.cookie = 'phpTrackme_'+name+'='+value+expires+'; path=/';
}
function setLang(lang) {