Compare commits

...

4 Commits

Author SHA1 Message Date
d9bc89b7f6 Update SNT gpx 2025-07-19 16:22:14 +02:00
760f38374f Add email trigger to manual positioning 2025-07-19 16:21:44 +02:00
b9a4bd6d2d Adapt manual message upload to vue 2025-05-12 19:48:49 +02:00
ea14a1ef3e Add manual message upload 2025-05-11 17:38:59 +02:00
12 changed files with 34627 additions and 7036 deletions

21
composer.lock generated
View File

@@ -12,7 +12,7 @@
"dist": { "dist": {
"type": "path", "type": "path",
"url": "../objects", "url": "../objects",
"reference": "a9f8601384a0078cf8531576768e2c5bad4bbf95" "reference": "bcae723140735b1432caaf3070ef4e29ecb73a76"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@@ -27,16 +27,16 @@
}, },
{ {
"name": "phpmailer/phpmailer", "name": "phpmailer/phpmailer",
"version": "v6.8.1", "version": "v6.10.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/PHPMailer/PHPMailer.git", "url": "https://github.com/PHPMailer/PHPMailer.git",
"reference": "e88da8d679acc3824ff231fdc553565b802ac016" "reference": "bf74d75a1fde6beaa34a0ddae2ec5fce0f72a144"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/e88da8d679acc3824ff231fdc553565b802ac016", "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/bf74d75a1fde6beaa34a0ddae2ec5fce0f72a144",
"reference": "e88da8d679acc3824ff231fdc553565b802ac016", "reference": "bf74d75a1fde6beaa34a0ddae2ec5fce0f72a144",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -56,6 +56,7 @@
"yoast/phpunit-polyfills": "^1.0.4" "yoast/phpunit-polyfills": "^1.0.4"
}, },
"suggest": { "suggest": {
"decomplexity/SendOauth2": "Adapter for using XOAUTH2 authentication",
"ext-mbstring": "Needed to send email in multibyte encoding charset or decode encoded addresses", "ext-mbstring": "Needed to send email in multibyte encoding charset or decode encoded addresses",
"ext-openssl": "Needed for secure SMTP sending and DKIM signing", "ext-openssl": "Needed for secure SMTP sending and DKIM signing",
"greew/oauth2-azure-provider": "Needed for Microsoft Azure XOAUTH2 authentication", "greew/oauth2-azure-provider": "Needed for Microsoft Azure XOAUTH2 authentication",
@@ -95,7 +96,7 @@
"description": "PHPMailer is a full-featured email creation and transfer class for PHP", "description": "PHPMailer is a full-featured email creation and transfer class for PHP",
"support": { "support": {
"issues": "https://github.com/PHPMailer/PHPMailer/issues", "issues": "https://github.com/PHPMailer/PHPMailer/issues",
"source": "https://github.com/PHPMailer/PHPMailer/tree/v6.8.1" "source": "https://github.com/PHPMailer/PHPMailer/tree/v6.10.0"
}, },
"funding": [ "funding": [
{ {
@@ -103,7 +104,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2023-08-29T08:26:30+00:00" "time": "2025-04-24T15:19:31+00:00"
} }
], ],
"packages-dev": [], "packages-dev": [],
@@ -114,7 +115,7 @@
}, },
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": [], "platform": {},
"platform-dev": [], "platform-dev": {},
"plugin-api-version": "2.3.0" "plugin-api-version": "2.6.0"
} }

41457
geo/snt.gpx Normal file → Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -24,6 +24,7 @@ upload_title = Picture & Video Uploads
upload_mode_archived= Project "$0" is archived. No upload allowed upload_mode_archived= Project "$0" is archived. No upload allowed
upload_success = $0 uploaded successfully upload_success = $0 uploaded successfully
upload_media_exist = Picture $0 already exists upload_media_exist = Picture $0 already exists
new_position = New Position
post_message = Message post_message = Message
post_name = Name post_name = Name

View File

@@ -24,6 +24,7 @@ upload_title = Cargar fotos y videos
upload_mode_archived= El proyecto "$0" esta archivado. No se puede cargar upload_mode_archived= El proyecto "$0" esta archivado. No se puede cargar
upload_success = $0 ha sido subido upload_success = $0 ha sido subido
upload_media_exist = La imagen $0 ya existe upload_media_exist = La imagen $0 ya existe
new_position = Nueva posición
post_message = Mensaje post_message = Mensaje
post_name = Nombre post_name = Nombre

View File

@@ -24,6 +24,7 @@ upload_title = Uploader photos & vidéos
upload_mode_archived= Le projet "$0" a été archivé. Aucun upload possible upload_mode_archived= Le projet "$0" a été archivé. Aucun upload possible
upload_success = $0 a été uploadé upload_success = $0 a été uploadé
upload_media_exist = l'image $0 existe déjà upload_media_exist = l'image $0 existe déjà
new_position = Nouvelle position
post_message = Message post_message = Message
post_name = Nom post_name = Nom

View File

@@ -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;
} }
} }

View File

