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

@ -16,7 +16,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
// google maps
var map;
var polies = new Array();
@ -31,25 +31,25 @@ function init() {
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
}
}
mapOptions = {
center: new google.maps.LatLng(init_latitude,init_longitude),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP,
scaleControl: true
};
};
map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
}
function displayTrack(xml,update) {
altitudes.length = 0;
var totalMeters = 0;
var totalSeconds = 0;
// init polyline
var poly = new google.maps.Polyline(polyOptions);
poly.setMap(map);
var path = poly.getPath();
var latlngbounds = new google.maps.LatLngBounds( );
poly.setMap(map);
var path = poly.getPath();
var latlngbounds = new google.maps.LatLngBounds( );
var positions = xml.getElementsByTagName('position');
var posLen = positions.length;
for (var i=0; i<posLen; i++) {
@ -62,27 +62,27 @@ function displayTrack(xml,update) {
// set marker
setMarker(p,i,posLen);
// update polyline
path.push(p.coordinates);
path.push(p.coordinates);
latlngbounds.extend(p.coordinates);
// save altitudes for chart
altitudes[i] = p.altitude;
}
}
if (update) {
map.fitBounds(latlngbounds);
if (i==1) {
// only one point, zoom out
zListener =
zListener =
google.maps.event.addListenerOnce(map, 'bounds_changed', function(event) {
if (this.getZoom()){
this.setZoom(15);
}
});
setTimeout(function(){google.maps.event.removeListener(zListener)}, 2000);
setTimeout(function(){google.maps.event.removeListener(zListener)}, 2000);
}
}
latestTime = p.dateoccured;
polies.push(poly);
updateSummary(p.dateoccured,totalMeters,totalSeconds);
if (p.tid!=trackid) {
trackid=p.tid;
@ -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()+
@ -139,7 +139,7 @@ function setMarker(p,i,posLen) {
'<b>'+lang_aspeed+':</b> '+((p.totalSeconds>0)?((p.totalMeters/p.totalSeconds).toKmH()*factor_kmh).toFixed():0)+' '+unit_kmh+'<br />'+
'<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>';
'</div></div>';
popup = new google.maps.InfoWindow();
popup.listener = google.maps.event.addListener(marker, 'click', (function(marker,content) {
return function() {
@ -149,37 +149,37 @@ function setMarker(p,i,posLen) {
chart.setSelection([{row:i,column:null}]);
}
}
})(marker,content));
markers.push(marker);
popups.push(popup);
})(marker,content));
markers.push(marker);
popups.push(popup);
}
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 bounds = new google.maps.LatLngBounds(sw,ne);
map.fitBounds(bounds);
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);
}

View File

