Update phpdoc, minor formatting
This commit is contained in:
parent
4c4ca498ca
commit
c46486396c
@ -16,10 +16,10 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once("auth.php"); // sets $mysqli, $user
|
require_once("auth.php"); // sets $mysqli, $user
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exit with xml response
|
* Exit with xml response
|
||||||
* @param boolean $isError Error if true
|
* @param boolean $isError Error if true
|
||||||
* @param string $errorMessage Optional error message
|
* @param string $errorMessage Optional error message
|
||||||
|
6
admin.js
6
admin.js
@ -40,12 +40,12 @@ function submitUser() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var xhr = getXHR();
|
var xhr = getXHR();
|
||||||
xhr.onreadystatechange = function() {
|
xhr.onreadystatechange = function () {
|
||||||
if (xhr.readyState==4 && xhr.status==200) {
|
if (xhr.readyState == 4 && xhr.status == 200) {
|
||||||
var xml = xhr.responseXML;
|
var xml = xhr.responseXML;
|
||||||
var message = "";
|
var message = "";
|
||||||
if (xml) {
|
if (xml) {
|
||||||
var root = xml.getElementsByTagName('root');
|
var root = xml.getElementsByTagName('root');
|
||||||
if (root.length && getNode(root[0], 'error') == 0) {
|
if (root.length && getNode(root[0], 'error') == 0) {
|
||||||
removeModal();
|
removeModal();
|
||||||
alert("User successfully added");
|
alert("User successfully added");
|
||||||
|
92
api_gmaps.js
92
api_gmaps.js
@ -24,6 +24,7 @@ var popups = new Array();
|
|||||||
var polyOptions;
|
var polyOptions;
|
||||||
var mapOptions;
|
var mapOptions;
|
||||||
var loadedAPI = 'gmaps';
|
var loadedAPI = 'gmaps';
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
google.maps.visualRefresh = true;
|
google.maps.visualRefresh = true;
|
||||||
polyOptions = {
|
polyOptions = {
|
||||||
@ -32,7 +33,7 @@ function init() {
|
|||||||
strokeWeight: 2
|
strokeWeight: 2
|
||||||
}
|
}
|
||||||
mapOptions = {
|
mapOptions = {
|
||||||
center: new google.maps.LatLng(init_latitude,init_longitude),
|
center: new google.maps.LatLng(init_latitude, init_longitude),
|
||||||
zoom: 8,
|
zoom: 8,
|
||||||
mapTypeId: google.maps.MapTypeId.ROADMAP,
|
mapTypeId: google.maps.MapTypeId.ROADMAP,
|
||||||
scaleControl: true
|
scaleControl: true
|
||||||
@ -40,7 +41,7 @@ function init() {
|
|||||||
map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
|
map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayTrack(xml,update) {
|
function displayTrack(xml, update) {
|
||||||
altitudes.length = 0;
|
altitudes.length = 0;
|
||||||
var totalMeters = 0;
|
var totalMeters = 0;
|
||||||
var totalSeconds = 0;
|
var totalSeconds = 0;
|
||||||
@ -48,18 +49,18 @@ function displayTrack(xml,update) {
|
|||||||
var poly = new google.maps.Polyline(polyOptions);
|
var poly = new google.maps.Polyline(polyOptions);
|
||||||
poly.setMap(map);
|
poly.setMap(map);
|
||||||
var path = poly.getPath();
|
var path = poly.getPath();
|
||||||
var latlngbounds = new google.maps.LatLngBounds( );
|
var latlngbounds = new google.maps.LatLngBounds();
|
||||||
var positions = xml.getElementsByTagName('position');
|
var positions = xml.getElementsByTagName('position');
|
||||||
var posLen = positions.length;
|
var posLen = positions.length;
|
||||||
for (var i=0; i<posLen; i++) {
|
for (var i = 0; i < posLen; i++) {
|
||||||
var p = parsePosition(positions[i]);
|
var p = parsePosition(positions[i]);
|
||||||
totalMeters += p.distance;
|
totalMeters += p.distance;
|
||||||
totalSeconds += p.seconds;
|
totalSeconds += p.seconds;
|
||||||
p['totalMeters'] = totalMeters;
|
p['totalMeters'] = totalMeters;
|
||||||
p['totalSeconds'] = totalSeconds;
|
p['totalSeconds'] = totalSeconds;
|
||||||
p['coordinates'] = new google.maps.LatLng(p.latitude,p.longitude);
|
p['coordinates'] = new google.maps.LatLng(p.latitude, p.longitude);
|
||||||
// set marker
|
// set marker
|
||||||
setMarker(p,i,posLen);
|
setMarker(p, i, posLen);
|
||||||
// update polyline
|
// update polyline
|
||||||
path.push(p.coordinates);
|
path.push(p.coordinates);
|
||||||
latlngbounds.extend(p.coordinates);
|
latlngbounds.extend(p.coordinates);
|
||||||
@ -68,26 +69,26 @@ function displayTrack(xml,update) {
|
|||||||
}
|
}
|
||||||
if (update) {
|
if (update) {
|
||||||
map.fitBounds(latlngbounds);
|
map.fitBounds(latlngbounds);
|
||||||
if (i==1) {
|
if (i == 1) {
|
||||||
// only one point, zoom out
|
// only one point, zoom out
|
||||||
zListener =
|
zListener =
|
||||||
google.maps.event.addListenerOnce(map, 'bounds_changed', function(event) {
|
google.maps.event.addListenerOnce(map, 'bounds_changed', function (event) {
|
||||||
if (this.getZoom()){
|
if (this.getZoom()) {
|
||||||
this.setZoom(15);
|
this.setZoom(15);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setTimeout(function(){google.maps.event.removeListener(zListener)}, 2000);
|
setTimeout(function () { google.maps.event.removeListener(zListener) }, 2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
latestTime = p.dateoccured;
|
latestTime = p.dateoccured;
|
||||||
polies.push(poly);
|
polies.push(poly);
|
||||||
|
|
||||||
updateSummary(p.dateoccured,totalMeters,totalSeconds);
|
updateSummary(p.dateoccured, totalMeters, totalSeconds);
|
||||||
if (p.tid!=trackid) {
|
if (p.tid != trackid) {
|
||||||
trackid=p.tid;
|
trackid = p.tid;
|
||||||
setTrack(trackid);
|
setTrack(trackid);
|
||||||
}
|
}
|
||||||
if (document.getElementById('bottom').style.display=='block') {
|
if (document.getElementById('bottom').style.display == 'block') {
|
||||||
// update altitudes chart
|
// update altitudes chart
|
||||||
chart.clearChart();
|
chart.clearChart();
|
||||||
displayChart();
|
displayChart();
|
||||||
@ -95,13 +96,13 @@ function displayTrack(xml,update) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function clearMap() {
|
function clearMap() {
|
||||||
if (polies){
|
if (polies) {
|
||||||
for (var i=0; i<polies.length; i++){
|
for (var i = 0; i < polies.length; i++) {
|
||||||
polies[i].setMap(null);
|
polies[i].setMap(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (markers){
|
if (markers) {
|
||||||
for (var i=0; i<markers.length; i++){
|
for (var i = 0; i < markers.length; i++) {
|
||||||
google.maps.event.removeListener(popups[i].listener);
|
google.maps.event.removeListener(popups[i].listener);
|
||||||
popups[i].setMap(null);
|
popups[i].setMap(null);
|
||||||
markers[i].setMap(null);
|
markers[i].setMap(null);
|
||||||
@ -113,59 +114,60 @@ function clearMap() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var popup;
|
var popup;
|
||||||
function setMarker(p,i,posLen) {
|
function setMarker(p, i, posLen) {
|
||||||
// marker
|
// marker
|
||||||
var marker = new google.maps.Marker( {
|
var marker = new google.maps.Marker({
|
||||||
map: map,
|
map: map,
|
||||||
position: p.coordinates,
|
position: p.coordinates,
|
||||||
title: p.dateoccured
|
title: p.dateoccured
|
||||||
});
|
});
|
||||||
if (latest==1) { marker.setIcon('//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('//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('//maps.google.com/mapfiles/markerB.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') }
|
else { marker.setIcon('//maps.gstatic.com/mapfiles/ridefinder-images/mm_20_gray.png') }
|
||||||
// popup
|
// popup
|
||||||
var content = getPopupHtml(p,i,posLen);
|
var content = getPopupHtml(p, i, posLen);
|
||||||
popup = new google.maps.InfoWindow();
|
popup = new google.maps.InfoWindow();
|
||||||
popup.listener = google.maps.event.addListener(marker, 'click', (function(marker,content) {
|
popup.listener = google.maps.event.addListener(marker, 'click', (function (marker, content) {
|
||||||
return function() {
|
return function () {
|
||||||
popup.setContent(content);
|
popup.setContent(content);
|
||||||
popup.open(map, marker);
|
popup.open(map, marker);
|
||||||
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 }]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})(marker,content));
|
})(marker, content));
|
||||||
markers.push(marker);
|
markers.push(marker);
|
||||||
popups.push(popup);
|
popups.push(popup);
|
||||||
}
|
}
|
||||||
|
|
||||||
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('//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);
|
||||||
}
|
}
|
||||||
|
@ -20,70 +20,71 @@
|
|||||||
var map;
|
var map;
|
||||||
var layerTrack;
|
var layerTrack;
|
||||||
var layerMarkers;
|
var layerMarkers;
|
||||||
var lineStyle = {strokeColor: '#FF0000', strokeOpacity: 1, strokeWidth: 2};
|
var lineStyle = { strokeColor: '#FF0000', strokeOpacity: 1, strokeWidth: 2 };
|
||||||
var wgs84;
|
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 = {
|
||||||
new OpenLayers.Control.ArgParser(), // default
|
controls: [
|
||||||
new OpenLayers.Control.Attribution(), // default
|
new OpenLayers.Control.ArgParser(), // default
|
||||||
new OpenLayers.Control.LayerSwitcher(),
|
new OpenLayers.Control.Attribution(), // default
|
||||||
new OpenLayers.Control.Navigation(), // default
|
new OpenLayers.Control.LayerSwitcher(),
|
||||||
new OpenLayers.Control.PanZoomBar(),// do we need it?
|
new OpenLayers.Control.Navigation(), // default
|
||||||
new OpenLayers.Control.ScaleLine()
|
new OpenLayers.Control.PanZoomBar(),// do we need it?
|
||||||
|
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('OpenStreetMap',
|
var mapnik = new OpenLayers.Layer.OSM('OpenStreetMap',
|
||||||
['//a.tile.openstreetmap.org/${z}/${x}/${y}.png',
|
['//a.tile.openstreetmap.org/${z}/${x}/${y}.png',
|
||||||
'//b.tile.openstreetmap.org/${z}/${x}/${y}.png',
|
'//b.tile.openstreetmap.org/${z}/${x}/${y}.png',
|
||||||
'//c.tile.openstreetmap.org/${z}/${x}/${y}.png']);
|
'//c.tile.openstreetmap.org/${z}/${x}/${y}.png']);
|
||||||
map.addLayer(mapnik);
|
map.addLayer(mapnik);
|
||||||
if (layer_ocm==1) {
|
if (layer_ocm == 1) {
|
||||||
// OpenCycleMap
|
// OpenCycleMap
|
||||||
var ocm = new OpenLayers.Layer.OSM('OpenCycleMap',
|
var ocm = new OpenLayers.Layer.OSM('OpenCycleMap',
|
||||||
['//a.tile.thunderforest.com/cycle/${z}/${x}/${y}.png',
|
['//a.tile.thunderforest.com/cycle/${z}/${x}/${y}.png',
|
||||||
'//b.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']);
|
'//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',
|
||||||
['//otile1.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',
|
'//otile2.mqcdn.com/tiles/1.0.0/map/${z}/${x}/${y}.jpg',
|
||||||
'//otile3.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']);
|
'//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',
|
||||||
['//a.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',
|
'//b.osm.trail.pl/osmapa.pl/${z}/${x}/${y}.png',
|
||||||
'//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',
|
||||||
['//1.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',
|
'//2.tiles.ump.waw.pl/ump_tiles/${z}/${x}/${y}.png',
|
||||||
'//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;
|
||||||
var totalMeters = 0;
|
var totalMeters = 0;
|
||||||
var totalSeconds = 0;
|
var totalSeconds = 0;
|
||||||
@ -91,16 +92,16 @@ function displayTrack(xml,update) {
|
|||||||
var latlngbounds = new OpenLayers.Bounds();
|
var latlngbounds = new OpenLayers.Bounds();
|
||||||
var positions = xml.getElementsByTagName('position');
|
var positions = xml.getElementsByTagName('position');
|
||||||
var posLen = positions.length;
|
var posLen = positions.length;
|
||||||
for (var i=0; i<posLen; i++) {
|
for (var i = 0; i < posLen; i++) {
|
||||||
var p = parsePosition(positions[i]);
|
var p = parsePosition(positions[i]);
|
||||||
totalMeters += p.distance;
|
totalMeters += p.distance;
|
||||||
totalSeconds += p.seconds;
|
totalSeconds += p.seconds;
|
||||||
p['totalMeters'] = totalMeters;
|
p['totalMeters'] = totalMeters;
|
||||||
p['totalSeconds'] = totalSeconds;
|
p['totalSeconds'] = totalSeconds;
|
||||||
// set marker
|
// set marker
|
||||||
setMarker(p,i,posLen);
|
setMarker(p, i, posLen);
|
||||||
// update polyline
|
// update polyline
|
||||||
var point = new OpenLayers.Geometry.Point(p.longitude, p.latitude).transform(wgs84,mercator);
|
var point = new OpenLayers.Geometry.Point(p.longitude, p.latitude).transform(wgs84, mercator);
|
||||||
latlngbounds.extend(point);
|
latlngbounds.extend(point);
|
||||||
points.push(point);
|
points.push(point);
|
||||||
// save altitudes for chart
|
// save altitudes for chart
|
||||||
@ -113,7 +114,7 @@ function displayTrack(xml,update) {
|
|||||||
map.addLayer(layerMarkers);
|
map.addLayer(layerMarkers);
|
||||||
if (update) {
|
if (update) {
|
||||||
map.zoomToExtent(latlngbounds);
|
map.zoomToExtent(latlngbounds);
|
||||||
if (i==1) {
|
if (i == 1) {
|
||||||
// only one point, zoom out
|
// only one point, zoom out
|
||||||
map.zoomOut();
|
map.zoomOut();
|
||||||
}
|
}
|
||||||
@ -121,12 +122,12 @@ function displayTrack(xml,update) {
|
|||||||
latestTime = p.dateoccured;
|
latestTime = p.dateoccured;
|
||||||
//polies.push(poly);
|
//polies.push(poly);
|
||||||
|
|
||||||
updateSummary(p.dateoccured,totalMeters,totalSeconds);
|
updateSummary(p.dateoccured, totalMeters, totalSeconds);
|
||||||
if (p.tid!=trackid) {
|
if (p.tid != trackid) {
|
||||||
trackid=p.tid;
|
trackid = p.tid;
|
||||||
setTrack(trackid);
|
setTrack(trackid);
|
||||||
}
|
}
|
||||||
if (document.getElementById('bottom').style.display=='block') {
|
if (document.getElementById('bottom').style.display == 'block') {
|
||||||
// update altitudes chart
|
// update altitudes chart
|
||||||
chart.clearChart();
|
chart.clearChart();
|
||||||
displayChart();
|
displayChart();
|
||||||
@ -134,74 +135,74 @@ function displayTrack(xml,update) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function clearMap() {
|
function clearMap() {
|
||||||
if (layerTrack){
|
if (layerTrack) {
|
||||||
layerTrack.removeAllFeatures();
|
layerTrack.removeAllFeatures();
|
||||||
}
|
}
|
||||||
if (layerMarkers){
|
if (layerMarkers) {
|
||||||
layerMarkers.clearMarkers();
|
layerMarkers.clearMarkers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setMarker(p,i,posLen) {
|
function setMarker(p, i, posLen) {
|
||||||
// marker
|
// marker
|
||||||
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('//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 == 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 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('//maps.gstatic.com/mapfiles/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
|
||||||
var content = getPopupHtml(p,i,posLen);
|
var content = getPopupHtml(p, i, posLen);
|
||||||
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
|
||||||
|
var popup = new OpenLayers.Popup.FramedCloud("popup_" + (i + 1), lonLat, null, content, icon, true);
|
||||||
|
map.addPopup(popup);
|
||||||
|
if (document.getElementById('bottom').style.display == 'block') {
|
||||||
|
chart.setSelection([{ row: i, column: null }]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// show popup
|
|
||||||
var popup = new OpenLayers.Popup.FramedCloud("popup_"+(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) {
|
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('//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);
|
||||||
}
|
}
|
||||||
|
4
auth.php
4
auth.php
@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once("helpers/config.php");
|
require_once("helpers/config.php");
|
||||||
$config = new uConfig();
|
$config = new uConfig();
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ if (!$user->isValid && ($config::$require_authentication || defined('headless'))
|
|||||||
|
|
||||||
if (!$login){
|
if (!$login){
|
||||||
// not authenticated and username not submited
|
// not authenticated and username not submited
|
||||||
// load form
|
// load form
|
||||||
if (defined('headless')) {
|
if (defined('headless')) {
|
||||||
header('HTTP/1.1 401 Unauthorized', true, 401);
|
header('HTTP/1.1 401 Unauthorized', true, 401);
|
||||||
} else {
|
} else {
|
||||||
|
@ -16,13 +16,19 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once("auth.php"); // sets $mysqli, $user
|
require_once("auth.php"); // sets $mysqli, $user
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exit with error message
|
||||||
|
*
|
||||||
|
* @param string $errorMessage Message
|
||||||
|
*/
|
||||||
function exitWithError($errorMessage) {
|
function exitWithError($errorMessage) {
|
||||||
return exitWithStatus(true, $errorMessage);
|
return exitWithStatus(true, $errorMessage);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
|
/**
|
||||||
* Exit with xml response
|
* Exit with xml response
|
||||||
* @param boolean $isError Error if true
|
* @param boolean $isError Error if true
|
||||||
* @param string $errorMessage Optional error message
|
* @param string $errorMessage Optional error message
|
||||||
@ -67,7 +73,7 @@
|
|||||||
if ($passUser->setPass($hash) === false) {
|
if ($passUser->setPass($hash) === false) {
|
||||||
exitWithError("Server error");
|
exitWithError("Server error");
|
||||||
}
|
}
|
||||||
|
|
||||||
exitWithStatus();
|
exitWithStatus();
|
||||||
|
|
||||||
?>
|
?>
|
@ -17,12 +17,18 @@
|
|||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set response error status and message
|
||||||
|
*
|
||||||
|
* @param array $response Respons
|
||||||
|
* @param string $message Message
|
||||||
|
*/
|
||||||
function setError(&$response, $message) {
|
function setError(&$response, $message) {
|
||||||
$response['error'] = true;
|
$response['error'] = true;
|
||||||
$response['message'] = $message;
|
$response['message'] = $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
define("headless", true);
|
define("headless", true);
|
||||||
require_once("../auth.php"); // sets $mysqli, $user
|
require_once("../auth.php"); // sets $mysqli, $user
|
||||||
|
|
||||||
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
|
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
|
||||||
@ -92,7 +98,7 @@ switch ($action) {
|
|||||||
$position = new uPosition();
|
$position = new uPosition();
|
||||||
$positionId = $position->add($user->id, $trackId,
|
$positionId = $position->add($user->id, $trackId,
|
||||||
$time, $lat, $lon, $altitude, $speed, $bearing, $accuracy, $provider, $comment, $imageId);
|
$time, $lat, $lon, $altitude, $speed, $bearing, $accuracy, $provider, $comment, $imageId);
|
||||||
|
|
||||||
if ($positionId === false) {
|
if ($positionId === false) {
|
||||||
setError($response, "Server error");
|
setError($response, "Server error");
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// This is default configuration file.
|
// This is default configuration file.
|
||||||
// Copy it to config.php and customize
|
// Copy it to config.php and customize
|
||||||
|
|
||||||
// default map drawing framework
|
// default map drawing framework
|
||||||
|
15
download.php
15
download.php
@ -16,10 +16,17 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once("auth.php"); // sets $mysqli, $user
|
require_once("auth.php"); // sets $mysqli, $user
|
||||||
require_once("helpers/position.php");
|
require_once("helpers/position.php");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add kml marker style element
|
||||||
|
*
|
||||||
|
* @param XMLWriter $xml Writer object
|
||||||
|
* @param string $name Color name
|
||||||
|
* @param string $url Url
|
||||||
|
*/
|
||||||
function addStyle($xml, $name, $url) {
|
function addStyle($xml, $name, $url) {
|
||||||
$xml->startElement("Style");
|
$xml->startElement("Style");
|
||||||
$xml->writeAttribute("id", $name."Style");
|
$xml->writeAttribute("id", $name."Style");
|
||||||
@ -32,6 +39,12 @@ function addStyle($xml, $name, $url) {
|
|||||||
$xml->endElement();
|
$xml->endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert seconds to [day], hour, minute, second string
|
||||||
|
*
|
||||||
|
* @param [type] $s Number of seconds
|
||||||
|
* @return string [d ]hhmmss
|
||||||
|
*/
|
||||||
function toHMS($s) {
|
function toHMS($s) {
|
||||||
$d = floor($s / 86400);
|
$d = floor($s / 86400);
|
||||||
$h = floor(($s % 86400) / 3600);
|
$h = floor(($s % 86400) / 3600);
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once("auth.php"); // sets $mysqli, $user
|
require_once("auth.php"); // sets $mysqli, $user
|
||||||
require_once("helpers/position.php");
|
require_once("helpers/position.php");
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ if ($userId) {
|
|||||||
$position->getLast($userId);
|
$position->getLast($userId);
|
||||||
$positionsArr[] = $position;
|
$positionsArr[] = $position;
|
||||||
}
|
}
|
||||||
|
|
||||||
header("Content-type: text/xml");
|
header("Content-type: text/xml");
|
||||||
$xml = new XMLWriter();
|
$xml = new XMLWriter();
|
||||||
$xml->openURI("php://output");
|
$xml->openURI("php://output");
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once("auth.php"); // sets $mysqli, $user
|
require_once("auth.php"); // sets $mysqli, $user
|
||||||
require_once("helpers/track.php");
|
require_once("helpers/track.php");
|
||||||
|
|
||||||
|
@ -17,7 +17,10 @@
|
|||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class uConfig {
|
/**
|
||||||
|
* Handles config values
|
||||||
|
*/
|
||||||
|
class uConfig {
|
||||||
// version number
|
// version number
|
||||||
static $version = "0.2-beta";
|
static $version = "0.2-beta";
|
||||||
|
|
||||||
@ -77,50 +80,60 @@ class uConfig {
|
|||||||
private static $fileLoaded = false;
|
private static $fileLoaded = false;
|
||||||
public static $rootDir;
|
public static $rootDir;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
self::$rootDir = dirname(__DIR__);
|
self::$rootDir = dirname(__DIR__);
|
||||||
$this->setFromFile();
|
$this->setFromFile();
|
||||||
$this->setFromCookies();
|
$this->setFromCookies();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setFromFile() {
|
/**
|
||||||
$configFile = self::$rootDir . "/config.php";
|
* Read config values from "/config.php" file
|
||||||
if (self::$fileLoaded || !file_exists($configFile)) {
|
*/
|
||||||
return;
|
private function setFromFile() {
|
||||||
}
|
$configFile = self::$rootDir . "/config.php";
|
||||||
self::$fileLoaded = true;
|
if (self::$fileLoaded || !file_exists($configFile)) {
|
||||||
include_once($configFile);
|
return;
|
||||||
|
}
|
||||||
|
self::$fileLoaded = true;
|
||||||
|
include_once($configFile);
|
||||||
|
|
||||||
if (isset($mapapi)) { self::$mapapi = $mapapi; }
|
if (isset($mapapi)) { self::$mapapi = $mapapi; }
|
||||||
if (isset($gkey)) { self::$gkey = $gkey; }
|
if (isset($gkey)) { self::$gkey = $gkey; }
|
||||||
if (isset($layer_ocm)) { self::$layer_ocm = $layer_ocm; }
|
if (isset($layer_ocm)) { self::$layer_ocm = $layer_ocm; }
|
||||||
if (isset($layer_mq)) { self::$layer_mq = $layer_mq; }
|
if (isset($layer_mq)) { self::$layer_mq = $layer_mq; }
|
||||||
if (isset($layer_osmapa)) { self::$layer_osmapa = $layer_osmapa; }
|
if (isset($layer_osmapa)) { self::$layer_osmapa = $layer_osmapa; }
|
||||||
if (isset($layer_ump)) { self::$layer_ump = $layer_ump; }
|
if (isset($layer_ump)) { self::$layer_ump = $layer_ump; }
|
||||||
if (isset($init_latitude)) { self::$init_latitude = $init_latitude; }
|
if (isset($init_latitude)) { self::$init_latitude = $init_latitude; }
|
||||||
if (isset($init_longitude)) { self::$init_longitude = $init_longitude; }
|
if (isset($init_longitude)) { self::$init_longitude = $init_longitude; }
|
||||||
if (isset($dbhost)) { self::$dbhost = $dbhost; }
|
if (isset($dbhost)) { self::$dbhost = $dbhost; }
|
||||||
if (isset($dbuser)) { self::$dbuser = $dbuser; }
|
if (isset($dbuser)) { self::$dbuser = $dbuser; }
|
||||||
if (isset($dbpass)) { self::$dbpass = $dbpass; }
|
if (isset($dbpass)) { self::$dbpass = $dbpass; }
|
||||||
if (isset($dbname)) { self::$dbname = $dbname; }
|
if (isset($dbname)) { self::$dbname = $dbname; }
|
||||||
if (isset($require_authentication)) { self::$require_authentication = (bool) $require_authentication; }
|
if (isset($require_authentication)) { self::$require_authentication = (bool) $require_authentication; }
|
||||||
if (isset($public_tracks)) { self::$public_tracks = (bool) $public_tracks; }
|
if (isset($public_tracks)) { self::$public_tracks = (bool) $public_tracks; }
|
||||||
if (isset($admin_user)) { self::$admin_user = $admin_user; }
|
if (isset($admin_user)) { self::$admin_user = $admin_user; }
|
||||||
if (isset($interval)) { self::$interval = $interval; }
|
if (isset($interval)) { self::$interval = $interval; }
|
||||||
if (isset($lang)) { self::$lang = $lang; }
|
if (isset($lang)) { self::$lang = $lang; }
|
||||||
if (isset($units)) { self::$units = $units; }
|
if (isset($units)) { self::$units = $units; }
|
||||||
|
|
||||||
if (!self::$require_authentication) {
|
if (!self::$require_authentication) {
|
||||||
// tracks must be public if we don't require authentication
|
// tracks must be public if we don't require authentication
|
||||||
self::$public_tracks = true;
|
self::$public_tracks = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private function setFromCookies() {
|
|
||||||
if (isset($_COOKIE["ulogger_api"])) { self::$mapapi = $_COOKIE["ulogger_api"]; }
|
/**
|
||||||
if (isset($_COOKIE["ulogger_lang"])) { self::$lang = $_COOKIE["ulogger_lang"]; }
|
* Read config values stored in cookies
|
||||||
if (isset($_COOKIE["ulogger_units"])) { self::$units = $_COOKIE["ulogger_units"]; }
|
*/
|
||||||
if (isset($_COOKIE["ulogger_interval"])) { self::$interval = $_COOKIE["ulogger_interval"]; }
|
private function setFromCookies() {
|
||||||
}
|
if (isset($_COOKIE["ulogger_api"])) { self::$mapapi = $_COOKIE["ulogger_api"]; }
|
||||||
}
|
if (isset($_COOKIE["ulogger_lang"])) { self::$lang = $_COOKIE["ulogger_lang"]; }
|
||||||
|
if (isset($_COOKIE["ulogger_units"])) { self::$units = $_COOKIE["ulogger_units"]; }
|
||||||
|
if (isset($_COOKIE["ulogger_interval"])) { self::$interval = $_COOKIE["ulogger_interval"]; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@ -17,31 +17,48 @@
|
|||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once (__DIR__ . "/config.php");
|
require_once (__DIR__ . "/config.php");
|
||||||
class uDb extends mysqli {
|
|
||||||
// singleton instance
|
|
||||||
protected static $instance;
|
|
||||||
|
|
||||||
// private constuctor
|
/**
|
||||||
private function __construct($host, $user, $pass, $name) {
|
* mysqli wrapper
|
||||||
parent::__construct($host, $user, $pass, $name);
|
*/
|
||||||
if ($this->connect_error) {
|
class uDb extends mysqli {
|
||||||
if (defined('headless')) {
|
/**
|
||||||
header("HTTP/1.1 503 Service Unavailable");
|
* Singleton instance
|
||||||
exit;
|
*
|
||||||
|
* @var mysqli Object instance
|
||||||
|
*/
|
||||||
|
protected static $instance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private constuctor
|
||||||
|
*
|
||||||
|
* @param string $host
|
||||||
|
* @param string $user
|
||||||
|
* @param string $pass
|
||||||
|
* @param string $name
|
||||||
|
*/
|
||||||
|
private function __construct($host, $user, $pass, $name) {
|
||||||
|
parent::__construct($host, $user, $pass, $name);
|
||||||
|
if ($this->connect_error) {
|
||||||
|
if (defined('headless')) {
|
||||||
|
header("HTTP/1.1 503 Service Unavailable");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
die("Database connection error (" . $this->connect_errno . ")");
|
||||||
}
|
}
|
||||||
die("Database connection error (" . $this->connect_errno . ")");
|
$this->set_charset('utf8');
|
||||||
}
|
}
|
||||||
$this->set_charset('utf8');
|
|
||||||
}
|
|
||||||
|
|
||||||
// returns singleton instance
|
/**
|
||||||
public static function getInstance() {
|
* Returns singleton instance
|
||||||
if (!self::$instance) {
|
*/
|
||||||
$config = new uConfig();
|
public static function getInstance() {
|
||||||
self::$instance = new self($config::$dbhost, $config::$dbuser, $config::$dbpass, $config::$dbname);
|
if (!self::$instance) {
|
||||||
|
$config = new uConfig();
|
||||||
|
self::$instance = new self($config::$dbhost, $config::$dbuser, $config::$dbpass, $config::$dbname);
|
||||||
|
}
|
||||||
|
return self::$instance;
|
||||||
}
|
}
|
||||||
return self::$instance;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
?>
|
?>
|
@ -17,9 +17,12 @@
|
|||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(__DIR__ . "/db.php");
|
require_once(__DIR__ . "/db.php");
|
||||||
|
|
||||||
class uPosition {
|
/**
|
||||||
|
* Positions handling
|
||||||
|
*/
|
||||||
|
class uPosition {
|
||||||
public $id;
|
public $id;
|
||||||
public $time;
|
public $time;
|
||||||
public $userId;
|
public $userId;
|
||||||
@ -40,23 +43,44 @@ class uPosition {
|
|||||||
|
|
||||||
private static $db;
|
private static $db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param integer $positionId Position id
|
||||||
|
*/
|
||||||
public function __construct($positionId = NULL) {
|
public function __construct($positionId = NULL) {
|
||||||
|
|
||||||
self::$db = uDB::getInstance();
|
self::$db = uDB::getInstance();
|
||||||
|
|
||||||
if (!empty($positionId)) {
|
if (!empty($positionId)) {
|
||||||
$query = "SELECT p.id, p.time, p.user_id, p.track_id,
|
$query = "SELECT p.id, p.time, p.user_id, p.track_id,
|
||||||
p.latitude, p.longitude, p.altitude, p.speed, p.bearing, p.accuracy, p.provider,
|
p.latitude, p.longitude, p.altitude, p.speed, p.bearing, p.accuracy, p.provider,
|
||||||
p.comment, p.image_id, u.login, t.name
|
p.comment, p.image_id, u.login, t.name
|
||||||
FROM positions p
|
FROM positions p
|
||||||
LEFT JOIN users u ON (p.user_id = u.id)
|
LEFT JOIN users u ON (p.user_id = u.id)
|
||||||
LEFT JOIN tracks t ON (p.track_id = t.id)
|
LEFT JOIN tracks t ON (p.track_id = t.id)
|
||||||
WHERE id = ? LIMIT 1";
|
WHERE id = ? LIMIT 1";
|
||||||
$params = [ 'i', $positionId ];
|
$params = [ 'i', $positionId ];
|
||||||
$this->loadWithQuery($query, $params);
|
$this->loadWithQuery($query, $params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add position
|
||||||
|
*
|
||||||
|
* @param int $userId
|
||||||
|
* @param int $trackId
|
||||||
|
* @param int $time Unix time stamp
|
||||||
|
* @param double $lat
|
||||||
|
* @param double $lon
|
||||||
|
* @param double $altitude
|
||||||
|
* @param double $speed
|
||||||
|
* @param double $bearing
|
||||||
|
* @param int $accuracy
|
||||||
|
* @param string $provider
|
||||||
|
* @param string $comment
|
||||||
|
* @param int $imageId
|
||||||
|
* @return int|bool New position id in database, false on error
|
||||||
|
*/
|
||||||
public function add($userId, $trackId, $time, $lat, $lon, $altitude, $speed, $bearing, $accuracy, $provider, $comment, $imageId) {
|
public function add($userId, $trackId, $time, $lat, $lon, $altitude, $speed, $bearing, $accuracy, $provider, $comment, $imageId) {
|
||||||
$positionId = false;
|
$positionId = false;
|
||||||
if (!is_null($lat) && !is_null($lon) && !is_null($time) && !empty($userId) && !empty($trackId)) {
|
if (!is_null($lat) && !is_null($lon) && !is_null($time) && !empty($userId) && !empty($trackId)) {
|
||||||
@ -77,6 +101,12 @@ class uPosition {
|
|||||||
return $positionId;
|
return $positionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill class properties with last position data from database
|
||||||
|
* (for given user if specified)
|
||||||
|
*
|
||||||
|
* @param int $userId Optional user id
|
||||||
|
*/
|
||||||
public function getLast($userId = NULL) {
|
public function getLast($userId = NULL) {
|
||||||
if (!empty($userId)) {
|
if (!empty($userId)) {
|
||||||
$where = "WHERE p.user_id = ?";
|
$where = "WHERE p.user_id = ?";
|
||||||
@ -85,17 +115,24 @@ class uPosition {
|
|||||||
$where = "";
|
$where = "";
|
||||||
$params = NULL;
|
$params = NULL;
|
||||||
}
|
}
|
||||||
$query = "SELECT p.id, p.time, p.user_id, p.track_id,
|
$query = "SELECT p.id, p.time, p.user_id, p.track_id,
|
||||||
p.latitude, p.longitude, p.altitude, p.speed, p.bearing, p.accuracy, p.provider,
|
p.latitude, p.longitude, p.altitude, p.speed, p.bearing, p.accuracy, p.provider,
|
||||||
p.comment, p.image_id, u.login, t.name
|
p.comment, p.image_id, u.login, t.name
|
||||||
FROM positions p
|
FROM positions p
|
||||||
LEFT JOIN users u ON (p.user_id = u.id)
|
LEFT JOIN users u ON (p.user_id = u.id)
|
||||||
LEFT JOIN tracks t ON (p.track_id = t.id)
|
LEFT JOIN tracks t ON (p.track_id = t.id)
|
||||||
$where
|
$where
|
||||||
ORDER BY p.time DESC LIMIT 1";
|
ORDER BY p.time DESC LIMIT 1";
|
||||||
$this->loadWithQuery($query, $params);
|
$this->loadWithQuery($query, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get array of all positions
|
||||||
|
*
|
||||||
|
* @param int $userId Optional limit to given user id
|
||||||
|
* @param int $trackId Optional limit to given track id
|
||||||
|
* @return array|bool Array of uPosition positions, false on error
|
||||||
|
*/
|
||||||
public function getAll($userId = NULL, $trackId = NULL) {
|
public function getAll($userId = NULL, $trackId = NULL) {
|
||||||
$rules = [];
|
$rules = [];
|
||||||
if (!empty($userId)) {
|
if (!empty($userId)) {
|
||||||
@ -103,19 +140,19 @@ class uPosition {
|
|||||||
}
|
}
|
||||||
if (!empty($trackId)) {
|
if (!empty($trackId)) {
|
||||||
$rules[] = "p.track_id = '" . self::$db->real_escape_string($trackId) ."'";
|
$rules[] = "p.track_id = '" . self::$db->real_escape_string($trackId) ."'";
|
||||||
}
|
}
|
||||||
if (!empty($rules)) {
|
if (!empty($rules)) {
|
||||||
$where = "WHERE " . implode(" AND ", $rules);
|
$where = "WHERE " . implode(" AND ", $rules);
|
||||||
} else {
|
} else {
|
||||||
$where = "";
|
$where = "";
|
||||||
}
|
}
|
||||||
$query = "SELECT p.id, p.time, p.user_id, p.track_id,
|
$query = "SELECT p.id, p.time, p.user_id, p.track_id,
|
||||||
p.latitude, p.longitude, p.altitude, p.speed, p.bearing, p.accuracy, p.provider,
|
p.latitude, p.longitude, p.altitude, p.speed, p.bearing, p.accuracy, p.provider,
|
||||||
p.comment, p.image_id, u.login, t.name
|
p.comment, p.image_id, u.login, t.name
|
||||||
FROM positions p
|
FROM positions p
|
||||||
LEFT JOIN users u ON (p.user_id = u.id)
|
LEFT JOIN users u ON (p.user_id = u.id)
|
||||||
LEFT JOIN tracks t ON (p.track_id = t.id)
|
LEFT JOIN tracks t ON (p.track_id = t.id)
|
||||||
$where
|
$where
|
||||||
ORDER BY p.time";
|
ORDER BY p.time";
|
||||||
$result = self::$db->query($query);
|
$result = self::$db->query($query);
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
@ -129,7 +166,12 @@ class uPosition {
|
|||||||
return $positionsArr;
|
return $positionsArr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// haversine distance to target point
|
/**
|
||||||
|
* Calculate distance to target point using haversine formula
|
||||||
|
*
|
||||||
|
* @param uPosition $target Target position
|
||||||
|
* @return int Distance in meters
|
||||||
|
*/
|
||||||
public function distanceTo($target) {
|
public function distanceTo($target) {
|
||||||
$lat1 = deg2rad($this->latitude);
|
$lat1 = deg2rad($this->latitude);
|
||||||
$lon1 = deg2rad($this->longitude);
|
$lon1 = deg2rad($this->longitude);
|
||||||
@ -141,10 +183,22 @@ class uPosition {
|
|||||||
return $bearing * 6371000;
|
return $bearing * 6371000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate time elapsed since target point
|
||||||
|
*
|
||||||
|
* @param uPosition $target Target position
|
||||||
|
* @return int Number of seconds
|
||||||
|
*/
|
||||||
public function secondsTo($target) {
|
public function secondsTo($target) {
|
||||||
return strtotime($this->time) - strtotime($target->time);
|
return strtotime($this->time) - strtotime($target->time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert database row to uPosition
|
||||||
|
*
|
||||||
|
* @param array $row Row
|
||||||
|
* @return uPosition Position
|
||||||
|
*/
|
||||||
private function rowToObject($row) {
|
private function rowToObject($row) {
|
||||||
$position = new uPosition();
|
$position = new uPosition();
|
||||||
$position->id = $row['id'];
|
$position->id = $row['id'];
|
||||||
@ -166,25 +220,31 @@ class uPosition {
|
|||||||
return $position;
|
return $position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill class properties with database query result
|
||||||
|
*
|
||||||
|
* @param string $query Query
|
||||||
|
* @param array|null $bindParams Optional array of bind parameters (types, params)
|
||||||
|
*/
|
||||||
private function loadWithQuery($query, $bindParams = NULL) {
|
private function loadWithQuery($query, $bindParams = NULL) {
|
||||||
$stmt = self::$db->prepare($query);
|
$stmt = self::$db->prepare($query);
|
||||||
if (is_array($bindParams) && ($types = array_shift($bindParams))) {
|
if (is_array($bindParams) && ($types = array_shift($bindParams))) {
|
||||||
call_user_func_array(
|
call_user_func_array(
|
||||||
[ $stmt, 'bind_param' ],
|
[ $stmt, 'bind_param' ],
|
||||||
array_merge([ $types ], array_map(function(&$param) { return $param; }, $bindParams))
|
array_merge([ $types ], array_map(function(&$param) { return $param; }, $bindParams))
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
if ($stmt->execute()) {
|
||||||
|
$stmt->bind_result($this->id, $this->time, $this->userId, $this->trackId,
|
||||||
|
$this->latitude, $this->longitude, $this->altitude, $this->speed,
|
||||||
|
$this->bearing, $this->accuracy, $this->provider,
|
||||||
|
$this->comment, $this->imageId, $this->userLogin, $this->trackName);
|
||||||
|
if ($stmt->fetch()) {
|
||||||
|
$this->isValid = true;
|
||||||
}
|
}
|
||||||
if ($stmt->execute()) {
|
}
|
||||||
$stmt->bind_result($this->id, $this->time, $this->userId, $this->trackId,
|
$stmt->close();
|
||||||
$this->latitude, $this->longitude, $this->altitude, $this->speed,
|
|
||||||
$this->bearing, $this->accuracy, $this->provider,
|
|
||||||
$this->comment, $this->imageId, $this->userLogin, $this->trackName);
|
|
||||||
if ($stmt->fetch()) {
|
|
||||||
$this->isValid = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$stmt->close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@ -17,9 +17,12 @@
|
|||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(__DIR__ . "/db.php");
|
require_once(__DIR__ . "/db.php");
|
||||||
|
|
||||||
class uTrack {
|
/**
|
||||||
|
* Track handling
|
||||||
|
*/
|
||||||
|
class uTrack {
|
||||||
public $id;
|
public $id;
|
||||||
public $userId;
|
public $userId;
|
||||||
public $name;
|
public $name;
|
||||||
@ -29,6 +32,11 @@ class uTrack {
|
|||||||
|
|
||||||
private static $db;
|
private static $db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param int $trackId Track id
|
||||||
|
*/
|
||||||
public function __construct($trackId = NULL) {
|
public function __construct($trackId = NULL) {
|
||||||
|
|
||||||
self::$db = uDB::getInstance();
|
self::$db = uDB::getInstance();
|
||||||
@ -46,6 +54,14 @@ class uTrack {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add new track
|
||||||
|
*
|
||||||
|
* @param string $userId User id
|
||||||
|
* @param string $name Name
|
||||||
|
* @param string $comment Optional comment
|
||||||
|
* @return int|bool New track id, false on error
|
||||||
|
*/
|
||||||
public function add($userId, $name, $comment = NULL) {
|
public function add($userId, $name, $comment = NULL) {
|
||||||
$trackId = false;
|
$trackId = false;
|
||||||
if (!empty($userId) && !empty($name)) {
|
if (!empty($userId) && !empty($name)) {
|
||||||
@ -61,6 +77,12 @@ class uTrack {
|
|||||||
return $trackId;
|
return $trackId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all tracks
|
||||||
|
*
|
||||||
|
* @param int $userId Optional limit to user id
|
||||||
|
* @return array|bool Array of uTrack tracks, false on error
|
||||||
|
*/
|
||||||
public function getAll($userId = NULL) {
|
public function getAll($userId = NULL) {
|
||||||
if (!empty($userId)) {
|
if (!empty($userId)) {
|
||||||
$where = "WHERE user_id='" . self::$db->real_escape_string($userId) ."'";
|
$where = "WHERE user_id='" . self::$db->real_escape_string($userId) ."'";
|
||||||
@ -80,6 +102,12 @@ class uTrack {
|
|||||||
return $trackArr;
|
return $trackArr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert database row to uTrack
|
||||||
|
*
|
||||||
|
* @param array $row Row
|
||||||
|
* @return uTrack Track
|
||||||
|
*/
|
||||||
private function rowToObject($row) {
|
private function rowToObject($row) {
|
||||||
$track = new uTrack();
|
$track = new uTrack();
|
||||||
$track->id = $row['id'];
|
$track->id = $row['id'];
|
||||||
@ -89,6 +117,6 @@ class uTrack {
|
|||||||
$track->isValid = true;
|
$track->isValid = true;
|
||||||
return $track;
|
return $track;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@ -16,11 +16,13 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
require_once (__DIR__ . "/config.php");
|
||||||
|
require_once (__DIR__ . "/db.php");
|
||||||
|
|
||||||
require_once(__DIR__ . "/config.php");
|
/**
|
||||||
require_once(__DIR__ . "/db.php");
|
* User handling routines
|
||||||
|
*/
|
||||||
class uUser {
|
class uUser {
|
||||||
public $id;
|
public $id;
|
||||||
public $login;
|
public $login;
|
||||||
public $hash;
|
public $hash;
|
||||||
@ -29,6 +31,11 @@ class uUser {
|
|||||||
|
|
||||||
private static $db;
|
private static $db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param string $login Login
|
||||||
|
*/
|
||||||
public function __construct($login = NULL) {
|
public function __construct($login = NULL) {
|
||||||
self::$db = uDB::getInstance();
|
self::$db = uDB::getInstance();
|
||||||
if (!empty($login)) {
|
if (!empty($login)) {
|
||||||
@ -44,6 +51,13 @@ class uUser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add new user
|
||||||
|
*
|
||||||
|
* @param string $login Login
|
||||||
|
* @param string $hash Password hash
|
||||||
|
* @return int|bool New user id, false on error
|
||||||
|
*/
|
||||||
public function add($login, $hash) {
|
public function add($login, $hash) {
|
||||||
$userid = false;
|
$userid = false;
|
||||||
if (!empty($login) && !empty($hash)) {
|
if (!empty($login) && !empty($hash)) {
|
||||||
@ -59,6 +73,12 @@ class uUser {
|
|||||||
return $userid;
|
return $userid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set user password
|
||||||
|
*
|
||||||
|
* @param string $hash Hash
|
||||||
|
* @return bool True on success, false otherwise
|
||||||
|
*/
|
||||||
public function setPass($hash) {
|
public function setPass($hash) {
|
||||||
$ret = false;
|
$ret = false;
|
||||||
$sql = "UPDATE users SET password = ? WHERE login = ?";
|
$sql = "UPDATE users SET password = ? WHERE login = ?";
|
||||||
@ -72,14 +92,26 @@ class uUser {
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if given password matches user's one
|
||||||
|
*
|
||||||
|
* @param String $password Password
|
||||||
|
* @return bool True if matches, false otherwise
|
||||||
|
*/
|
||||||
public function validPassword($password) {
|
public function validPassword($password) {
|
||||||
return password_verify($password, $this->hash);
|
return password_verify($password, $this->hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store uUser object in session
|
||||||
|
*/
|
||||||
public function storeInSession() {
|
public function storeInSession() {
|
||||||
$_SESSION['user'] = $this;
|
$_SESSION['user'] = $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill uUser object properties from session data
|
||||||
|
*/
|
||||||
public function getFromSession() {
|
public function getFromSession() {
|
||||||
if (isset($_SESSION['user'])) {
|
if (isset($_SESSION['user'])) {
|
||||||
$sessionUser = $_SESSION['user'];
|
$sessionUser = $_SESSION['user'];
|
||||||
@ -91,6 +123,11 @@ class uUser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all users
|
||||||
|
*
|
||||||
|
* @return array|bool Array of uUser users, false on error
|
||||||
|
*/
|
||||||
public function getAll() {
|
public function getAll() {
|
||||||
$query = "SELECT id, login, password FROM users ORDER BY login";
|
$query = "SELECT id, login, password FROM users ORDER BY login";
|
||||||
$result = self::$db->query($query);
|
$result = self::$db->query($query);
|
||||||
@ -105,6 +142,12 @@ class uUser {
|
|||||||
return $userArr;
|
return $userArr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert database row to uUser
|
||||||
|
*
|
||||||
|
* @param array $row Row
|
||||||
|
* @return uUser User
|
||||||
|
*/
|
||||||
private function rowToObject($row) {
|
private function rowToObject($row) {
|
||||||
$user = new uUser();
|
$user = new uUser();
|
||||||
$user->id = $row['id'];
|
$user->id = $row['id'];
|
||||||
@ -115,10 +158,15 @@ class uUser {
|
|||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is given login admin user
|
||||||
|
*
|
||||||
|
* @param string $login Login
|
||||||
|
* @return bool True if admin, false otherwise
|
||||||
|
*/
|
||||||
private function isAdmin($login) {
|
private function isAdmin($login) {
|
||||||
$config = new uConfig();
|
$config = new uConfig();
|
||||||
return (!empty($config::$admin_user) && $config::$admin_user == $login);
|
return (!empty($config::$admin_user) && $config::$admin_user == $login);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
?>
|
|
@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once("auth.php");
|
require_once("auth.php");
|
||||||
require_once("helpers/position.php");
|
require_once("helpers/position.php");
|
||||||
require_once("helpers/track.php");
|
require_once("helpers/track.php");
|
||||||
@ -52,7 +52,7 @@ if ($user->isAdmin || $config::$public_tracks) {
|
|||||||
if ($lastPosition->isValid) {
|
if ($lastPosition->isValid) {
|
||||||
$lastUserId = $lastPosition->userId;
|
$lastUserId = $lastPosition->userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
$usersArr = $user->getAll();
|
$usersArr = $user->getAll();
|
||||||
if (!empty($usersArr)) {
|
if (!empty($usersArr)) {
|
||||||
foreach ($usersArr as $aUser) {
|
foreach ($usersArr as $aUser) {
|
||||||
|
4
lang.php
4
lang.php
@ -16,9 +16,9 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// available languages
|
// available languages
|
||||||
$langsArr = [
|
$langsArr = [
|
||||||
"en" => "English",
|
"en" => "English",
|
||||||
"pl" => "Polski",
|
"pl" => "Polski",
|
||||||
"de" => "Deutsch",
|
"de" => "Deutsch",
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$lang["title"] = "• μlogger •";
|
$lang["title"] = "• μlogger •";
|
||||||
$lang["private"] = "Sie müssen Benutzernamen und Kennwort eingeben, um auf diese Seite zuzugreifen.";
|
$lang["private"] = "Sie müssen Benutzernamen und Kennwort eingeben, um auf diese Seite zuzugreifen.";
|
||||||
$lang["authfail"] = "Falscher Benutzername oder Passwort";
|
$lang["authfail"] = "Falscher Benutzername oder Passwort";
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// default language for translations
|
// default language for translations
|
||||||
|
|
||||||
$lang["title"] = "• μlogger •";
|
$lang["title"] = "• μlogger •";
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$lang["title"] = "• μlogger •";
|
$lang["title"] = "• μlogger •";
|
||||||
$lang["private"] = "Necesitas un nombre de usuario y contraseña para acceder a esta página.";
|
$lang["private"] = "Necesitas un nombre de usuario y contraseña para acceder a esta página.";
|
||||||
$lang["authfail"] = "Nombre de usuasrio o contraseña erroneos";
|
$lang["authfail"] = "Nombre de usuasrio o contraseña erroneos";
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$lang["title"] = "• μlogger •";
|
$lang["title"] = "• μlogger •";
|
||||||
$lang["private"] = "Il faut un nom d'utilisateur et un mot de passe pour accéder à cette page.";
|
$lang["private"] = "Il faut un nom d'utilisateur et un mot de passe pour accéder à cette page.";
|
||||||
$lang["authfail"] = "Nom d'utilisateur ou mot de passe erroné.";
|
$lang["authfail"] = "Nom d'utilisateur ou mot de passe erroné.";
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$lang["title"] = "• μlogger •";
|
$lang["title"] = "• μlogger •";
|
||||||
$lang["private"] = "Felhasználónév és jelszó szükséges a belépéshez";
|
$lang["private"] = "Felhasználónév és jelszó szükséges a belépéshez";
|
||||||
$lang["authfail"] = "Hibás név vagy jelszó";
|
$lang["authfail"] = "Hibás név vagy jelszó";
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
$lang["title"] = "• μlogger •";
|
$lang["title"] = "• μlogger •";
|
||||||
$lang["private"] = "Aby się zalogować musisz podać login i hasło";
|
$lang["private"] = "Aby się zalogować musisz podać login i hasło";
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
session_name('ulogger');
|
session_name('ulogger');
|
||||||
session_start();
|
session_start();
|
||||||
$_SESSION = NULL;
|
$_SESSION = NULL;
|
||||||
@ -27,4 +27,5 @@ session_destroy();
|
|||||||
$ssl = ((!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "" || $_SERVER['HTTPS'] == "off") ? "http" : "https");
|
$ssl = ((!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "" || $_SERVER['HTTPS'] == "off") ? "http" : "https");
|
||||||
$url = str_replace("//", "/", $_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME'])."/index.php");
|
$url = str_replace("//", "/", $_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME'])."/index.php");
|
||||||
header("Location: $ssl://$url");
|
header("Location: $ssl://$url");
|
||||||
?>
|
|
||||||
|
?>
|
8
main.css
8
main.css
@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
html {
|
html {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
@ -195,8 +195,8 @@ select {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.mi {
|
.mi {
|
||||||
color:white;
|
color:white;
|
||||||
padding-right:0.1em;
|
padding-right:0.1em;
|
||||||
font-style:italic;
|
font-style:italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ select {
|
|||||||
-webkit-border-radius: 5px;
|
-webkit-border-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
260
main.js
260
main.js
@ -16,8 +16,8 @@
|
|||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// general stuff
|
// general stuff
|
||||||
if (units=='imperial') {
|
if (units == 'imperial') {
|
||||||
factor_kmh = 0.62; //to mph
|
factor_kmh = 0.62; //to mph
|
||||||
unit_kmh = 'mph';
|
unit_kmh = 'mph';
|
||||||
factor_m = 3.28; // to feet
|
factor_m = 3.28; // to feet
|
||||||
@ -45,12 +45,12 @@ function displayChart() {
|
|||||||
data.addColumn('number', 'id');
|
data.addColumn('number', 'id');
|
||||||
data.addColumn('number', 'altitude');
|
data.addColumn('number', 'altitude');
|
||||||
var altLen = altitudes.length;
|
var altLen = altitudes.length;
|
||||||
for (var i=0; i<altLen; i++) {
|
for (var i = 0; i < altLen; i++) {
|
||||||
data.addRow([(i+1),Math.round((altitudes[i]*factor_m))]);
|
data.addRow([(i + 1), Math.round((altitudes[i] * factor_m))]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
title: lang['altitude']+' ('+unit_m+')',
|
title: lang['altitude'] + ' (' + unit_m + ')',
|
||||||
hAxis: { textPosition: 'none' },
|
hAxis: { textPosition: 'none' },
|
||||||
legend: { position: 'none' }
|
legend: { position: 'none' }
|
||||||
};
|
};
|
||||||
@ -63,13 +63,13 @@ function displayChart() {
|
|||||||
|
|
||||||
function toggleChart(i) {
|
function toggleChart(i) {
|
||||||
var altLen = altitudes.length;
|
var altLen = altitudes.length;
|
||||||
if (altLen<=1) { return; }
|
if (altLen <= 1) { return; }
|
||||||
var e = document.getElementById('bottom');
|
var e = document.getElementById('bottom');
|
||||||
if (arguments.length < 1) {
|
if (arguments.length < 1) {
|
||||||
if (e.style.display == 'block') { i = 0 }
|
if (e.style.display == 'block') { i = 0 }
|
||||||
else { i = 1; }
|
else { i = 1; }
|
||||||
}
|
}
|
||||||
if (i==0) {
|
if (i == 0) {
|
||||||
chart.clearChart();
|
chart.clearChart();
|
||||||
e.style.display = 'none';
|
e.style.display = 'none';
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ function toggleMenu(i) {
|
|||||||
if (ebutton.innerHTML == '»') { i = 0 }
|
if (ebutton.innerHTML == '»') { i = 0 }
|
||||||
else { i = 1; }
|
else { i = 1; }
|
||||||
}
|
}
|
||||||
if (i==0) {
|
if (i == 0) {
|
||||||
emenu.style.width = '0';
|
emenu.style.width = '0';
|
||||||
emain.style.marginRight = '0';
|
emain.style.marginRight = '0';
|
||||||
ebutton.style.right = '0';
|
ebutton.style.right = '0';
|
||||||
@ -104,52 +104,52 @@ function toggleMenu(i) {
|
|||||||
function getXHR() {
|
function getXHR() {
|
||||||
var xmlhttp = null;
|
var xmlhttp = null;
|
||||||
if (window.XMLHttpRequest) {
|
if (window.XMLHttpRequest) {
|
||||||
xmlhttp=new XMLHttpRequest();
|
xmlhttp = new XMLHttpRequest();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
|
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
|
||||||
}
|
}
|
||||||
return xmlhttp;
|
return xmlhttp;
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadTrack(userid,trackid,update) {
|
function loadTrack(userid, trackid, update) {
|
||||||
if (latest==1) { trackid=0; }
|
if (latest == 1) { trackid = 0; }
|
||||||
var xhr = getXHR();
|
var xhr = getXHR();
|
||||||
xhr.onreadystatechange = function() {
|
xhr.onreadystatechange = function () {
|
||||||
if (xhr.readyState==4 && xhr.status==200) {
|
if (xhr.readyState == 4 && xhr.status == 200) {
|
||||||
var xml = xhr.responseXML;
|
var xml = xhr.responseXML;
|
||||||
var positions = xml.getElementsByTagName('position');
|
var positions = xml.getElementsByTagName('position');
|
||||||
if (positions.length>0) {
|
if (positions.length > 0) {
|
||||||
clearMap();
|
clearMap();
|
||||||
displayTrack(xml,update);
|
displayTrack(xml, update);
|
||||||
}
|
}
|
||||||
xhr = null;
|
xhr = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xhr.open('GET','getpositions.php?trackid='+trackid+'&userid='+userid,true);
|
xhr.open('GET', 'getpositions.php?trackid=' + trackid + '&userid=' + userid, true);
|
||||||
xhr.send();
|
xhr.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
function parsePosition(p) {
|
function parsePosition(p) {
|
||||||
// read data
|
// read data
|
||||||
var latitude = getNode(p,'latitude');
|
var latitude = getNode(p, 'latitude');
|
||||||
var longitude = getNode(p,'longitude');
|
var longitude = getNode(p, 'longitude');
|
||||||
var altitude = getNode(p,'altitude'); // may be null
|
var altitude = getNode(p, 'altitude'); // may be null
|
||||||
if (altitude != null) { altitude = parseInt(altitude); }
|
if (altitude != null) { altitude = parseInt(altitude); }
|
||||||
var speed = getNode(p,'speed'); // may be null
|
var speed = getNode(p, 'speed'); // may be null
|
||||||
if (speed != null) { speed = parseInt(speed); }
|
if (speed != null) { speed = parseInt(speed); }
|
||||||
var bearing = getNode(p,'bearing'); // may be null
|
var bearing = getNode(p, 'bearing'); // may be null
|
||||||
if (bearing != null) { bearing = parseInt(bearing); }
|
if (bearing != null) { bearing = parseInt(bearing); }
|
||||||
var accuracy = getNode(p,'accuracy'); // may be null
|
var accuracy = getNode(p, 'accuracy'); // may be null
|
||||||
if (accuracy != null) { accuracy = parseInt(accuracy); }
|
if (accuracy != null) { accuracy = parseInt(accuracy); }
|
||||||
var provider = getNode(p,'provider'); // may be null
|
var provider = getNode(p, 'provider'); // may be null
|
||||||
var comments = getNode(p,'comments'); // may be null
|
var comments = getNode(p, 'comments'); // may be null
|
||||||
var username = getNode(p,'username');
|
var username = getNode(p, 'username');
|
||||||
var trackname = getNode(p,'trackname');
|
var trackname = getNode(p, 'trackname');
|
||||||
var tid = getNode(p,'trackid');
|
var tid = getNode(p, 'trackid');
|
||||||
var dateoccured = getNode(p,'dateoccured');
|
var dateoccured = getNode(p, 'dateoccured');
|
||||||
var distance = parseInt(getNode(p,'distance'));
|
var distance = parseInt(getNode(p, 'distance'));
|
||||||
var seconds = parseInt(getNode(p,'seconds'));
|
var seconds = parseInt(getNode(p, 'seconds'));
|
||||||
return {
|
return {
|
||||||
'latitude': latitude,
|
'latitude': latitude,
|
||||||
'longitude': longitude,
|
'longitude': longitude,
|
||||||
@ -174,88 +174,97 @@ function getPopupHtml(p, i, count) {
|
|||||||
var time = dateTime[1];
|
var time = dateTime[1];
|
||||||
var provider = '';
|
var provider = '';
|
||||||
if (p.provider == 'gps') {
|
if (p.provider == 'gps') {
|
||||||
provider = ' (<img class="icon" alt="'+lang['gps']+'" title="'+lang['gps']+'" src="images/gps_dark.svg" />)';
|
provider = ' (<img class="icon" alt="' + lang['gps'] + '" title="' + lang['gps'] + '" src="images/gps_dark.svg" />)';
|
||||||
} else if (p.provider == 'network') {
|
} else if (p.provider == 'network') {
|
||||||
provider = ' (<img class="icon" alt="'+lang['network']+'" title="'+lang['network']+'" src="images/network_dark.svg" />)';
|
provider = ' (<img class="icon" alt="' + lang['network'] + '" title="' + lang['network'] + '" src="images/network_dark.svg" />)';
|
||||||
}
|
}
|
||||||
popup =
|
var stats = '';
|
||||||
'<div id="popup">'+
|
if (latest == 0) {
|
||||||
'<div id="pheader">'+
|
stats =
|
||||||
'<div><img alt="'+lang['user']+'" title="'+lang['user']+'" src="images/user_dark.svg" /> '+p.username+'</div>'+
|
'<div id="pright">' +
|
||||||
'<div><img alt="'+lang['track']+'" title="'+lang['track']+'" src="images/route_dark.svg" /> '+p.trackname+'</div>'+
|
'<img class="icon" src="images/stats_blue.svg" style="padding-left: 3em;" /><br />' +
|
||||||
'</div>'+
|
'<img class="icon" alt="' + lang['ttime'] + '" title="' + lang['ttime'] + '" src="images/time_blue.svg" /> ' +
|
||||||
'<div id="pbody">'+
|
p.totalSeconds.toHMS() + '<br />' +
|
||||||
((p.comments != null)?'<div id="pcomments">'+p.comments+'</div>':'')+
|
'<img class="icon" alt="' + lang['aspeed'] + '" title="' + lang['aspeed'] + '" src="images/speed_blue.svg" /> ' +
|
||||||
'<div id="pleft">'+
|
((p.totalSeconds > 0) ? ((p.totalMeters / p.totalSeconds).toKmH() * factor_kmh).toFixed() : 0) + ' ' + unit_kmh + '<br />' +
|
||||||
'<img class="icon" alt="'+lang['time']+'" title="'+lang['time']+'" src="images/calendar_dark.svg" /> '+date+'<br />'+
|
'<img class="icon" alt="' + lang['tdistance'] + '" title="' + lang['tdistance'] + '" src="images/distance_blue.svg" /> ' +
|
||||||
'<img class="icon" alt="'+lang['time']+'" title="'+lang['time']+'" src="images/clock_dark.svg" /> '+time+'<br />'+
|
(p.totalMeters.toKm() * factor_km).toFixed(2) + ' ' + unit_km + '<br />' + '</div>';
|
||||||
((p.speed != null)?'<img class="icon" alt="'+lang['speed']+'" title="'+lang['speed']+'" src="images/speed_dark.svg" /> '+(p.speed.toKmH()*factor_kmh)+' '+unit_kmh+'<br />':'')+
|
}
|
||||||
((p.altitude != null)?'<img class="icon" alt="'+lang['altitude']+'" title="'+lang['altitude']+'" src="images/altitude_dark.svg" /> '+(p.altitude*factor_m).toFixed()+' '+unit_m+'<br />':'')+
|
popup =
|
||||||
((p.accuracy != null)?'<img class="icon" alt="'+lang['accuracy']+'" title="'+lang['accuracy']+'" src="images/accuracy_dark.svg" /> '+(p.accuracy*factor_m).toFixed()+' '+unit_m+provider+'<br />':'')+
|
'<div id="popup">' +
|
||||||
'</div>'+
|
'<div id="pheader">' +
|
||||||
((latest==0)?
|
'<div><img alt="' + lang['user'] + '" title="' + lang['user'] + '" src="images/user_dark.svg" /> ' + p.username + '</div>' +
|
||||||
('<div id="pright">'+
|
'<div><img alt="' + lang['track'] + '" title="' + lang['track'] + '" src="images/route_dark.svg" /> ' + p.trackname + '</div>' +
|
||||||
'<img class="icon" src="images/stats_blue.svg" style="padding-left: 3em;" /><br />'+
|
'</div>' +
|
||||||
'<img class="icon" alt="'+lang['ttime']+'" title="'+lang['ttime']+'" src="images/time_blue.svg" /> '+p.totalSeconds.toHMS()+'<br />'+
|
'<div id="pbody">' +
|
||||||
'<img class="icon" alt="'+lang['aspeed']+'" title="'+lang['aspeed']+'" src="images/speed_blue.svg" /> '+((p.totalSeconds>0)?((p.totalMeters/p.totalSeconds).toKmH()*factor_kmh).toFixed():0)+' '+unit_kmh+'<br />'+
|
((p.comments != null) ? '<div id="pcomments">' + p.comments + '</div>' : '') +
|
||||||
'<img class="icon" alt="'+lang['tdistance']+'" title="'+lang['tdistance']+'" src="images/distance_blue.svg" /> '+(p.totalMeters.toKm()*factor_km).toFixed(2)+' '+unit_km+'<br />'+'</div>')
|
'<div id="pleft">' +
|
||||||
:
|
'<img class="icon" alt="' + lang['time'] + '" title="' + lang['time'] + '" src="images/calendar_dark.svg" /> ' + date + '<br />' +
|
||||||
'')+
|
'<img class="icon" alt="' + lang['time'] + '" title="' + lang['time'] + '" src="images/clock_dark.svg" /> ' + time + '<br />' +
|
||||||
'<div id="pfooter">'+lang['point']+' '+(i + 1)+' '+lang['of']+' '+count+'</div>'+
|
((p.speed != null) ? '<img class="icon" alt="' + lang['speed'] + '" title="' + lang['speed'] + '" src="images/speed_dark.svg" /> ' +
|
||||||
'</div></div>';
|
(p.speed.toKmH() * factor_kmh) + ' ' + unit_kmh + '<br />' : '') +
|
||||||
|
((p.altitude != null) ? '<img class="icon" alt="' + lang['altitude'] + '" title="' + lang['altitude'] + '" src="images/altitude_dark.svg" /> ' +
|
||||||
|
(p.altitude * factor_m).toFixed() + ' ' + unit_m + '<br />' : '') +
|
||||||
|
((p.accuracy != null) ? '<img class="icon" alt="' + lang['accuracy'] + '" title="' + lang['accuracy'] + '" src="images/accuracy_dark.svg" /> ' +
|
||||||
|
(p.accuracy * factor_m).toFixed() + ' ' + unit_m + provider + '<br />' : '') +
|
||||||
|
'</div>' +
|
||||||
|
stats +
|
||||||
|
'<div id="pfooter">' + lang['point'] + ' ' + (i + 1) + ' ' + lang['of'] + ' ' + count + '</div>' +
|
||||||
|
'</div></div>';
|
||||||
return popup;
|
return popup;
|
||||||
}
|
}
|
||||||
|
|
||||||
function load(type,userid,trackid) {
|
function load(type, userid, trackid) {
|
||||||
var url = 'download.php?type='+type+'&userid='+userid+'&trackid='+trackid;
|
var url = 'download.php?type=' + type + '&userid=' + userid + '&trackid=' + trackid;
|
||||||
window.location.assign(url);
|
window.location.assign(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSummary(l,d,s) {
|
function updateSummary(l, d, s) {
|
||||||
var t = document.getElementById('summary');
|
var t = document.getElementById('summary');
|
||||||
if (latest==0){
|
if (latest == 0) {
|
||||||
t.innerHTML = '<u>'+lang['summary']+'</u><br />'+
|
t.innerHTML = '<u>' + lang['summary'] + '</u><br />' +
|
||||||
'<span><img class="icon" alt="'+lang['tdistance']+'" title="'+lang['tdistance']+'" src="images/distance.svg" /> '+(d.toKm()*factor_km).toFixed(2)+' '+unit_km+'</span>'+
|
'<span><img class="icon" alt="' + lang['tdistance'] + '" title="' + lang['tdistance'] + '" src="images/distance.svg" /> ' + (d.toKm() * factor_km).toFixed(2) + ' ' + unit_km + '</span>' +
|
||||||
'<span><img class="icon" alt="'+lang['ttime']+'" title="'+lang['ttime']+'" src="images/time.svg" /> '+s.toHMS()+'</span>';
|
'<span><img class="icon" alt="' + lang['ttime'] + '" title="' + lang['ttime'] + '" src="images/time.svg" /> ' + s.toHMS() + '</span>';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
t.innerHTML = '<u>'+lang['latest']+':</u><br />'+l;
|
t.innerHTML = '<u>' + lang['latest'] + ':</u><br />' + l;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNode(p,name) {
|
function getNode(p, name) {
|
||||||
return ((p.getElementsByTagName(name)[0].childNodes[0]) ? p.getElementsByTagName(name)[0].childNodes[0].nodeValue : null);
|
return ((p.getElementsByTagName(name)[0].childNodes[0]) ? p.getElementsByTagName(name)[0].childNodes[0].nodeValue : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// seconds to (d) H:M:S
|
// seconds to (d) H:M:S
|
||||||
Number.prototype.toHMS = function(){
|
Number.prototype.toHMS = function () {
|
||||||
var s = this;
|
var s = this;
|
||||||
var d = Math.floor(s / 86400);
|
var d = Math.floor(s / 86400);
|
||||||
var h = Math.floor((s % 86400) / 3600);
|
var h = Math.floor((s % 86400) / 3600);
|
||||||
var m = Math.floor(((s % 86400) % 3600) / 60);
|
var m = Math.floor(((s % 86400) % 3600) / 60);
|
||||||
s = ((s % 86400) % 3600) % 60;
|
s = ((s % 86400) % 3600) % 60;
|
||||||
|
|
||||||
return ((d>0)?(d + ' d '):'') + (('00'+h).slice(-2)) + ':' + (('00'+m).slice(-2)) + ':' + (('00'+s).slice(-2)) + '';
|
return ((d > 0) ? (d + ' d ') : '') + (('00' + h).slice(-2)) + ':' + (('00' + m).slice(-2)) + ':' + (('00' + s).slice(-2)) + '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// meters to km
|
// meters to km
|
||||||
Number.prototype.toKm = function() {
|
Number.prototype.toKm = function () {
|
||||||
return Math.round(this/10)/100;
|
return Math.round(this / 10) / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
// m/s to km/h
|
// m/s to km/h
|
||||||
Number.prototype.toKmH = function() {
|
Number.prototype.toKmH = function () {
|
||||||
return Math.round(this*3600/10)/100;
|
return Math.round(this * 3600 / 10) / 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
// negate value
|
// negate value
|
||||||
function toggleLatest() {
|
function toggleLatest() {
|
||||||
if (latest==0) {
|
if (latest == 0) {
|
||||||
latest = 1;
|
latest = 1;
|
||||||
loadTrack(userid,0,1);
|
loadTrack(userid, 0, 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
latest = 0;
|
latest = 0;
|
||||||
loadTrack(userid,trackid,1);
|
loadTrack(userid, trackid, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,31 +273,31 @@ function setTrack(t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function selectTrack(f) {
|
function selectTrack(f) {
|
||||||
trackid=f.options[f.selectedIndex].value;
|
trackid = f.options[f.selectedIndex].value;
|
||||||
document.getElementById('latest').checked = false;
|
document.getElementById('latest').checked = false;
|
||||||
if (latest==1) { toggleLatest(); }
|
if (latest == 1) { toggleLatest(); }
|
||||||
loadTrack(userid,trackid,1);
|
loadTrack(userid, trackid, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectUser(f) {
|
function selectUser(f) {
|
||||||
userid=f.options[f.selectedIndex].value;
|
userid = f.options[f.selectedIndex].value;
|
||||||
if (f.options[0].disabled==false) {
|
if (f.options[0].disabled == false) {
|
||||||
f.options[0].disabled = true;
|
f.options[0].disabled = true;
|
||||||
}
|
}
|
||||||
document.getElementById('latest').checked = false;
|
document.getElementById('latest').checked = false;
|
||||||
if (latest==1) { toggleLatest(); }
|
if (latest == 1) { toggleLatest(); }
|
||||||
getTracks(userid);
|
getTracks(userid);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTracks(userid) {
|
function getTracks(userid) {
|
||||||
var xhr = getXHR();
|
var xhr = getXHR();
|
||||||
xhr.onreadystatechange = function() {
|
xhr.onreadystatechange = function () {
|
||||||
if (xhr.readyState==4 && xhr.status==200) {
|
if (xhr.readyState == 4 && xhr.status == 200) {
|
||||||
var xml = xhr.responseXML;
|
var xml = xhr.responseXML;
|
||||||
var trackSelect = document.getElementsByName('track')[0];
|
var trackSelect = document.getElementsByName('track')[0];
|
||||||
clearOptions(trackSelect);
|
clearOptions(trackSelect);
|
||||||
var tracks = xml.getElementsByTagName('track');
|
var tracks = xml.getElementsByTagName('track');
|
||||||
if (tracks.length>0) {
|
if (tracks.length > 0) {
|
||||||
fillOptions(xml);
|
fillOptions(xml);
|
||||||
} else {
|
} else {
|
||||||
clearMap();
|
clearMap();
|
||||||
@ -296,27 +305,27 @@ function getTracks(userid) {
|
|||||||
xhr = null;
|
xhr = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xhr.open('GET','gettracks.php?userid='+userid,true);
|
xhr.open('GET', 'gettracks.php?userid=' + userid, true);
|
||||||
xhr.send();
|
xhr.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
function fillOptions(xml) {
|
function fillOptions(xml) {
|
||||||
var trackSelect = document.getElementsByName('track')[0];
|
var trackSelect = document.getElementsByName('track')[0];
|
||||||
var tracks = xml.getElementsByTagName('track');
|
var tracks = xml.getElementsByTagName('track');
|
||||||
var trackLen = tracks.length;
|
var trackLen = tracks.length;
|
||||||
for (var i=0; i<trackLen; i++) {
|
for (var i = 0; i < trackLen; i++) {
|
||||||
var trackid = getNode(tracks[i],'trackid');
|
var trackid = getNode(tracks[i], 'trackid');
|
||||||
var trackname = getNode(tracks[i],'trackname');
|
var trackname = getNode(tracks[i], 'trackname');
|
||||||
var option = document.createElement("option");
|
var option = document.createElement("option");
|
||||||
option.value = trackid;
|
option.value = trackid;
|
||||||
option.innerHTML = trackname;
|
option.innerHTML = trackname;
|
||||||
trackSelect.appendChild(option);
|
trackSelect.appendChild(option);
|
||||||
}
|
}
|
||||||
var defaultTrack = getNode(tracks[0],'trackid');
|
var defaultTrack = getNode(tracks[0], 'trackid');
|
||||||
loadTrack(userid,defaultTrack,1);
|
loadTrack(userid, defaultTrack, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearOptions(el){
|
function clearOptions(el) {
|
||||||
if (el.options) {
|
if (el.options) {
|
||||||
while (el.options.length) {
|
while (el.options.length) {
|
||||||
el.remove(0);
|
el.remove(0);
|
||||||
@ -326,9 +335,9 @@ function clearOptions(el){
|
|||||||
|
|
||||||
var auto;
|
var auto;
|
||||||
function autoReload() {
|
function autoReload() {
|
||||||
if (live==0) {
|
if (live == 0) {
|
||||||
live = 1;
|
live = 1;
|
||||||
auto = setInterval(function() { loadTrack(userid,trackid,0); },interval*1000);
|
auto = setInterval(function () { loadTrack(userid, trackid, 0); }, interval * 1000);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
live = 0;
|
live = 0;
|
||||||
@ -338,17 +347,17 @@ function autoReload() {
|
|||||||
|
|
||||||
function setTime() {
|
function setTime() {
|
||||||
var i = parseInt(prompt(lang['newinterval']));
|
var i = parseInt(prompt(lang['newinterval']));
|
||||||
if (!isNaN(i) && i!=interval) {
|
if (!isNaN(i) && i != interval) {
|
||||||
interval = i;
|
interval = i;
|
||||||
document.getElementById('auto').innerHTML = interval;
|
document.getElementById('auto').innerHTML = interval;
|
||||||
// if live tracking on, reload with new interval
|
// if live tracking on, reload with new interval
|
||||||
if (live==1) {
|
if (live == 1) {
|
||||||
live = 0;
|
live = 0;
|
||||||
clearInterval(auto);
|
clearInterval(auto);
|
||||||
autoReload();
|
autoReload();
|
||||||
}
|
}
|
||||||
// save current state as default
|
// save current state as default
|
||||||
setCookie('interval',interval,30);
|
setCookie('interval', interval, 30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,26 +367,27 @@ 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+'&'):'')+'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('//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;
|
||||||
@ -386,26 +396,26 @@ function waitAndLoad(api,url) {
|
|||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -414,32 +424,32 @@ 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 = 'ulogger_'+name+'='+value+expires+'; path=/';
|
document.cookie = 'ulogger_' + name + '=' + value + expires + '; path=/';
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLang(lang) {
|
function setLang(lang) {
|
||||||
setCookie('lang',lang,30);
|
setCookie('lang', lang, 30);
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUnits(unit) {
|
function setUnits(unit) {
|
||||||
units = unit;
|
units = unit;
|
||||||
setCookie('units',unit,30);
|
setCookie('units', unit, 30);
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,7 +473,7 @@ function userMenu() {
|
|||||||
} else {
|
} else {
|
||||||
dropdown.classList.add('show');
|
dropdown.classList.add('show');
|
||||||
window.addEventListener('click', removeOnClick, true);
|
window.addEventListener('click', removeOnClick, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeOnClick(event) {
|
function removeOnClick(event) {
|
||||||
|
6
pass.js
6
pass.js
@ -40,12 +40,12 @@ function submitPass() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var xhr = getXHR();
|
var xhr = getXHR();
|
||||||
xhr.onreadystatechange = function() {
|
xhr.onreadystatechange = function () {
|
||||||
if (xhr.readyState==4 && xhr.status==200) {
|
if (xhr.readyState == 4 && xhr.status == 200) {
|
||||||
var xml = xhr.responseXML;
|
var xml = xhr.responseXML;
|
||||||
var message = "";
|
var message = "";
|
||||||
if (xml) {
|
if (xml) {
|
||||||
var root = xml.getElementsByTagName('root');
|
var root = xml.getElementsByTagName('root');
|
||||||
if (root.length && getNode(root[0], 'error') == 0) {
|
if (root.length && getNode(root[0], 'error') == 0) {
|
||||||
removeModal();
|
removeModal();
|
||||||
alert("Password successfully changed");
|
alert("Password successfully changed");
|
||||||
|
@ -21,10 +21,10 @@
|
|||||||
*
|
*
|
||||||
* However, as μlogger users more secure password storage methods,
|
* However, as μlogger users more secure password storage methods,
|
||||||
* it is impossible to convert old password hashes to the new format.
|
* it is impossible to convert old password hashes to the new format.
|
||||||
* Administrator will have to fill in user passwords manually.
|
* Administrator will have to fill in user passwords manually.
|
||||||
* Alternatively authentication code could be modify in order to
|
* Alternatively authentication code could be modify in order to
|
||||||
* temporarily accept old hashes and convert it as users log in.
|
* temporarily accept old hashes and convert it as users log in.
|
||||||
* It should be pretty simple, but this is not a top priority
|
* It should be pretty simple, but this is not a top priority
|
||||||
* for this small project.
|
* for this small project.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user