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

View File

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

View File

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

View File

@ -111,7 +111,6 @@ $lang_form = '
<option value="en"'.(($lang=="en")?' selected':'').'>English</option> <option value="en"'.(($lang=="en")?' selected':'').'>English</option>
<option value="pl"'.(($lang=="pl")?' selected':'').'>Polski</option> <option value="pl"'.(($lang=="pl")?' selected':'').'>Polski</option>
<option value="de"'.(($lang=="de")?' selected':'').'>Deutsch</option> <option value="de"'.(($lang=="de")?' selected':'').'>Deutsch</option>
<option value="hu"'.(($lang=="hu")?' selected':'').'>Magyar</option>
</select> </select>
</form> </form>
'; ';
@ -165,13 +164,13 @@ print
'; ';
if ($mapapi == "gmaps") { if ($mapapi == "gmaps") {
print 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> <script type="text/javascript" src="api_gmaps.js"></script>
'; ';
} }
else { else {
print 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> <script type="text/javascript" src="api_openlayers.js"></script>
'; ';
} }

114
main.js
View File

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