@ -16,70 +16,73 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
// openlayers
var map;
var layerTrack;
var layerMarkers;
var lineStyle = {strokeColor: '#FF0000', strokeOpacity: 1, strokeWidth: 2};
var lineStyle = {strokeColor: '#FF0000', strokeOpacity: 1, strokeWidth: 2};
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
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']);
if (layer_osmapa==1) {
// osmapa.pl
var osmapa = new OpenLayers.Layer.OSM('osmapa.pl',
['//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
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']);
if (layer_ump==1) {
// UMP
var ump = new OpenLayers.Layer.OSM('UMP',
['//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,21 +107,21 @@ 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) {
// only one point, zoom out
// only one point, zoom out
map.zoomOut();
}
}
latestTime = p.dateoccured;
//polies.push(poly);
updateSummary(p.dateoccured,totalMeters,totalSeconds);
if (p.tid!=trackid) {
trackid=p.tid;
@ -144,18 +147,18 @@ function setMarker(p,i,posLen) {
// marker
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); }
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);
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
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('//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
var content = '<div id="popup">'+
@ -171,49 +174,49 @@ function setMarker(p,i,posLen) {
'<b>'+lang_aspeed+':</b> '+((p.totalSeconds>0)?((p.totalMeters/p.totalSeconds).toKmH()*factor_kmh).toFixed():0)+' '+unit_kmh+'<br />'+
'<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}]);
}
}
})());
'</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}]);
}
}
})());
}
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;
@ -37,18 +37,18 @@ if ($require_authentication) {
session_name('trackme');
session_start();
$sid = session_id();
$auth = (isset($_SESSION['auth']) ? $_SESSION['auth'] : "");
$admin = (isset($_SESSION['admin']) ? $_SESSION['admin'] : "");
$user = (isset($_REQUEST['user']) ? $_REQUEST['user'] : "");
$pass = (isset($_REQUEST['pass']) ? md5($salt.$_REQUEST['pass']) : "");
$ssl = ((!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "" || $_SERVER['HTTPS'] == "off") ? "http" : "https");
$auth_error = (isset($_REQUEST['auth_error']) ? $_REQUEST['auth_error'] : 0);
// not authenticated and username not submited
// load form
if ((!$auth) && (!$user)){
print
if ((!$auth) && (!$user)){
print
'<!DOCTYPE html>
<html>
<head>
@ -92,13 +92,13 @@ if ($require_authentication) {
$query->free_result();
//correct pass
if (($user==$rec_user) && ($pass==$rec_pass)) {
if (($user==$rec_user) && ($pass==$rec_pass)) {
// login successful
//delete old session
$_SESSION = NULL;
session_destroy();
session_destroy();
// start new session
session_name('trackme');
session_name('trackme');
session_start();
if (($user==$admin_user) && ($admin_user != "")) {
$_SESSION['admin'] = $admin_user;
@ -106,7 +106,7 @@ if ($require_authentication) {
$_SESSION['auth'] = $rec_ID;
$url = str_replace("//", "/", $_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME'])."/index.php");
header("Location: $ssl://$url");
exit;
exit;
} else {
// unsuccessful
$error = "?auth_error=1";
@ -115,8 +115,8 @@ if ($require_authentication) {
if (isset($_COOKIE[session_name('trackme')])) {
setcookie(session_name('trackme'),'',time()-42000,'/');
}
session_destroy();
$mysqli->close();
session_destroy();
$mysqli->close();
$url = str_replace("//", "/", $_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME'])."/index.php");
header("Location: $ssl://$url$error");
exit;

View File

@ -17,9 +17,9 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
$version = "2.3";
$version = "2.3";
// default map drawing framework
// default map drawing framework
// (gmaps = google maps, openlayers = openlayers/osm)
//$mapapi = "gmaps";
$mapapi = "openlayers";
@ -50,7 +50,7 @@ $dbname = ""; // database name
$salt = ""; // fill in random string here, it will increase security of password hashes
// other
// require login/password authentication
// require login/password authentication
// (0 = no, 1 = yes)
$require_authentication = 1;
@ -58,12 +58,12 @@ $require_authentication = 1;
// none if empty
$admin_user = "";
// allow automatic registration of new users
// allow automatic registration of new users
// (0 = no, 1 = yes)
$allow_registration = 0;
// Default interval in seconds for live auto reload
$interval = 10;
$interval = 10;
// Default language
// (en, pl, de)

View File

@ -29,7 +29,7 @@ if ($units=="imperial") {
$unit_m = "ft";
$factor_km = 0.62; // to miles
$unit_km = "mi";
}
}
else {
$factor_kmh = 1;
$unit_kmh = "km/h";
@ -55,10 +55,10 @@ function addStyle($xml,$name,$url) {
$xml->startElement("IconStyle");
$xml->writeAttribute("id", $name."Icon");
$xml->startElement("Icon");
$xml->writeElement("href", $url);
$xml->endElement();
$xml->endElement();
$xml->endElement();
$xml->writeElement("href", $url);
$xml->endElement();
$xml->endElement();
$xml->endElement();
}
function toHMS($s) {
$d = floor($s/86400);
@ -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;
@ -113,12 +113,12 @@ if ($trackid>0 && $userid>0) {
$prev_dateoccured = $dateoccured;
$totalMeters += $distance;
$totalSeconds += $seconds;
if(++$i == $query->num_rows) { $style = "#greenStyle"; } // last element
$xml->startElement("Placemark");
$xml->writeAttribute("id", $positionid);
//$xml->writeElement("name", $i);
$description =
$description =
"<div style=\"font-weight: bolder;padding-bottom: 10px;border-bottom: 1px solid gray;\">".$lang_user.": ".strtoupper($username)."<br />".$lang_track.": ".strtoupper($trackname).
"</div>".
"<div>".
@ -138,7 +138,7 @@ if ($trackid>0 && $userid>0) {
$coordinate[$i] = $longitude.",".$latitude.(($altitude) ? ",".$altitude : "");
$xml->writeElement("coordinates", $coordinate[$i]);
$xml->endElement();
$xml->endElement();
$xml->endElement();
$style = "#grayStyle"; // other elements
}
$coordinates = implode("\n",$coordinate);
@ -147,16 +147,16 @@ if ($trackid>0 && $userid>0) {
$xml->startElement("LineString");
$xml->writeElement("coordinates", $coordinates);
$xml->endElement();
$xml->endElement();
$xml->endElement();
$xml->endElement();
$xml->endElement();
$xml->endDocument();
$xml->endDocument();
$xml->flush();
break;
case "gpx":
header("Content-type: application/application/gpx+xm");
header("Content-Disposition: attachment; filename=\"track$trackid.gpx\"");
@ -164,10 +164,10 @@ if ($trackid>0 && $userid>0) {
$xml->openURI("php://output");
$xml->startDocument("1.0");
$xml->startElement("gpx");
$xml->writeAttribute("xmlns", "http://www.topografix.com/GPX/1/1");
$xml->writeAttribute("xmlns:gpxdata", "http://www.cluetrust.com/XML/GPXDATA/1/0");
$xml->writeAttribute("creator", "phpTrackme");
$xml->writeAttribute("version", "1.1");
$xml->writeAttribute("xmlns", "http://www.topografix.com/GPX/1/1");
$xml->writeAttribute("xmlns:gpxdata", "http://www.cluetrust.com/XML/GPXDATA/1/0");
$xml->writeAttribute("creator", "phpTrackme");
$xml->writeAttribute("version", "1.1");
$xml->startElement("metadata");
$xml->writeElement("name", $trackname);
$xml->writeElement("time", str_replace(" ","T",$dateoccured));
@ -185,7 +185,7 @@ if ($trackid>0 && $userid>0) {
$seconds = (isset($prev_dateoccured))?(strtotime($dateoccured)-strtotime($prev_dateoccured)):0;
$prev_dateoccured = $dateoccured;
$totalMeters += $distance;
$totalSeconds += $seconds;
$totalSeconds += $seconds;
$xml->startElement("trkpt");
$xml->writeAttribute("lat", $latitude);
$xml->writeAttribute("lon", $longitude);
@ -193,7 +193,7 @@ if ($trackid>0 && $userid>0) {
$xml->writeElement("time", str_replace(" ","T",$dateoccured));
$xml->writeElement("name", ++$i);
$xml->startElement("desc");
$description =
$description =
$lang_user.": ".strtoupper($username)." ".$lang_track.": ".strtoupper($trackname).
" ".$lang_time.": ".$dateoccured.
(($speed)?" ".$lang_speed.": ".round($speed*3.6,2*$factor_kmh)." ".$unit_kmh:"").
@ -205,14 +205,14 @@ if ($trackid>0 && $userid>0) {
$xml->writeCData($description);
$xml->endElement();
$xml->endElement();
}
}
$xml->endElement();
$xml->endElement();
$xml->endElement();
$xml->endDocument();
$xml->flush();
break;
$xml->endDocument();
$xml->flush();
break;
}
$query->free_result();
$query->close();

View File

@ -42,7 +42,7 @@ if ($userid) {
else {
// get data only for latest point
$query = $mysqli->prepare("SELECT positions.ID,positions.Latitude,positions.Longitude,positions.Altitude,positions.Speed,positions.Angle,positions.DateOccurred,positions.Comments,users.username,trips.Name,trips.ID FROM positions LEFT JOIN users ON (positions.FK_Users_ID=users.ID) LEFT JOIN trips ON (positions.FK_Trips_ID=trips.ID) WHERE positions.FK_Users_ID=? ORDER BY positions.DateOccurred DESC LIMIT 1");
$query->bind_param('i', $userid);
$query->bind_param('i', $userid);
}
$query->execute();
$query->bind_result($positionid,$latitude,$longitude,$altitude,$speed,$angle,$dateoccured,$comments,$username,$trackname,$trackid);
@ -53,32 +53,32 @@ if ($userid) {
$xml->startDocument("1.0");
$xml->setIndent(true);
$xml->startElement('root');
while ($query->fetch()) {
$xml->startElement("position");
$xml->writeAttribute("id", $positionid);
$xml->writeElement("latitude", $latitude);
$xml->writeElement("longitude", $longitude);
$xml->writeElement("altitude", ($altitude)?round($altitude):$altitude);
$xml->writeElement("speed", $speed);
$xml->writeElement("angle", $angle);
$xml->writeElement("dateoccured", $dateoccured);
$xml->writeElement("comments", $comments);
$xml->writeElement("username", $username);
$xml->writeElement("trackid", $trackid);
$xml->writeElement("trackname", $trackname);
$xml->writeElement("latitude", $latitude);
$xml->writeElement("longitude", $longitude);
$xml->writeElement("altitude", ($altitude)?round($altitude):$altitude);
$xml->writeElement("speed", $speed);
$xml->writeElement("angle", $angle);
$xml->writeElement("dateoccured", $dateoccured);
$xml->writeElement("comments", $comments);
$xml->writeElement("username", $username);
$xml->writeElement("trackid", $trackid);
$xml->writeElement("trackname", $trackname);
$distance = (isset($prev_latitude))?haversine_distance($prev_latitude,$prev_longitude,$latitude,$longitude):0;
$prev_latitude = $latitude;
$prev_longitude = $longitude;
$xml->writeElement("distance", round($distance));
$xml->writeElement("distance", round($distance));
$seconds = (isset($prev_dateoccured))?(strtotime($dateoccured)-strtotime($prev_dateoccured)):0;
$prev_dateoccured = $dateoccured;
$xml->writeElement("seconds", $seconds);
$xml->endElement();
$xml->writeElement("seconds", $seconds);
$xml->endElement();
}
$xml->endElement();
$xml->endDocument();
$xml->endDocument();
$xml->flush();
$query->free_result();

View File

@ -33,16 +33,16 @@ if ($userid) {
$xml->startDocument("1.0");
$xml->setIndent(true);
$xml->startElement('root');
while ($query->fetch()) {
$xml->startElement("trip");
$xml->writeElement("trackid", $trackid);
$xml->writeElement("trackname", $trackname);
$xml->endElement();
$xml->writeElement("trackid", $trackid);
$xml->writeElement("trackname", $trackname);
$xml->endElement();
}
$xml->endElement();
$xml->endDocument();
$xml->endDocument();
$xml->flush();
$query->free_result();

View File

@ -22,14 +22,14 @@ require_once("auth.php");
if ($auth && !$admin) {
// get username
$query = "SELECT username FROM users WHERE ID='$auth' LIMIT 1";
$query = "SELECT username FROM users WHERE ID='$auth' LIMIT 1";
$result = $mysqli->query($query);
$row = $result->fetch_assoc();
$user = $row["username"];
// users
$user_form = '<u>'.$lang_user.'</u><br />'.$user.' (<a href="logout.php">'.$lang_logout.'</a>)';
}
}
else {
// free access or admin user
// prepare user select form
@ -40,12 +40,12 @@ else {
<u>'.$lang_user.'</u> ';
if ($auth) {
$user_form .= '&nbsp;'.$user.' (<a href="logout.php">'.$lang_logout.'</a>)';
}
}
$user_form .= '
<br />
<form>
<select name="user" onchange="selectUser(this)">
<option value="0">'.$lang_suser.'</option>';
<option value="0">'.$lang_suser.'</option>';
// get last position user
$query = "SELECT FK_Users_ID FROM positions ORDER BY DateOccurred LIMIT 1";
$result = $mysqli->query($query);
@ -55,10 +55,10 @@ else {
} else {
$last_id = "";
}
$query = "SELECT ID,username FROM users ORDER BY username";
$query = "SELECT ID,username FROM users ORDER BY username";
$result = $mysqli->query($query);
while ($row = $result->fetch_assoc()) {
$user_form .= sprintf("<option %svalue=\"%s\">%s</option>\n", ($row["ID"] == $last_id)?"selected ":"",$row["ID"], $row["username"]);
$user_form .= sprintf("<option %svalue=\"%s\">%s</option>\n", ($row["ID"] == $last_id)?"selected ":"",$row["ID"], $row["username"]);
}
$user_form .= '
</select>
@ -79,7 +79,7 @@ if ($auth && !$admin) {
// or user who did last move
$userid = $last_id;
}
$query = "SELECT * FROM trips WHERE FK_Users_ID='$userid' ORDER BY ID DESC";
$query = "SELECT * FROM trips WHERE FK_Users_ID='$userid' ORDER BY ID DESC";
$result = $mysqli->query($query);
$trackid = "";
@ -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>
';
@ -126,7 +125,7 @@ $units_form = '
</form>
';
print
print
'<!DOCTYPE html>
<html>
<head>
@ -164,14 +163,14 @@ print
<script type="text/javascript" src="main.js"></script>
';
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="api_gmaps.js"></script>
print
' <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>
';
}
@ -180,7 +179,7 @@ print '
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
</script>
</head>
<body onload="init();loadTrack(userid,trackid,1);">
<div id="menu">
@ -190,20 +189,20 @@ print '
</div>
<div id="trip">
'.$track_form.'
<input type="checkbox" onchange="autoReload();"> '.$lang_autoreload.' (<a href="javascript:void(0);" onclick="setTime()"><span id="auto">'.$interval.'</span></a> s)<br />
<input type="checkbox" onchange="autoReload();"> '.$lang_autoreload.' (<a href="javascript:void(0);" onclick="setTime()"><span id="auto">'.$interval.'</span></a> s)<br />
<a href="javascript:void(0);" onclick="loadTrack(userid,trackid,0)">'.$lang_reload.'</a><br />
</div>
<div id="summary"></div>
<div id="other">
<a href="javascript:void(0);" onclick="toggleChart();">'.$lang_chart.'</a>
</div>
<div id="api">
<div id="api">
'.$api_form.'
</div>
<div id="lang">
<div id="lang">
'.$lang_form.'
</div>
<div id="units">
<div id="units">
'.$units_form.'
</div>
<div id="export">
@ -220,7 +219,7 @@ print '
<div id="bottom">
<div id="chart"></div>
<div id="close"><a href="javascript:void(0);" onclick="toggleChart(0);">'.$lang_close.'</a></div>
</div>
</div>
</div>
</body>
</html>';

View File

@ -53,7 +53,7 @@ switch($lang) {
$lang_metric = "Metric";
$lang_imperial = "Imperial/US";
break;
case "pl":
$lang_title = "• phpTrackme •";
$lang_private = "Aby się zalogować musisz podać login i hasło";
@ -75,20 +75,20 @@ switch($lang) {
$lang_suser = "wybierz login";
$lang_point = "Punkt";
$lang_of = "z";
$lang_summary = "Podsumowanie";
$lang_summary = "Podsumowanie";
$lang_logout = "wyloguj";
$lang_login = "zaloguj";
$lang_username = "Login";
$lang_password = "Hasło";
$lang_language = "Język";
$lang_newinterval = "Podaj częstotliwość odświeżania (w sekundach)";
$lang_api = "Map API";
$lang_api = "Map API";
$lang_language = "Język";
$lang_units = "Jednostki";
$lang_metric = "Metryczne";
$lang_imperial = "Anglosaskie";
break;
case "de":
$lang_title = "• phpTrackme •";
$lang_private = "Sie müssen Benutzernamen und Kennwort eingeben, um auf diese Seite zuzugreifen.";
@ -122,7 +122,7 @@ switch($lang) {
$lang_units = "Maßsystem";
$lang_metric = "Metrisches";
$lang_imperial = "Angloamerikanisches";
break;
break;
case "hu":
$lang_title = "• phpTrackme •";
@ -145,14 +145,14 @@ switch($lang) {
$lang_suser = "Felhasználónév";
$lang_point = "Rögzített pontok száma";
$lang_of = "/";
$lang_summary = "Utazás adatai";
$lang_summary = "Utazás adatai";
$lang_logout = "Kilépés";
$lang_login = "Belépés";
$lang_username = "Felhasználó";
$lang_password = "Jelszó";
$lang_language = "Nyelv";
$lang_newinterval = "Automatikus frissítés ideje (másodpercben)";
$lang_api = "Map API";
$lang_api = "Map API";
$lang_language = "Nyelv";
$lang_units = "Mértékegység";
$lang_metric = "Metrikus";

View File

@ -23,7 +23,7 @@ $_SESSION = NULL;
if (isset($_COOKIE[session_name('trackme')])) {
setcookie(session_name('trackme'),'',time()-42000,'/');
}
session_destroy();
session_destroy();
$ssl = ((!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "" || $_SERVER['HTTPS'] == "off") ? "http" : "https");
$url = str_replace("//", "/", $_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME'])."/index.php");
header("Location: $ssl://$url");

View File

@ -78,7 +78,7 @@ select {
position: fixed;
width: 165px;
bottom:0;
padding: 10px;
padding: 10px;
background-color:rgba(102, 102, 102, 0.9);
color: lightgray;
}
@ -103,7 +103,7 @@ select {
padding-bottom: 10px;
}
#login {
font-family: Verdana, sans-serif;
font-family: Verdana, sans-serif;
position: relative;
top: 10%;
background-color: #444;
@ -141,7 +141,7 @@ select {
border-bottom: 1px solid gray;
}
#pcomments {
clear: both;
clear: both;
color: #903;
}
#pleft,#pright {
@ -161,8 +161,8 @@ select {
position: absolute;
z-index: 10000;
}
#chart {
position: fixed;
#chart {
position: fixed;
bottom: 0; left:0; right: 0;
height: 200px;
margin-right: 165px;

148
main.js
View File

@ -16,7 +16,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
// general stuff
if (units=='imperial') {
factor_kmh = 0.62; //to mph
@ -25,7 +25,7 @@ if (units=='imperial') {
unit_m = 'ft';
factor_km = 0.62; // to miles
unit_km = 'mi';
}
}
else {
factor_kmh = 1;
unit_kmh = 'km/h';
@ -58,18 +58,18 @@ function displayChart() {
chart = new google.visualization.LineChart(document.getElementById('chart'));
chart.draw(data, options);
addChartEvent(chart);
}
function toggleChart(i) {
var altLen = altitudes.length;
if (altLen<=1) { return; }
if (altLen<=1) { return; }
var e = document.getElementById('bottom');
if (arguments.length < 1) {
if (e.style.display == 'block') { i = 0 }
else { i = 1; }
}
}
if (i==0) {
chart.clearChart();
e.style.display = 'none';
@ -80,14 +80,14 @@ function toggleChart(i) {
}
}
function toggleMenu(i) {
function toggleMenu(i) {
var emenu = document.getElementById('menu');
var emain = document.getElementById('main');
var ebutton = document.getElementById('menu-close');
if (arguments.length < 1) {
if (ebutton.innerHTML == '»') { i = 0 }
else { i = 1; }
}
}
if (i==0) {
emenu.style.width = '0';
emain.style.marginRight = '0';
@ -99,7 +99,7 @@ function toggleMenu(i) {
emain.style.marginRight = '165px';
ebutton.style.right = '165px';
ebutton.innerHTML = '»';
}
}
}
function getXHR() {
@ -120,8 +120,8 @@ function loadTrack(userid,trackid,update) {
if (xhr.readyState==4 && xhr.status==200) {
var xml = xhr.responseXML;
var positions = xml.getElementsByTagName('position');
if (positions.length>0) {
clearMap();
if (positions.length>0) {
clearMap();
displayTrack(xml,update);
}
xhr = null;
@ -161,7 +161,7 @@ function parsePosition(p) {
'dateoccured': dateoccured,
'distance': distance,
'seconds': seconds
};
};
}
function load(type,userid,trackid) {
@ -246,7 +246,7 @@ function getTrips(userid) {
var trackSelect = document.getElementsByName('track')[0];
clearOptions(trackSelect);
var trips = xml.getElementsByTagName('trip');
if (trips.length>0) {
if (trips.length>0) {
fillOptions(xml);
} else {
clearMap();
@ -255,7 +255,7 @@ function getTrips(userid) {
}
}
xhr.open('GET','gettrips.php?userid='+userid,true);
xhr.send();
xhr.send();
}
function fillOptions(xml) {
@ -269,7 +269,7 @@ function fillOptions(xml) {
option.value = trackid;
option.innerHTML = trackname;
trackSelect.appendChild(option);
}
}
var defaultTrack = getNode(trips[0],'trackid');
loadTrack(userid,defaultTrack,1);
}
@ -300,94 +300,94 @@ function setTime() {
interval = i;
document.getElementById('auto').innerHTML = interval;
// if live tracking on, reload with new interval
if (live==1) {
if (live==1) {
live = 0;
clearInterval(auto);
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 {
var expires = '';
}
document.cookie = 'phpTrackme_'+name+'='+value+expires+'; path=/';
}
else {
var expires = '';
}
document.cookie = 'phpTrackme_'+name+'='+value+expires+'; path=/';
}
function setLang(lang) {

View File

@ -1,8 +1,8 @@
--
--
-- Database layout inherited from TrackMe
-- Some tables/columns are not used by the viewer at the moment.
-- Kept for compatibility with old data.
--
--
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";