Compare commits
2 Commits
b9a4bd6d2d
...
vue
| Author | SHA1 | Date | |
|---|---|---|---|
| d9bc89b7f6 | |||
| 760f38374f |
41457
geo/snt.gpx
Normal file → Executable file
41457
geo/snt.gpx
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
@@ -33,12 +33,10 @@ class Converter extends PhpObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function isGeoJsonValid($sCodeName) {
|
public static function isGeoJsonValid($sCodeName) {
|
||||||
$bResult = false;
|
|
||||||
$sGpxFilePath = Gpx::getFilePath($sCodeName);
|
$sGpxFilePath = Gpx::getFilePath($sCodeName);
|
||||||
$sGeoJsonFilePath = GeoJson::getFilePath($sCodeName);
|
$sGeoJsonFilePath = GeoJson::getFilePath($sCodeName);
|
||||||
|
|
||||||
//No need to generate if gpx is missing
|
//No need to generate if gpx is missing
|
||||||
if(!file_exists($sGpxFilePath) || file_exists($sGeoJsonFilePath) && filemtime($sGeoJsonFilePath) > filemtime(Gpx::getFilePath($sCodeName))) $bResult = true;
|
return !file_exists($sGpxFilePath) || file_exists($sGeoJsonFilePath) && filemtime($sGeoJsonFilePath) >= filemtime($sGpxFilePath);
|
||||||
return $bResult;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
70
lib/Spot.php
70
lib/Spot.php
@@ -223,34 +223,7 @@ class Spot extends Main
|
|||||||
|
|
||||||
//Send Update Email
|
//Send Update Email
|
||||||
if($bNewMsg) {
|
if($bNewMsg) {
|
||||||
$oEmail = new Email($this->asContext['serv_name'], 'email_update');
|
$bSuccess = $this->sendEmail();
|
||||||
$oEmail->setDestInfo($this->oUser->getActiveUsersInfo());
|
|
||||||
|
|
||||||
//Add Position
|
|
||||||
$asLastMessage = array_shift($this->getSpotMessages(array($this->oProject->getLastMessageId($this->getFeedConstraints(Feed::MSG_TABLE)))));
|
|
||||||
$oEmail->oTemplate->setTags($asLastMessage);
|
|
||||||
$oEmail->oTemplate->setTag('date_time', 'time:'.$asLastMessage['unix_time'], 'd/m/Y, H:i');
|
|
||||||
|
|
||||||
//Add latest news feed
|
|
||||||
$asNews = $this->getNextFeed(0, true);
|
|
||||||
$iPostCount = 0;
|
|
||||||
foreach($asNews as $asPost) {
|
|
||||||
if($asPost['type'] != 'message') {
|
|
||||||
$oEmail->oTemplate->newInstance('news');
|
|
||||||
$oEmail->oTemplate->setInstanceTags('news', array(
|
|
||||||
'local_server' => $this->asContext['serv_name'],
|
|
||||||
'project' => $this->oProject->getProjectCodeName(),
|
|
||||||
'type' => $asPost['type'],
|
|
||||||
'id' => $asPost['id_'.$asPost['type']])
|
|
||||||
);
|
|
||||||
$oEmail->oTemplate->addInstance($asPost['type'], $asPost);
|
|
||||||
$oEmail->oTemplate->setInstanceTag($asPost['type'], 'local_server', $this->asContext['serv_name']);
|
|
||||||
$iPostCount++;
|
|
||||||
}
|
|
||||||
if($iPostCount == self::MAIL_CHUNK_SIZE) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$bSuccess = $oEmail->send();
|
|
||||||
$sDesc = $bSuccess?'mail_sent':'mail_failure';
|
$sDesc = $bSuccess?'mail_sent':'mail_failure';
|
||||||
}
|
}
|
||||||
else $sDesc = 'no_new_msg';
|
else $sDesc = 'no_new_msg';
|
||||||
@@ -258,6 +231,37 @@ class Spot extends Main
|
|||||||
return self::getJsonResult($bSuccess, $sDesc);
|
return self::getJsonResult($bSuccess, $sDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function sendEmail() {
|
||||||
|
$oEmail = new Email($this->asContext['serv_name'], 'email_update');
|
||||||
|
$oEmail->setDestInfo($this->oUser->getActiveUsersInfo());
|
||||||
|
|
||||||
|
//Add Position
|
||||||
|
$asLastMessage = array_shift($this->getSpotMessages(array($this->oProject->getLastMessageId($this->getFeedConstraints(Feed::MSG_TABLE)))));
|
||||||
|
$oEmail->oTemplate->setTags($asLastMessage);
|
||||||
|
$oEmail->oTemplate->setTag('date_time', 'time:'.$asLastMessage['unix_time'], 'd/m/Y, H:i');
|
||||||
|
|
||||||
|
//Add latest news feed
|
||||||
|
$asNews = $this->getNextFeed(0, true);
|
||||||
|
$iPostCount = 0;
|
||||||
|
foreach($asNews as $asPost) {
|
||||||
|
if($asPost['type'] != 'message') {
|
||||||
|
$oEmail->oTemplate->newInstance('news');
|
||||||
|
$oEmail->oTemplate->setInstanceTags('news', array(
|
||||||
|
'local_server' => $this->asContext['serv_name'],
|
||||||
|
'project' => $this->oProject->getProjectCodeName(),
|
||||||
|
'type' => $asPost['type'],
|
||||||
|
'id' => $asPost['id_'.$asPost['type']])
|
||||||
|
);
|
||||||
|
$oEmail->oTemplate->addInstance($asPost['type'], $asPost);
|
||||||
|
$oEmail->oTemplate->setInstanceTag($asPost['type'], 'local_server', $this->asContext['serv_name']);
|
||||||
|
$iPostCount++;
|
||||||
|
}
|
||||||
|
if($iPostCount == self::MAIL_CHUNK_SIZE) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $oEmail->send();
|
||||||
|
}
|
||||||
|
|
||||||
public function genCronFile() {
|
public function genCronFile() {
|
||||||
//$bSuccess = (file_put_contents('spot_cron.sh', '#!/bin/bash'."\n".'cd '.dirname($_SERVER['SCRIPT_FILENAME'])."\n".'php -f index.php a=update_feed')!==false);
|
//$bSuccess = (file_put_contents('spot_cron.sh', '#!/bin/bash'."\n".'cd '.dirname($_SERVER['SCRIPT_FILENAME'])."\n".'php -f index.php a=update_feed')!==false);
|
||||||
$sFileName = 'spot_cron.sh';
|
$sFileName = 'spot_cron.sh';
|
||||||
@@ -634,9 +638,15 @@ class Spot extends Main
|
|||||||
|
|
||||||
public function addPosition($sLat, $sLng, $iTimestamp) {
|
public function addPosition($sLat, $sLng, $iTimestamp) {
|
||||||
$oFeed = new Feed($this->oDb, $this->oProject->getFeedIds()[0]);
|
$oFeed = new Feed($this->oDb, $this->oProject->getFeedIds()[0]);
|
||||||
$bResult = ($oFeed->addManualPosition($sLat, $sLng, $iTimestamp) > 0);
|
$bSuccess = ($oFeed->addManualPosition($sLat, $sLng, $iTimestamp) > 0);
|
||||||
|
|
||||||
return self::getJsonResult($bResult, $bResult?'':$this->oDb->getLastError());
|
if($bSuccess) {
|
||||||
|
$bSuccess = $this->sendEmail();
|
||||||
|
$sDesc = $bSuccess?'mail_sent':'mail_failure';
|
||||||
|
}
|
||||||
|
else $sDesc = 'error_commit_db';
|
||||||
|
|
||||||
|
return self::getJsonResult($bSuccess, $sDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAdminSettings($sType='') {
|
public function getAdminSettings($sType='') {
|
||||||
|
|||||||
@@ -80,9 +80,6 @@ if($sAction!='')
|
|||||||
case 'add_position':
|
case 'add_position':
|
||||||
$sResult = $oSpot->addPosition($sLat, $sLng, $iTimestamp);
|
$sResult = $oSpot->addPosition($sLat, $sLng, $iTimestamp);
|
||||||
break;
|
break;
|
||||||
case 'admin_new':
|
|
||||||
$sResult = $oSpot->createProject();
|
|
||||||
break;
|
|
||||||
case 'admin_get':
|
case 'admin_get':
|
||||||
$sResult = $oSpot->getAdminSettings();
|
$sResult = $oSpot->getAdminSettings();
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user