@@ -168,6 +168,31 @@ class Feed extends PhpObject {
return $bNewMsg; return $bNewMsg;
} }
public function addManualPosition($sLat, $sLng, $iTimestamp) {
$sTimeZone = date_default_timezone_get();
$oDateTime = new \DateTime('@'.$iTimestamp);
$oDateTime->setTimezone(new \DateTimeZone($sTimeZone));
$asWeather = $this->getWeather(array($sLat, $sLng), $iTimestamp);
$asMsg = [
'ref_msg_id' => $iTimestamp.'/man',
'id_feed' => $this->getFeedId(),
'type' => 'OK',
'latitude' => $sLat,
'longitude' => $sLng,
'iso_time' => $oDateTime->format("Y-m-d\TH:i:sO"), //Incorrect ISO 8601 format, but compliant with Spot data
'site_time' => $oDateTime->format(Db::TIMESTAMP_FORMAT),
'timezone' => $sTimeZone,
'unix_time' => $iTimestamp,
'content' => '',
'battery_state' => '',
'posted_on' => date(Db::TIMESTAMP_FORMAT),
];
$iMessageId = $this->oDb->insertRow(self::MSG_TABLE, array_merge($asMsg, $asWeather));
return $iMessageId;
}
private function updateFeed() { private function updateFeed() {
$bNewMsg = false; $bNewMsg = false;
$asData = $this->retrieveFeed(); $asData = $this->retrieveFeed();

View File

@@ -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';
@@ -632,6 +636,19 @@ class Spot extends Main
return self::getJsonResult($asResult['result'], $asResult['desc'], $asResult['data']); return self::getJsonResult($asResult['result'], $asResult['desc'], $asResult['data']);
} }
public function addPosition($sLat, $sLng, $iTimestamp) {
$oFeed = new Feed($this->oDb, $this->oProject->getFeedIds()[0]);
$bSuccess = ($oFeed->addManualPosition($sLat, $sLng, $iTimestamp) > 0);
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='') {
$oFeed = new Feed($this->oDb); $oFeed = new Feed($this->oDb);
$asData = array( $asData = array(

View File

@@ -26,6 +26,9 @@ $oValue = $_REQUEST['value'] ?? '';
$iId = $_REQUEST['id'] ?? 0 ; $iId = $_REQUEST['id'] ?? 0 ;
$sType = $_REQUEST['type'] ?? ''; $sType = $_REQUEST['type'] ?? '';
$sEmail = $_REQUEST['email'] ?? ''; $sEmail = $_REQUEST['email'] ?? '';
$sLat = $_REQUEST['latitude'] ?? '';
$sLng = $_REQUEST['longitude'] ?? '';
$iTimestamp = $_REQUEST['timestamp'] ?? 0;
//Initiate class //Initiate class
$oSpot = new Spot(__FILE__, $sTimezone); $oSpot = new Spot(__FILE__, $sTimezone);
@@ -74,6 +77,9 @@ if($sAction!='')
case 'add_comment': case 'add_comment':
$sResult = $oSpot->addComment($iId, $sContent); $sResult = $oSpot->addComment($iId, $sContent);
break; break;
case 'add_position':
$sResult = $oSpot->addPosition($sLat, $sLng, $iTimestamp);
break;
case 'admin_get': case 'admin_get':
$sResult = $oSpot->getAdminSettings(); $sResult = $oSpot->getAdminSettings();
break; break;

View File

@@ -1,9 +1,11 @@
<script> <script>
import SpotIcon from './spotIcon.vue';
import SpotButton from './spotButton.vue'; import SpotButton from './spotButton.vue';
import AdminInput from './adminInput.vue'; import AdminInput from './adminInput.vue';
export default { export default {
components: { components: {
SpotIcon,
SpotButton, SpotButton,
AdminInput AdminInput
}, },
@@ -117,7 +119,7 @@ export default {
</script> </script>
<template> <template>
<div id="admin"> <div id="admin">
<a name="back" class="button" href="#project"><i class="fa fa-back push"></i>{{ l('nav_back') }}</a> <a name="back" class="button" href="#project"><SpotIcon :icon="'back'" :text="l('nav_back')" /></a>
<h1>{{ l('projects') }}</h1> <h1>{{ l('projects') }}</h1>
<div id="project_section"> <div id="project_section">
<table> <table>

View File

@@ -1,4 +1,5 @@
<script> <script>
import SpotIcon from './spotIcon.vue';
import SpotButton from './spotButton.vue'; import SpotButton from './spotButton.vue';
import "blueimp-file-upload/js/vendor/jquery.ui.widget.js"; import "blueimp-file-upload/js/vendor/jquery.ui.widget.js";
import "blueimp-file-upload/js/jquery.iframe-transport.js"; import "blueimp-file-upload/js/jquery.iframe-transport.js";
@@ -6,7 +7,7 @@ import "blueimp-file-upload/js/jquery.fileupload.js";
export default { export default {
name: 'upload', name: 'upload',
components: { SpotButton }, components: { SpotButton, SpotIcon },
inject: ['spot', 'projects', 'consts', 'user'], inject: ['spot', 'projects', 'consts', 'user'],
data() { data() {
return { return {
@@ -49,20 +50,39 @@ export default {
this.spot.get2('add_comment', {id: oFile.id, content: oFile.content}) this.spot.get2('add_comment', {id: oFile.id, content: oFile.content})
.then((asData) => {this.logs.push(this.spot.lang('media_comment_update', asData.filename));}) .then((asData) => {this.logs.push(this.spot.lang('media_comment_update', asData.filename));})
.catch((sMsgId) => {this.logs.push(this.spot.lang(sMsgId));}); .catch((sMsgId) => {this.logs.push(this.spot.lang(sMsgId));});
},
addPosition() {
if(navigator.geolocation) {
this.logs.push('Determining position...');
navigator.geolocation.getCurrentPosition(
(position) => {
this.logs.push('Sending position...');
this.spot.get2('add_position', {'latitude':position.coords.latitude, 'longitude':position.coords.longitude, 'timestamp':Math.round(position.timestamp / 1000)})
.then((asData) => {this.logs.push('Position sent');})
.catch((sMsgId) => {this.logs.push(self.lang(sMsgId));});
},
(error) => {
this.logs.push(error.message);
}
);
}
else this.logs.push('This browser does not support geolocation');
} }
} }
} }
</script> </script>
<template> <template>
<div id="upload"> <div id="upload">
<a name="back" class="button" href="#project"><i class="fa fa-back push"></i>{{ spot.lang('nav_back') }}</a> <a name="back" class="button" href="#project"><SpotIcon :icon="'back'" :text="spot.lang('nav_back')" /></a>
<h1>{{ spot.lang('upload_title') }}</h1> <h1>{{ spot.lang('upload_title') }}</h1>
<h2>{{ this.project.name }}</h2> <h2>{{ this.project.name }}</h2>
<input v-if="project.editable" id="fileupload" type="file" name="files[]" :data-url="this.spot.getActionLink('upload')" multiple> <div class="section" v-if="project.editable">
<div class="progress" v-if="progress > 0"> <input id="fileupload" type="file" name="files[]" :data-url="this.spot.getActionLink('upload')" multiple />
</div>
<div class="section progress" v-if="progress > 0">
<div class="bar" :style="{width:progress+'%'}"></div> <div class="bar" :style="{width:progress+'%'}"></div>
</div> </div>
<div class="comment" v-for="file in files"> <div class="section comment" v-for="file in files">
<img class="thumb" :src="file.thumbnail" /> <img class="thumb" :src="file.thumbnail" />
<div class="form"> <div class="form">
<input class="content" name="content" type="text" v-model="file.content" /> <input class="content" name="content" type="text" v-model="file.content" />
@@ -70,7 +90,10 @@ export default {
<SpotButton :classes="'save'" :icon="'save'" :text="spot.lang('save')" @click="addComment(file)" /> <SpotButton :classes="'save'" :icon="'save'" :text="spot.lang('save')" @click="addComment(file)" />
</div> </div>
</div> </div>
<div class="logs" v-if="logs.length > 0"> <div class="section location">
<SpotButton :icon="'message'" :text="spot.lang('new_position')" @click="addPosition()" />
</div>
<div class="section logs" v-if="logs.length > 0">
<p class="log" v-for="log in logs">{{ log }}.</p> <p class="log" v-for="log in logs">{{ log }}.</p>
</div> </div>
</div> </div>

View File

@@ -1,16 +1,14 @@
#upload { #upload {
padding: 1em; padding: 1em;
input[type="file"] { .section {
border: 1px solid #333;
border-radius: 3px; border-radius: 3px;
} margin-top: 1rem;
padding: 0 1rem 1rem 1rem;
border-bottom: 1px solid #EEE;
}
.progress { .progress {
margin: 1rem 0;
border: 1px solid #333;
border-radius: 3px;
.bar { .bar {
height: 18px; height: 18px;
background: green; background: green;
@@ -18,8 +16,6 @@
} }
.comment { .comment {
margin-top: 1em;
.thumb { .thumb {
width: 30%; width: 30%;
max-width: 100px; max-width: 100px;
@@ -27,30 +23,27 @@
.form { .form {
display: inline-block; display: inline-block;
width: calc(70% - 1em); width: calc(70% - 2rem);
min-width: calc(100% - 100px - 1em); min-width: calc(100% - 100px - 2rem);
margin-left: 1em; padding: 1rem;
vertical-align: top; vertical-align: top;
box-sizing: border-box;
.content { .content {
width: 100%; width: calc(100% - 2rem);
box-sizing: border-box; box-sizing: border-box;
padding: 0.5em; padding: 0.5em;
border: 1px solid #333; background: #EEE;
border-radius: 3px;
} }
.save { .save {
margin-top: 1em; margin-top: 1rem;
padding: 0.5em; padding: 0.5em;
} }
} }
} }
.logs { .logs {
border: 1px solid #333;
border-radius: 3px;
margin-top: 1rem;
padding: 1rem; padding: 1rem;
p.log { p.log {