Enforce admin privileges
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* GPX to GeoJSON Converter
|
* GPX to GeoJSON Converter
|
||||||
*
|
*
|
||||||
* To convert a gpx file:
|
* To convert a gpx file:
|
||||||
* 1. Add file <file_name>.gpx to geo/ folder
|
* 1. Add file <file_name>.gpx to geo/ folder
|
||||||
* 2. Assign file to project: UPDATE projects SET codename = '<file_name>' WHERE id_project = <id_project>;
|
* 2. Assign file to project: UPDATE projects SET codename = '<file_name>' WHERE id_project = <id_project>;
|
||||||
@@ -12,23 +12,23 @@
|
|||||||
* ?a=build_geojson&name=<file_name>
|
* ?a=build_geojson&name=<file_name>
|
||||||
*/
|
*/
|
||||||
class Converter extends PhpObject {
|
class Converter extends PhpObject {
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct(__CLASS__, Settings::DEBUG);
|
parent::__construct(__CLASS__, Settings::DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function convertToGeoJson($sCodeName) {
|
public static function convertToGeoJson($sCodeName) {
|
||||||
$oGpx = new Gpx($sCodeName);
|
$oGpx = new Gpx($sCodeName);
|
||||||
$oGeoJson = new GeoJson($sCodeName);
|
$oGeoJson = new GeoJson($sCodeName);
|
||||||
|
|
||||||
$oGeoJson->buildTracks($oGpx->getTracks());
|
$oGeoJson->buildTracks($oGpx->getTracks());
|
||||||
if($oGeoJson->isSimplicationRequired()) $oGeoJson->buildTracks($oGpx->getTracks(), true);
|
if($oGeoJson->isSimplicationRequired()) $oGeoJson->buildTracks($oGpx->getTracks(), true);
|
||||||
$oGeoJson->sortOffTracks();
|
$oGeoJson->sortOffTracks();
|
||||||
$oGeoJson->saveFile();
|
$oGeoJson->saveFile();
|
||||||
|
|
||||||
return $oGpx->getLog().'<br />'.$oGeoJson->getLog();
|
return $oGpx->getLog().'<br />'.$oGeoJson->getLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isGeoJsonValid($sCodeName) {
|
public static function isGeoJsonValid($sCodeName) {
|
||||||
$bResult = false;
|
$bResult = false;
|
||||||
$sGeoJsonFilePath = Geo::getFilePath($sCodeName, GeoJson::EXT);
|
$sGeoJsonFilePath = Geo::getFilePath($sCodeName, GeoJson::EXT);
|
||||||
@@ -38,23 +38,23 @@ class Converter extends PhpObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Geo extends PhpObject {
|
class Geo extends PhpObject {
|
||||||
|
|
||||||
const GEO_FOLDER = 'geo/';
|
const GEO_FOLDER = 'geo/';
|
||||||
const OPT_SIMPLE = 'simplification';
|
const OPT_SIMPLE = 'simplification';
|
||||||
|
|
||||||
protected $asTracks;
|
protected $asTracks;
|
||||||
protected $sFilePath;
|
protected $sFilePath;
|
||||||
|
|
||||||
public function __construct($sCodeName) {
|
public function __construct($sCodeName) {
|
||||||
parent::__construct(get_class($this), Settings::DEBUG, PhpObject::MODE_HTML);
|
parent::__construct(get_class($this), Settings::DEBUG, PhpObject::MODE_HTML);
|
||||||
$this->sFilePath = self::getFilePath($sCodeName, static::EXT);
|
$this->sFilePath = self::getFilePath($sCodeName, static::EXT);
|
||||||
$this->asTracks = array();
|
$this->asTracks = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getFilePath($sCodeName, $sExt) {
|
public static function getFilePath($sCodeName, $sExt) {
|
||||||
return self::GEO_FOLDER.$sCodeName.$sExt;
|
return self::GEO_FOLDER.$sCodeName.$sExt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLog() {
|
public function getLog() {
|
||||||
return $this->getCleanMessageStack(PhpObject::NOTICE_TAB);
|
return $this->getCleanMessageStack(PhpObject::NOTICE_TAB);
|
||||||
}
|
}
|
||||||
@@ -63,20 +63,20 @@ class Geo extends PhpObject {
|
|||||||
class Gpx extends Geo {
|
class Gpx extends Geo {
|
||||||
|
|
||||||
const EXT = '.gpx';
|
const EXT = '.gpx';
|
||||||
|
|
||||||
public function __construct($sCodeName) {
|
public function __construct($sCodeName) {
|
||||||
parent::__construct($sCodeName);
|
parent::__construct($sCodeName);
|
||||||
$this->parseFile();
|
$this->parseFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTracks() {
|
public function getTracks() {
|
||||||
return $this->asTracks;
|
return $this->asTracks;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function parseFile() {
|
private function parseFile() {
|
||||||
$this->addNotice('Parsing: '.$this->sFilePath);
|
$this->addNotice('Parsing: '.$this->sFilePath);
|
||||||
$oXml = simplexml_load_file($this->sFilePath);
|
$oXml = simplexml_load_file($this->sFilePath);
|
||||||
|
|
||||||
//Tracks
|
//Tracks
|
||||||
$this->addNotice('Converting '.count($oXml->trk).' tracks');
|
$this->addNotice('Converting '.count($oXml->trk).' tracks');
|
||||||
foreach($oXml->trk as $aoTrack) {
|
foreach($oXml->trk as $aoTrack) {
|
||||||
@@ -87,7 +87,7 @@ class Gpx extends Geo {
|
|||||||
'color' => (string) $aoTrack->extensions->children('gpxx', true)->TrackExtension->DisplayColor,
|
'color' => (string) $aoTrack->extensions->children('gpxx', true)->TrackExtension->DisplayColor,
|
||||||
'points'=> array()
|
'points'=> array()
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($aoTrack->trkseg as $asSegment) {
|
foreach($aoTrack->trkseg as $asSegment) {
|
||||||
foreach($asSegment as $asPoint) {
|
foreach($asSegment as $asPoint) {
|
||||||
$asTrack['points'][] = array(
|
$asTrack['points'][] = array(
|
||||||
@@ -99,52 +99,52 @@ class Gpx extends Geo {
|
|||||||
}
|
}
|
||||||
$this->asTracks[] = $asTrack;
|
$this->asTracks[] = $asTrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Waypoints
|
//Waypoints
|
||||||
$this->addNotice('Ignoring '.count($oXml->wpt).' waypoints');
|
$this->addNotice('Ignoring '.count($oXml->wpt).' waypoints');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GeoJson extends Geo {
|
class GeoJson extends Geo {
|
||||||
|
|
||||||
const EXT = '.geojson';
|
const EXT = '.geojson';
|
||||||
const MAX_FILESIZE = 2; //MB
|
const MAX_FILESIZE = 2; //MB
|
||||||
const MAX_DEVIATION_FLAT = 0.1; //10%
|
const MAX_DEVIATION_FLAT = 0.1; //10%
|
||||||
const MAX_DEVIATION_ELEV = 0.1; //20%
|
const MAX_DEVIATION_ELEV = 0.1; //10%
|
||||||
|
|
||||||
public function __construct($sCodeName) {
|
public function __construct($sCodeName) {
|
||||||
parent::__construct($sCodeName);
|
parent::__construct($sCodeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveFile() {
|
public function saveFile() {
|
||||||
$this->addNotice('Saving '.$this->sFilePath);
|
$this->addNotice('Saving '.$this->sFilePath);
|
||||||
file_put_contents($this->sFilePath, $this->buildGeoJson());
|
file_put_contents($this->sFilePath, $this->buildGeoJson());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isSimplicationRequired() {
|
public function isSimplicationRequired() {
|
||||||
//Size in bytes
|
//Size in bytes
|
||||||
$iFileSize = strlen($this->buildGeoJson());
|
$iFileSize = strlen($this->buildGeoJson());
|
||||||
|
|
||||||
//Convert to MB
|
//Convert to MB
|
||||||
$iFileSize = round($iFileSize / pow(1024, 2), 2);
|
$iFileSize = round($iFileSize / pow(1024, 2), 2);
|
||||||
|
|
||||||
//Compare with max allowed size
|
//Compare with max allowed size
|
||||||
$bFileTooLarge = ($iFileSize > self::MAX_FILESIZE);
|
$bFileTooLarge = ($iFileSize > self::MAX_FILESIZE);
|
||||||
if($bFileTooLarge) $this->addNotice('Output file is too large ('.$iFileSize.'MB > '.self::MAX_FILESIZE.'MB)');
|
if($bFileTooLarge) $this->addNotice('Output file is too large ('.$iFileSize.'MB > '.self::MAX_FILESIZE.'MB)');
|
||||||
|
|
||||||
return $bFileTooLarge;
|
return $bFileTooLarge;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildTracks($asTracks, $bSimplify=false) {
|
public function buildTracks($asTracks, $bSimplify=false) {
|
||||||
$this->addNotice('Creating '.($bSimplify?'Simplified ':'').'GeoJson Tracks');
|
$this->addNotice('Creating '.($bSimplify?'Simplified ':'').'GeoJson Tracks');
|
||||||
|
|
||||||
$iGlobalInvalidPointCount = 0;
|
$iGlobalInvalidPointCount = 0;
|
||||||
$iGlobalPointCount = 0;
|
$iGlobalPointCount = 0;
|
||||||
|
|
||||||
$this->asTracks = array();
|
$this->asTracks = array();
|
||||||
foreach($asTracks as $asTrackProps) {
|
foreach($asTracks as $asTrackProps) {
|
||||||
$asOptions = $this->parseOptions($asTrackProps['cmt']);
|
$asOptions = $this->parseOptions($asTrackProps['cmt']);
|
||||||
|
|
||||||
//Color mapping
|
//Color mapping
|
||||||
switch($asTrackProps['color']) {
|
switch($asTrackProps['color']) {
|
||||||
case 'DarkBlue':
|
case 'DarkBlue':
|
||||||
@@ -166,7 +166,7 @@ class GeoJson extends Geo {
|
|||||||
$this->addNotice('Ignoring Track "'.$asTrackProps['name'].' (unknown color "'.$asTrackProps['color'].'")');
|
$this->addNotice('Ignoring Track "'.$asTrackProps['name'].' (unknown color "'.$asTrackProps['color'].'")');
|
||||||
continue 2; //discard tracks
|
continue 2; //discard tracks
|
||||||
}
|
}
|
||||||
|
|
||||||
$asTrack = array(
|
$asTrack = array(
|
||||||
'type' => 'Feature',
|
'type' => 'Feature',
|
||||||
'properties' => array(
|
'properties' => array(
|
||||||
@@ -179,7 +179,7 @@ class GeoJson extends Geo {
|
|||||||
'coordinates' => array()
|
'coordinates' => array()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
//Track points
|
//Track points
|
||||||
$asTrackPoints = $asTrackProps['points'];
|
$asTrackPoints = $asTrackProps['points'];
|
||||||
$iPointCount = count($asTrackPoints);
|
$iPointCount = count($asTrackPoints);
|
||||||
@@ -197,19 +197,19 @@ class GeoJson extends Geo {
|
|||||||
$asPrevPoint = $asPoint;
|
$asPrevPoint = $asPoint;
|
||||||
}
|
}
|
||||||
$this->asTracks[] = $asTrack;
|
$this->asTracks[] = $asTrack;
|
||||||
|
|
||||||
$iGlobalInvalidPointCount += $iInvalidPointCount;
|
$iGlobalInvalidPointCount += $iInvalidPointCount;
|
||||||
$iGlobalPointCount += $iPointCount;
|
$iGlobalPointCount += $iPointCount;
|
||||||
if($iInvalidPointCount > 0) $this->addNotice('Removing '.$iInvalidPointCount.'/'.$iPointCount.' points ('.round($iInvalidPointCount / $iPointCount * 100, 1).'%) from '.$asTrackProps['name']);
|
if($iInvalidPointCount > 0) $this->addNotice('Removing '.$iInvalidPointCount.'/'.$iPointCount.' points ('.round($iInvalidPointCount / $iPointCount * 100, 1).'%) from '.$asTrackProps['name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($bSimplify) $this->addNotice('Total: '.$iGlobalInvalidPointCount.'/'.$iGlobalPointCount.' points removed ('.round($iGlobalInvalidPointCount / $iGlobalPointCount * 100, 1).'%)');
|
if($bSimplify) $this->addNotice('Total: '.$iGlobalInvalidPointCount.'/'.$iGlobalPointCount.' points removed ('.round($iGlobalInvalidPointCount / $iGlobalPointCount * 100, 1).'%)');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function sortOffTracks() {
|
public function sortOffTracks() {
|
||||||
$this->addNotice('Sorting off-tracks');
|
$this->addNotice('Sorting off-tracks');
|
||||||
|
|
||||||
//Find first & last track points
|
//Find first & last track points
|
||||||
$asTracksEnds = array();
|
$asTracksEnds = array();
|
||||||
$asTracks = array();
|
$asTracks = array();
|
||||||
@@ -218,16 +218,16 @@ class GeoJson extends Geo {
|
|||||||
$asTracksEnds[$sTrackId] = array('first'=>reset($asTrack['geometry']['coordinates']), 'last'=>end($asTrack['geometry']['coordinates']));
|
$asTracksEnds[$sTrackId] = array('first'=>reset($asTrack['geometry']['coordinates']), 'last'=>end($asTrack['geometry']['coordinates']));
|
||||||
$asTracks[$sTrackId] = $asTrack;
|
$asTracks[$sTrackId] = $asTrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Find variants close-by tracks
|
//Find variants close-by tracks
|
||||||
$asClonedTracks = $asTracks;
|
$asClonedTracks = $asTracks;
|
||||||
foreach($asClonedTracks as $sTrackId=>$asTrack) {
|
foreach($asClonedTracks as $sTrackId=>$asTrack) {
|
||||||
if($asTrack['properties']['type'] != 'off-track') continue;
|
if($asTrack['properties']['type'] != 'off-track') continue;
|
||||||
|
|
||||||
$iMinDistance = INF;
|
$iMinDistance = INF;
|
||||||
$sConnectedTrackId = 0;
|
$sConnectedTrackId = 0;
|
||||||
$iPosition = 0;
|
$iPosition = 0;
|
||||||
|
|
||||||
//Test all track ending points to find the closest
|
//Test all track ending points to find the closest
|
||||||
foreach($asTracksEnds as $sTrackEndId=>$asTrackEnds) {
|
foreach($asTracksEnds as $sTrackEndId=>$asTrackEnds) {
|
||||||
if($sTrackEndId != $sTrackId) {
|
if($sTrackEndId != $sTrackId) {
|
||||||
@@ -238,7 +238,7 @@ class GeoJson extends Geo {
|
|||||||
$iPosition = 0; //Track before the Connected Track
|
$iPosition = 0; //Track before the Connected Track
|
||||||
$iMinDistance = $iDistance;
|
$iMinDistance = $iDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Calculate distance between the first point of the track and every ending point of other tracks
|
//Calculate distance between the first point of the track and every ending point of other tracks
|
||||||
$iDistance = self::getDistance($asTracksEnds[$sTrackId]['first'], $asTrackEnds['last']);
|
$iDistance = self::getDistance($asTracksEnds[$sTrackId]['first'], $asTrackEnds['last']);
|
||||||
if($iDistance < $iMinDistance) {
|
if($iDistance < $iMinDistance) {
|
||||||
@@ -248,16 +248,16 @@ class GeoJson extends Geo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Move track
|
//Move track
|
||||||
unset($asTracks[$sTrackId]);
|
unset($asTracks[$sTrackId]);
|
||||||
$iOffset = array_search($sConnectedTrackId, array_keys($asTracks)) + $iPosition;
|
$iOffset = array_search($sConnectedTrackId, array_keys($asTracks)) + $iPosition;
|
||||||
$asTracks = array_slice($asTracks, 0, $iOffset) + array($sTrackId => $asTrack) + array_slice($asTracks, $iOffset);
|
$asTracks = array_slice($asTracks, 0, $iOffset) + array($sTrackId => $asTrack) + array_slice($asTracks, $iOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->asTracks = array_values($asTracks);
|
$this->asTracks = array_values($asTracks);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function parseOptions($sComment){
|
private function parseOptions($sComment){
|
||||||
$asOptions = array(self::OPT_SIMPLE=>'');
|
$asOptions = array(self::OPT_SIMPLE=>'');
|
||||||
foreach(explode("\n", $sComment) as $sLine) {
|
foreach(explode("\n", $sComment) as $sLine) {
|
||||||
@@ -265,52 +265,52 @@ class GeoJson extends Geo {
|
|||||||
}
|
}
|
||||||
return $asOptions;
|
return $asOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isPointValid($asPointA, $asPointO, $asPointB) {
|
private function isPointValid($asPointA, $asPointO, $asPointB) {
|
||||||
/* A----O Calculate angle AO^OB
|
/* A----O Calculate angle AO^OB
|
||||||
* \ If angle is within [90% Pi ; 110% Pi], O can be discarded
|
* \ If angle is within [90% Pi ; 110% Pi], O can be discarded
|
||||||
* \ O is valid otherwise
|
* \ O is valid otherwise
|
||||||
* B
|
* B
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//Path Turn Check -> -> -> ->
|
//Path Turn Check -> -> -> ->
|
||||||
//Law of Cosines (vector): angle = arccos(OA.OB / ||OA||.||OB||)
|
//Law of Cosines (vector): angle = arccos(OA.OB / ||OA||.||OB||)
|
||||||
$fVectorOA = array('lon'=>($asPointA['lon'] - $asPointO['lon']), 'lat'=> ($asPointA['lat'] - $asPointO['lat']));
|
$fVectorOA = array('lon'=>($asPointA['lon'] - $asPointO['lon']), 'lat'=> ($asPointA['lat'] - $asPointO['lat']));
|
||||||
$fVectorOB = array('lon'=>($asPointB['lon'] - $asPointO['lon']), 'lat'=> ($asPointB['lat'] - $asPointO['lat']));
|
$fVectorOB = array('lon'=>($asPointB['lon'] - $asPointO['lon']), 'lat'=> ($asPointB['lat'] - $asPointO['lat']));
|
||||||
|
|
||||||
$fLengthOA = sqrt(pow($asPointA['lon'] - $asPointO['lon'], 2) + pow($asPointA['lat'] - $asPointO['lat'], 2));
|
$fLengthOA = sqrt(pow($asPointA['lon'] - $asPointO['lon'], 2) + pow($asPointA['lat'] - $asPointO['lat'], 2));
|
||||||
$fLengthOB = sqrt(pow($asPointO['lon'] - $asPointB['lon'], 2) + pow($asPointO['lat'] - $asPointB['lat'], 2));
|
$fLengthOB = sqrt(pow($asPointO['lon'] - $asPointB['lon'], 2) + pow($asPointO['lat'] - $asPointB['lat'], 2));
|
||||||
|
|
||||||
$fVectorOAxOB = $fVectorOA['lon'] * $fVectorOB['lon'] + $fVectorOA['lat'] * $fVectorOB['lat'];
|
$fVectorOAxOB = $fVectorOA['lon'] * $fVectorOB['lon'] + $fVectorOA['lat'] * $fVectorOB['lat'];
|
||||||
$fAngleAOB = acos($fVectorOAxOB/($fLengthOA * $fLengthOB));
|
$fAngleAOB = acos($fVectorOAxOB/($fLengthOA * $fLengthOB));
|
||||||
|
|
||||||
//Elevation Check
|
//Elevation Check
|
||||||
//Law of Cosines: angle = arccos((OB² + AO² - AB²) / (2*OB*AO))
|
//Law of Cosines: angle = arccos((OB² + AO² - AB²) / (2*OB*AO))
|
||||||
$fLengthAB = sqrt(pow($asPointB['ele'] - $asPointA['ele'], 2) + pow($fLengthOA + $fLengthOB, 2));
|
$fLengthAB = sqrt(pow($asPointB['ele'] - $asPointA['ele'], 2) + pow($fLengthOA + $fLengthOB, 2));
|
||||||
$fLengthAO = sqrt(pow($asPointO['ele'] - $asPointA['ele'], 2) + pow($fLengthOA, 2));
|
$fLengthAO = sqrt(pow($asPointO['ele'] - $asPointA['ele'], 2) + pow($fLengthOA, 2));
|
||||||
$fLengthOB = sqrt(pow($asPointB['ele'] - $asPointO['ele'], 2) + pow($fLengthOB, 2));
|
$fLengthOB = sqrt(pow($asPointB['ele'] - $asPointO['ele'], 2) + pow($fLengthOB, 2));
|
||||||
$fAngleAOBElev = acos((pow($fLengthOB, 2) + pow($fLengthAO, 2) - pow($fLengthAB, 2)) / (2 * $fLengthOB * $fLengthAO));
|
$fAngleAOBElev = acos((pow($fLengthOB, 2) + pow($fLengthAO, 2) - pow($fLengthAB, 2)) / (2 * $fLengthOB * $fLengthAO));
|
||||||
|
|
||||||
return ($fAngleAOB <= (1 - self::MAX_DEVIATION_FLAT) * M_PI || $fAngleAOB >= (1 + self::MAX_DEVIATION_FLAT) * M_PI ||
|
return ($fAngleAOB <= (1 - self::MAX_DEVIATION_FLAT) * M_PI || $fAngleAOB >= (1 + self::MAX_DEVIATION_FLAT) * M_PI ||
|
||||||
$fAngleAOBElev <= (1 - self::MAX_DEVIATION_ELEV) * M_PI || $fAngleAOBElev >= (1 + self::MAX_DEVIATION_ELEV) * M_PI);
|
$fAngleAOBElev <= (1 - self::MAX_DEVIATION_ELEV) * M_PI || $fAngleAOBElev >= (1 + self::MAX_DEVIATION_ELEV) * M_PI);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildGeoJson() {
|
private function buildGeoJson() {
|
||||||
return json_encode(array('type'=>'FeatureCollection', 'features'=>$this->asTracks));
|
return json_encode(array('type'=>'FeatureCollection', 'features'=>$this->asTracks));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getDistance($asPointA, $asPointB) {
|
private static function getDistance($asPointA, $asPointB) {
|
||||||
$fLatFrom = $asPointA[1];
|
$fLatFrom = $asPointA[1];
|
||||||
$fLonFrom = $asPointA[0];
|
$fLonFrom = $asPointA[0];
|
||||||
$fLatTo = $asPointB[1];
|
$fLatTo = $asPointB[1];
|
||||||
$fLonTo = $asPointB[0];
|
$fLonTo = $asPointB[0];
|
||||||
|
|
||||||
$fRad = M_PI / 180;
|
$fRad = M_PI / 180;
|
||||||
|
|
||||||
//Calculate distance from latitude and longitude
|
//Calculate distance from latitude and longitude
|
||||||
$fTheta = $fLonFrom - $fLonTo;
|
$fTheta = $fLonFrom - $fLonTo;
|
||||||
$fDistance = sin($fLatFrom * $fRad) * sin($fLatTo * $fRad) + cos($fLatFrom * $fRad) * cos($fLatTo * $fRad) * cos($fTheta * $fRad);
|
$fDistance = sin($fLatFrom * $fRad) * sin($fLatTo * $fRad) + cos($fLatFrom * $fRad) * cos($fLatTo * $fRad) * cos($fTheta * $fRad);
|
||||||
|
|
||||||
return acos($fDistance) / $fRad * 60 * 1.853;
|
return acos($fDistance) / $fRad * 60 * 1.853;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ class Feed extends PhpObject {
|
|||||||
$oNow = new DateTime('now');
|
$oNow = new DateTime('now');
|
||||||
$iSecDiff = $oNow->getTimestamp() - $oLastUpdate->getTimestamp();
|
$iSecDiff = $oNow->getTimestamp() - $oLastUpdate->getTimestamp();
|
||||||
|
|
||||||
if($iSecDiff > self::FEED_MAX_REFRESH) $bNewMsg = $this->updateFeed();
|
if($iSecDiff > self::FEED_MAX_REFRESH && !Settings::DEBUG) $bNewMsg = $this->updateFeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $bNewMsg;
|
return $bNewMsg;
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ class Project extends PhpObject {
|
|||||||
case 2: $asProject['mode'] = self::MODE_HISTO; break;
|
case 2: $asProject['mode'] = self::MODE_HISTO; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($sCodeName!= '' && !Converter::isGeoJsonValid($sCodeName)) Converter::convertToGeoJson($sCodeName);
|
if($sCodeName != '' && !Converter::isGeoJsonValid($sCodeName)) Converter::convertToGeoJson($sCodeName);
|
||||||
|
|
||||||
$asProject['geofilepath'] = Spot::addTimestampToFilePath(Geo::getFilePath($sCodeName, GeoJson::EXT));
|
$asProject['geofilepath'] = Spot::addTimestampToFilePath(Geo::getFilePath($sCodeName, GeoJson::EXT));
|
||||||
$asProject['gpxfilepath'] = Spot::addTimestampToFilePath(Geo::getFilePath($sCodeName, Gpx::EXT));
|
$asProject['gpxfilepath'] = Spot::addTimestampToFilePath(Geo::getFilePath($sCodeName, Gpx::EXT));
|
||||||
|
|||||||
47
inc/spot.php
47
inc/spot.php
@@ -73,6 +73,8 @@ class Spot extends Main
|
|||||||
{
|
{
|
||||||
//Install DB
|
//Install DB
|
||||||
$this->oDb->install();
|
$this->oDb->install();
|
||||||
|
|
||||||
|
$this->oUser->addUser('admin@admin.com', $this->oLang->getLanguage(), date_default_timezone_get());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function syncPics() {
|
public function syncPics() {
|
||||||
@@ -93,13 +95,14 @@ class Spot extends Main
|
|||||||
Project::PROJ_TABLE => array('name', 'codename', 'active_from', 'active_to'),
|
Project::PROJ_TABLE => array('name', 'codename', 'active_from', 'active_to'),
|
||||||
self::POST_TABLE => array(Db::getId(Project::PROJ_TABLE), Db::getId(User::USER_TABLE), 'name', 'content', 'site_time', 'timezone'),
|
self::POST_TABLE => array(Db::getId(Project::PROJ_TABLE), Db::getId(User::USER_TABLE), 'name', 'content', 'site_time', 'timezone'),
|
||||||
Media::MEDIA_TABLE => array(Db::getId(Project::PROJ_TABLE), 'filename', 'type', 'taken_on', 'posted_on', 'timezone', 'rotate', 'comment'),
|
Media::MEDIA_TABLE => array(Db::getId(Project::PROJ_TABLE), 'filename', 'type', 'taken_on', 'posted_on', 'timezone', 'rotate', 'comment'),
|
||||||
User::USER_TABLE => array('name', 'email', 'gravatar', 'language', 'timezone', 'active'),
|
User::USER_TABLE => array('name', 'email', 'gravatar', 'language', 'timezone', 'active', 'clearance'),
|
||||||
self::MAP_TABLE => array('codename', 'geo_name', 'min_zoom', 'max_zoom', 'attribution'),
|
self::MAP_TABLE => array('codename', 'geo_name', 'min_zoom', 'max_zoom', 'attribution'),
|
||||||
self::MAPPING_TABLE => array(Db::getId(self::MAP_TABLE) , Db::getId(Project::PROJ_TABLE))
|
self::MAPPING_TABLE => array(Db::getId(self::MAP_TABLE) , Db::getId(Project::PROJ_TABLE))
|
||||||
),
|
),
|
||||||
'types' => array
|
'types' => array
|
||||||
(
|
(
|
||||||
'active' => "BOOLEAN",
|
'active' => "BOOLEAN DEFAULT ".User::USER_INACTIVE,
|
||||||
|
'clearance' => "TINYINT(1) DEFAULT ".User::CLEARANCE_USER,
|
||||||
'active_from' => "TIMESTAMP DEFAULT 0",
|
'active_from' => "TIMESTAMP DEFAULT 0",
|
||||||
'active_to' => "TIMESTAMP DEFAULT 0",
|
'active_to' => "TIMESTAMP DEFAULT 0",
|
||||||
'battery_state' => "VARCHAR(10)",
|
'battery_state' => "VARCHAR(10)",
|
||||||
@@ -149,8 +152,14 @@ class Spot extends Main
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMainPage($asGlobalVars = array(), $sMainPage = 'index', $asMainPageTags=array())
|
public function getAppMainPage()
|
||||||
{
|
{
|
||||||
|
//Cache Page List
|
||||||
|
$asPages = array_diff($this->asMasks, array('email_update', 'email_conf'));
|
||||||
|
if(!$this->oUser->checkUserClearance(User::CLEARANCE_ADMIN)) {
|
||||||
|
$asPages = array_diff($asPages, array('admin', 'upload'));
|
||||||
|
}
|
||||||
|
|
||||||
return parent::getMainPage(
|
return parent::getMainPage(
|
||||||
array(
|
array(
|
||||||
'vars' => array(
|
'vars' => array(
|
||||||
@@ -166,7 +175,7 @@ class Spot extends Main
|
|||||||
'default_timezone' => Settings::TIMEZONE
|
'default_timezone' => Settings::TIMEZONE
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
$sMainPage,
|
'index',
|
||||||
array(
|
array(
|
||||||
'host_url' => $this->asContext['serv_name'],
|
'host_url' => $this->asContext['serv_name'],
|
||||||
'filepath_css' => self::addTimestampToFilePath('style/spot.css'),
|
'filepath_css' => self::addTimestampToFilePath('style/spot.css'),
|
||||||
@@ -176,10 +185,15 @@ class Spot extends Main
|
|||||||
'filepath_js_jquery_mods' => self::addTimestampToFilePath('script/jquery.mods.js'),
|
'filepath_js_jquery_mods' => self::addTimestampToFilePath('script/jquery.mods.js'),
|
||||||
'filepath_js_spot' => self::addTimestampToFilePath('script/spot.js'),
|
'filepath_js_spot' => self::addTimestampToFilePath('script/spot.js'),
|
||||||
'filepath_js_lightbox' => self::addTimestampToFilePath('script/lightbox.js')
|
'filepath_js_lightbox' => self::addTimestampToFilePath('script/lightbox.js')
|
||||||
)
|
),
|
||||||
|
$asPages
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function checkUserClearance($iClearance) {
|
||||||
|
return $this->oUser->checkUserClearance($iClearance);
|
||||||
|
}
|
||||||
|
|
||||||
/* Managing projects */
|
/* Managing projects */
|
||||||
|
|
||||||
public function setProjectId($iProjectId=0) {
|
public function setProjectId($iProjectId=0) {
|
||||||
@@ -188,6 +202,8 @@ class Spot extends Main
|
|||||||
|
|
||||||
public function updateProject() {
|
public function updateProject() {
|
||||||
$bNewMsg = false;
|
$bNewMsg = false;
|
||||||
|
$bSuccess = true;
|
||||||
|
$sDesc = '';
|
||||||
|
|
||||||
//Update all feeds belonging to the project
|
//Update all feeds belonging to the project
|
||||||
$asFeeds = $this->oProject->getFeedIds();
|
$asFeeds = $this->oProject->getFeedIds();
|
||||||
@@ -227,8 +243,13 @@ class Spot extends Main
|
|||||||
if($iPostCount == self::MAIL_CHUNK_SIZE) break;
|
if($iPostCount == self::MAIL_CHUNK_SIZE) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$oEmail->send();
|
$bSuccess = $oEmail->send();
|
||||||
|
if(!$bSuccess) $sDesc = $oEmail->ErrorInfo;
|
||||||
|
else $sDesc = 'mail_sent';
|
||||||
}
|
}
|
||||||
|
else $sDesc = 'no_new_msg';
|
||||||
|
|
||||||
|
return self::getJsonResult($bSuccess, $sDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function genCronFile() {
|
public function genCronFile() {
|
||||||
@@ -303,9 +324,8 @@ class Spot extends Main
|
|||||||
$this->oLang->setLanguage($this->oUser->getLang(), self::DEFAULT_LANG);
|
$this->oLang->setLanguage($this->oUser->getLang(), self::DEFAULT_LANG);
|
||||||
$asResult = $this->oUser->removeUser();
|
$asResult = $this->oUser->removeUser();
|
||||||
|
|
||||||
$sDesc = $asResult['desc'];
|
$sDesc = explode(':', $asResult['desc'])[1];
|
||||||
if($sDesc=='') $sDesc = $this->oLang->getTranslation('nl_unsubscribed');
|
return $this->oLang->getTranslation($sDesc);
|
||||||
return $sDesc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getSpotMessages()
|
private function getSpotMessages()
|
||||||
@@ -491,7 +511,8 @@ class Spot extends Main
|
|||||||
$asData = array(
|
$asData = array(
|
||||||
'project' => $this->oProject->getProjects(),
|
'project' => $this->oProject->getProjects(),
|
||||||
'feed' => $oFeed->getFeeds(),
|
'feed' => $oFeed->getFeeds(),
|
||||||
'spot' => $oFeed->getSpots()
|
'spot' => $oFeed->getSpots(),
|
||||||
|
'user' => $this->oUser->getActiveUsersInfo()
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($asData['project'] as &$asProject) {
|
foreach($asData['project'] as &$asProject) {
|
||||||
@@ -499,6 +520,8 @@ class Spot extends Main
|
|||||||
$asProject['active_to'] = substr($asProject['active_to'], 0, 10);
|
$asProject['active_to'] = substr($asProject['active_to'], 0, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach($asData['user'] as &$asUser) $asUser['id'] = $asUser[Db::getId(User::USER_TABLE)];
|
||||||
|
|
||||||
return self::getJsonResult(true, '', $asData);
|
return self::getJsonResult(true, '', $asData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -587,10 +610,6 @@ class Spot extends Main
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function convertGpxToGeojson($sGeoFileName) {
|
|
||||||
return Converter::convertToGeoJson($sGeoFileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function decToDms($dValue, $sType) {
|
public static function decToDms($dValue, $sType) {
|
||||||
if($sType=='lat') $sDirection = ($dValue >= 0)?'N':'S'; //Latitude
|
if($sType=='lat') $sDirection = ($dValue >= 0)?'N':'S'; //Latitude
|
||||||
else $sDirection = ($dValue >= 0)?'E':'W'; //Longitude
|
else $sDirection = ($dValue >= 0)?'E':'W'; //Longitude
|
||||||
|
|||||||
36
inc/user.php
36
inc/user.php
@@ -5,6 +5,12 @@ class User extends PhpObject {
|
|||||||
//DB Tables
|
//DB Tables
|
||||||
const USER_TABLE = 'users';
|
const USER_TABLE = 'users';
|
||||||
|
|
||||||
|
//Clearance Levels
|
||||||
|
const USER_ACTIVE = 1;
|
||||||
|
const USER_INACTIVE = 0;
|
||||||
|
const CLEARANCE_USER = 0;
|
||||||
|
const CLEARANCE_ADMIN = 9;
|
||||||
|
|
||||||
//Cookie
|
//Cookie
|
||||||
const COOKIE_ID_USER = 'subscriber';
|
const COOKIE_ID_USER = 'subscriber';
|
||||||
const COOKIE_DURATION = 60 * 60 * 24 * 365; //1 year
|
const COOKIE_DURATION = 60 * 60 * 24 * 365; //1 year
|
||||||
@@ -22,7 +28,15 @@ class User extends PhpObject {
|
|||||||
parent::__construct(__CLASS__, Settings::DEBUG);
|
parent::__construct(__CLASS__, Settings::DEBUG);
|
||||||
$this->oDb = &$oDb;
|
$this->oDb = &$oDb;
|
||||||
$this->iUserId = 0;
|
$this->iUserId = 0;
|
||||||
$this->asUserInfo = array(Db::getId(self::USER_TABLE)=>0, 'name'=>'', 'email'=>'', 'language'=>'', 'timezone'=>'', 'active'=>'0');
|
$this->asUserInfo = array(
|
||||||
|
Db::getId(self::USER_TABLE) => 0,
|
||||||
|
'name' => '',
|
||||||
|
'email' => '',
|
||||||
|
'language' => '',
|
||||||
|
'timezone' => '',
|
||||||
|
'active' => self::USER_INACTIVE,
|
||||||
|
'clearance' => self::CLEARANCE_USER
|
||||||
|
);
|
||||||
$this->checkUserCookie();
|
$this->checkUserCookie();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +50,7 @@ class User extends PhpObject {
|
|||||||
$sEmail = trim($sEmail);
|
$sEmail = trim($sEmail);
|
||||||
|
|
||||||
//Check Email availability
|
//Check Email availability
|
||||||
$iUserId = $this->oDb->selectValue(self::USER_TABLE, Db::getId(self::USER_TABLE), array('email'=>$sEmail, 'active'=>'1'));
|
$iUserId = $this->oDb->selectValue(self::USER_TABLE, Db::getId(self::USER_TABLE), array('email'=>$sEmail, 'active'=>self::USER_ACTIVE));
|
||||||
|
|
||||||
if($iUserId > 0) {
|
if($iUserId > 0) {
|
||||||
//Log user in
|
//Log user in
|
||||||
@@ -45,7 +59,12 @@ class User extends PhpObject {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//Add/Reactivate user
|
//Add/Reactivate user
|
||||||
$iUserId = $this->oDb->insertUpdateRow(self::USER_TABLE, array('email'=>$sEmail, 'language'=>$sLang, 'timezone'=>$sTimezone, 'active'=>'1'), array('email'));
|
$iUserId = $this->oDb->insertUpdateRow(
|
||||||
|
self::USER_TABLE,
|
||||||
|
array('email'=>$sEmail, 'language'=>$sLang, 'timezone'=>$sTimezone, 'active'=>self::USER_ACTIVE),
|
||||||
|
array('email')
|
||||||
|
);
|
||||||
|
|
||||||
if($iUserId==0) $sDesc = 'lang:error_commit_db';
|
if($iUserId==0) $sDesc = 'lang:error_commit_db';
|
||||||
else {
|
else {
|
||||||
$this->updateGravatar($iUserId, $sEmail);
|
$this->updateGravatar($iUserId, $sEmail);
|
||||||
@@ -68,7 +87,7 @@ class User extends PhpObject {
|
|||||||
$sDesc = '';
|
$sDesc = '';
|
||||||
|
|
||||||
if($this->iUserId > 0) {
|
if($this->iUserId > 0) {
|
||||||
$iUserId = $this->oDb->updateRow(self::USER_TABLE, $this->iUserId, array('active'=>'0'));
|
$iUserId = $this->oDb->updateRow(self::USER_TABLE, $this->iUserId, array('active'=>self::USER_INACTIVE));
|
||||||
if($iUserId==0) $sDesc = 'lang:error_commit_db';
|
if($iUserId==0) $sDesc = 'lang:error_commit_db';
|
||||||
else {
|
else {
|
||||||
$sDesc = 'lang:nl_unsubscribed';
|
$sDesc = 'lang:nl_unsubscribed';
|
||||||
@@ -121,13 +140,20 @@ class User extends PhpObject {
|
|||||||
$asInfo = array(
|
$asInfo = array(
|
||||||
'select' => array_keys($this->asUserInfo),
|
'select' => array_keys($this->asUserInfo),
|
||||||
'from' => self::USER_TABLE,
|
'from' => self::USER_TABLE,
|
||||||
'constraint'=> array('active'=>'1')
|
'constraint'=> array('active'=>self::USER_ACTIVE)
|
||||||
);
|
);
|
||||||
if($iUserId != -1) $asInfo['constraint'][Db::getId(self::USER_TABLE)] = $iUserId;
|
if($iUserId != -1) $asInfo['constraint'][Db::getId(self::USER_TABLE)] = $iUserId;
|
||||||
|
|
||||||
|
if(!$this->checkUserClearance(self::CLEARANCE_ADMIN)) unset($asInfo['select']['clearance']);
|
||||||
|
|
||||||
return $this->oDb->selectRows($asInfo);
|
return $this->oDb->selectRows($asInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function checkUserClearance($iClearance)
|
||||||
|
{
|
||||||
|
return ($this->asUserInfo['clearance'] >= $iClearance);
|
||||||
|
}
|
||||||
|
|
||||||
private function updateCookie($iDeltaTime) {
|
private function updateCookie($iDeltaTime) {
|
||||||
setcookie(self::COOKIE_ID_USER, ($iDeltaTime < 0)?'':$this->iUserId, array('samesite' => 'Lax', 'expires' => time() + $iDeltaTime));
|
setcookie(self::COOKIE_ID_USER, ($iDeltaTime < 0)?'':$this->iUserId, array('samesite' => 'Lax', 'expires' => time() + $iDeltaTime));
|
||||||
}
|
}
|
||||||
|
|||||||
73
index.php
73
index.php
@@ -39,39 +39,9 @@ if($sAction!='')
|
|||||||
case 'feed':
|
case 'feed':
|
||||||
$sResult = $oSpot->getNewsFeed($iChunk);
|
$sResult = $oSpot->getNewsFeed($iChunk);
|
||||||
break;
|
break;
|
||||||
case 'update_project':
|
|
||||||
$sResult = $oSpot->updateProject();
|
|
||||||
break;
|
|
||||||
case 'upload':
|
|
||||||
$sResult = $oSpot->upload();
|
|
||||||
break;
|
|
||||||
case 'add_comment':
|
|
||||||
$sResult = $oSpot->addComment($iId, $sContent);
|
|
||||||
break;
|
|
||||||
case 'add_post':
|
case 'add_post':
|
||||||
$sResult = $oSpot->addPost($sName, $sContent);
|
$sResult = $oSpot->addPost($sName, $sContent);
|
||||||
break;
|
break;
|
||||||
/*case 'sql':
|
|
||||||
$sResult = $oSpot->getDbBuildScript();
|
|
||||||
break;*/
|
|
||||||
case 'sync_pics':
|
|
||||||
$sResult = $oSpot->syncPics();
|
|
||||||
break;
|
|
||||||
case 'admin_new':
|
|
||||||
$sResult = $oSpot->createProject();
|
|
||||||
break;
|
|
||||||
case 'admin_get':
|
|
||||||
$sResult = $oSpot->getAdminSettings();
|
|
||||||
break;
|
|
||||||
case 'admin_set':
|
|
||||||
$sResult = $oSpot->setAdminSettings($sType, $iId, $sField, $oValue);
|
|
||||||
break;
|
|
||||||
case 'admin_del':
|
|
||||||
$sResult = $oSpot->delAdminSettings($sType, $iId);
|
|
||||||
break;
|
|
||||||
case 'build_geojson':
|
|
||||||
$sResult = $oSpot->convertGpxToGeojson($sName);
|
|
||||||
break;
|
|
||||||
case 'subscribe':
|
case 'subscribe':
|
||||||
$sResult = $oSpot->subscribe($sEmail);
|
$sResult = $oSpot->subscribe($sEmail);
|
||||||
break;
|
break;
|
||||||
@@ -81,14 +51,49 @@ if($sAction!='')
|
|||||||
case 'unsubscribe_email':
|
case 'unsubscribe_email':
|
||||||
$sResult = $oSpot->unsubscribeFromEmail($iId);
|
$sResult = $oSpot->unsubscribeFromEmail($iId);
|
||||||
break;
|
break;
|
||||||
case 'generate_cron':
|
case 'update_project':
|
||||||
$sResult = $oSpot->genCronFile();
|
$sResult = $oSpot->updateProject();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$sResult = Main::getJsonResult(false, Main::NOT_FOUND);
|
if($oSpot->checkUserClearance(User::CLEARANCE_ADMIN))
|
||||||
|
{
|
||||||
|
switch($sAction)
|
||||||
|
{
|
||||||
|
case 'upload':
|
||||||
|
$sResult = $oSpot->upload();
|
||||||
|
break;
|
||||||
|
case 'add_comment':
|
||||||
|
$sResult = $oSpot->addComment($iId, $sContent);
|
||||||
|
break;
|
||||||
|
case 'admin_new':
|
||||||
|
$sResult = $oSpot->createProject();
|
||||||
|
break;
|
||||||
|
case 'admin_get':
|
||||||
|
$sResult = $oSpot->getAdminSettings();
|
||||||
|
break;
|
||||||
|
case 'admin_set':
|
||||||
|
$sResult = $oSpot->setAdminSettings($sType, $iId, $sField, $oValue);
|
||||||
|
break;
|
||||||
|
case 'admin_del':
|
||||||
|
$sResult = $oSpot->delAdminSettings($sType, $iId);
|
||||||
|
break;
|
||||||
|
case 'sync_pics':
|
||||||
|
$sResult = $oSpot->syncPics();
|
||||||
|
break;
|
||||||
|
case 'generate_cron':
|
||||||
|
$sResult = $oSpot->genCronFile();
|
||||||
|
break;
|
||||||
|
case 'sql':
|
||||||
|
$sResult = $oSpot->getDbBuildScript();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$sResult = Main::getJsonResult(false, Main::NOT_FOUND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else $sResult = Main::getJsonResult(false, Main::NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else $sResult = $oSpot->getMainPage();
|
else $sResult = $oSpot->getAppMainPage();
|
||||||
|
|
||||||
$sDebug = ob_get_clean();
|
$sDebug = ob_get_clean();
|
||||||
if(Settings::DEBUG && $sDebug!='') $oSpot->addUncaughtError($sDebug);
|
if(Settings::DEBUG && $sDebug!='') $oSpot->addUncaughtError($sDebug);
|
||||||
|
|||||||
@@ -68,6 +68,9 @@ last_update = Last Spot update
|
|||||||
ref_spot_id = Ref. Spot ID
|
ref_spot_id = Ref. Spot ID
|
||||||
model = Model
|
model = Model
|
||||||
delete = Delete
|
delete = Delete
|
||||||
|
id_user = User ID
|
||||||
|
language = Language
|
||||||
|
clearance = Clearance
|
||||||
|
|
||||||
unit_day = day
|
unit_day = day
|
||||||
unit_days = days
|
unit_days = days
|
||||||
@@ -93,7 +96,7 @@ conf_preheader = Thanks for keeping in touch!
|
|||||||
conf_thanks_sub = You're all set!
|
conf_thanks_sub = You're all set!
|
||||||
conf_body_para_1 = Thank you for checking in on my wanderings :). I'll make sure to keep you posted on my progress along the trail.
|
conf_body_para_1 = Thank you for checking in on my wanderings :). I'll make sure to keep you posted on my progress along the trail.
|
||||||
conf_body_para_2 = I usually check-in once a day, plus sometimes on special events, like successful peak ascents. I am using a GPS-based device (PLB) which does not require phone reception to work. Thus the messages should be pretty frequent, but, being awestruck by the beauty of nature, I could also just forget to send a signal once in a while. So do not worry if you don't receive anything for a couple of days.
|
conf_body_para_2 = I usually check-in once a day, plus sometimes on special events, like successful peak ascents. I am using a GPS-based device (PLB) which does not require phone reception to work. Thus the messages should be pretty frequent, but, being awestruck by the beauty of nature, I could also just forget to send a signal once in a while. So do not worry if you don't receive anything for a couple of days.
|
||||||
conf_body_para_3 = If I've posted some pictures recently, you should also get them in this email.
|
conf_body_para_3 = If I've posted some pictures recently, you should also get them in the same email.
|
||||||
conf_body_conclusion= Happy Trails!
|
conf_body_conclusion= Happy Trails!
|
||||||
conf_signature = --François
|
conf_signature = --François
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,9 @@ last_update = Dernière maj depuis Spot
|
|||||||
ref_spot_id = ID Spot ref.
|
ref_spot_id = ID Spot ref.
|
||||||
model = Modèle
|
model = Modèle
|
||||||
delete = Supprimer
|
delete = Supprimer
|
||||||
|
id_user = ID Utilisateur
|
||||||
|
language = Langue
|
||||||
|
clearance = Niveau d'autorisation
|
||||||
|
|
||||||
unit_day = jour
|
unit_day = jour
|
||||||
unit_days = jours
|
unit_days = jours
|
||||||
|
|||||||
@@ -49,12 +49,30 @@
|
|||||||
<tbody></tbody>
|
<tbody></tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<h1>Users</h1>
|
||||||
|
<div id="users">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>[#]lang:id_user[#]</th>
|
||||||
|
<th>[#]lang:name[#]</th>
|
||||||
|
<th>[#]lang:language[#]</th>
|
||||||
|
<th>[#]lang:time_zone[#]</th>
|
||||||
|
<th>[#]lang:clearance[#]</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody></tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<h1>ToolBox</h1>
|
||||||
|
<div id="toolbox"></div>
|
||||||
<div id="feedback" class="feedback"></div>
|
<div id="feedback" class="feedback"></div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
oSpot.pageInit = function(asHash) {
|
oSpot.pageInit = function(asHash) {
|
||||||
self.get('admin_get', setProjects);
|
self.get('admin_get', setProjects);
|
||||||
$('#new').addButton('new', 'New Project', 'new', createProject, 'main-btn');
|
$('#new').addButton('new', 'New Project', 'new', createProject, 'main-btn');
|
||||||
|
$('#toolbox').addButton('refresh', 'Update Project', 'refresh', updateProject, 'main-btn');
|
||||||
};
|
};
|
||||||
|
|
||||||
oSpot.onFeedback = function(sType, sMsg, asContext) {
|
oSpot.onFeedback = function(sType, sMsg, asContext) {
|
||||||
@@ -116,6 +134,13 @@ function setProjects(asElemTypes) {
|
|||||||
.append($('<td>').text(oElem.name))
|
.append($('<td>').text(oElem.name))
|
||||||
.append($('<td>').text(oElem.model))
|
.append($('<td>').text(oElem.model))
|
||||||
break;
|
break;
|
||||||
|
case 'user':
|
||||||
|
$Elem
|
||||||
|
.append($('<td>').text(oElem.name))
|
||||||
|
.append($('<td>').text(oElem.language))
|
||||||
|
.append($('<td>').text(oElem.timezone))
|
||||||
|
.append($('<td>').text(oElem.clearance))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$Elem.appendTo($('#'+sElemType+'s').find('table tbody'));
|
$Elem.appendTo($('#'+sElemType+'s').find('table tbody'));
|
||||||
@@ -128,6 +153,15 @@ function createProject() {
|
|||||||
self.get('admin_new', setProjects);
|
self.get('admin_new', setProjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateProject() {
|
||||||
|
self.get(
|
||||||
|
'update_project',
|
||||||
|
function(asData, sMsg){oSpot.onFeedback('success', sMsg, {'update':'project'});},
|
||||||
|
{},
|
||||||
|
function(sMsg){oSpot.onFeedback('error', sMsg, {'update':'project'});}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function commit(event, $This) {
|
function commit(event, $This) {
|
||||||
$This = $This || $(this);
|
$This = $This || $(this);
|
||||||
if(typeof self.tmp('wait') != 'undefined') clearTimeout(self.tmp('wait'));
|
if(typeof self.tmp('wait') != 'undefined') clearTimeout(self.tmp('wait'));
|
||||||
|
|||||||
@@ -175,8 +175,14 @@ function Spot(asGlobals)
|
|||||||
this.switchPage = function(asHash)
|
this.switchPage = function(asHash)
|
||||||
{
|
{
|
||||||
var sPageName = asHash.page;
|
var sPageName = asHash.page;
|
||||||
var bSamePage = self.vars('page')==sPageName;
|
var bSamePage = (self.vars('page') == sPageName);
|
||||||
if(self.onQuitPage(bSamePage) && !bSamePage || self.onSamePageMove(asHash))
|
var bFirstPage = (self.vars('page') == '');
|
||||||
|
|
||||||
|
if(!self.consts.pages[sPageName]) { //Page does not exist
|
||||||
|
if(bFirstPage) self.setHash(self.consts.default_page);
|
||||||
|
else self.setHash(self.vars('page'), self.vars(['hash', 'items']));
|
||||||
|
}
|
||||||
|
else if(self.onQuitPage(bSamePage) && !bSamePage || self.onSamePageMove(asHash))
|
||||||
{
|
{
|
||||||
//Delete tmp variables
|
//Delete tmp variables
|
||||||
self.vars('tmp', {});
|
self.vars('tmp', {});
|
||||||
@@ -185,8 +191,8 @@ function Spot(asGlobals)
|
|||||||
self.resetTmpFunctions();
|
self.resetTmpFunctions();
|
||||||
|
|
||||||
//Officially a new page
|
//Officially a new page
|
||||||
var bFirstPage = self.vars('page')=='';
|
|
||||||
self.vars('page', sPageName);
|
self.vars('page', sPageName);
|
||||||
|
self.vars('hash', asHash);
|
||||||
|
|
||||||
//Update Page Title
|
//Update Page Title
|
||||||
this.setPageTitle(sPageName+' '+(asHash.items[0] || ''));
|
this.setPageTitle(sPageName+' '+(asHash.items[0] || ''));
|
||||||
@@ -202,6 +208,7 @@ function Spot(asGlobals)
|
|||||||
self.elem.main.stop().fadeTo('fast', 0, function(){self.splash($Dom, asHash, bFirstPage);}); //Switching page
|
self.elem.main.stop().fadeTo('fast', 0, function(){self.splash($Dom, asHash, bFirstPage);}); //Switching page
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(bSamePage) self.vars('hash', asHash);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setPageTitle = function(sTitle) {
|
this.setPageTitle = function(sTitle) {
|
||||||
|
|||||||
@@ -91,3 +91,4 @@ $fa-css-prefix: fa;
|
|||||||
|
|
||||||
/* Admin */
|
/* Admin */
|
||||||
.#{$fa-css-prefix}-new:before { content: fa-content($fa-var-plus); }
|
.#{$fa-css-prefix}-new:before { content: fa-content($fa-var-plus); }
|
||||||
|
.#{$fa-css-prefix}-refresh:before { content: fa-content($fa-var-sync); }
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user