This commit is contained in:
+29
-29
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Franzz\Spot;
|
||||
namespace Franzz\Livetrail;
|
||||
|
||||
use Franzz\Objects\PhpObject;
|
||||
use Franzz\Objects\ToolBox;
|
||||
@@ -27,7 +27,7 @@ class Controller extends PhpObject
|
||||
'logout'
|
||||
);
|
||||
|
||||
private Spot $oSpot;
|
||||
private Livetrail $oLivetrail;
|
||||
private array $asReq;
|
||||
private string $sCsrfToken = '';
|
||||
|
||||
@@ -69,22 +69,22 @@ class Controller extends PhpObject
|
||||
//Authentication and CSRF protection share the same server-side session.
|
||||
$this->initCsrfToken();
|
||||
|
||||
//Create Spot Instance
|
||||
$this->oSpot = new Spot($sProcessPage, $this->asReq['t']);
|
||||
//Create Livetrail instance
|
||||
$this->oLivetrail = new Livetrail($sProcessPage, $this->asReq['t']);
|
||||
|
||||
//Validate CSRF, then release the session lock before long-running work.
|
||||
$bValidMutationRequest = $this->validateMutationRequest($sAction);
|
||||
if(!$bValidMutationRequest || !in_array($sAction, self::SESSION_WRITING_ACTIONS, true)) $this->closeSession();
|
||||
|
||||
if(!$bValidMutationRequest) $sResult = Spot::getJsonResult(false, Spot::UNAUTHORIZED);
|
||||
if(!$bValidMutationRequest) $sResult = Livetrail::getJsonResult(false, Livetrail::UNAUTHORIZED);
|
||||
else {
|
||||
$this->oSpot->setProjectId($this->asReq['id_project']);
|
||||
$sResult = ($sAction == '')?$this->oSpot->getAppMainPage($this->getCsrfToken()):$this->dispatch($sAction);
|
||||
$this->oLivetrail->setProjectId($this->asReq['id_project']);
|
||||
$sResult = ($sAction == '')?$this->oLivetrail->getAppMainPage($this->getCsrfToken()):$this->dispatch($sAction);
|
||||
}
|
||||
|
||||
//Clean errors
|
||||
$sDebug = ob_get_clean();
|
||||
if($sDebug != '') $this->oSpot->addUncaughtError($sDebug);
|
||||
if($sDebug != '') $this->oLivetrail->addUncaughtError($sDebug);
|
||||
$this->closeSession();
|
||||
|
||||
return $sResult;
|
||||
@@ -140,36 +140,36 @@ class Controller extends PhpObject
|
||||
private function dispatch(string $sAction): string
|
||||
{
|
||||
return match($sAction) {
|
||||
'markers' => $this->oSpot->getMarkers(),
|
||||
'last_update' => $this->oSpot->getLastUpdate(),
|
||||
'next_feed' => $this->oSpot->getNextFeed($this->asReq['id']),
|
||||
'new_feed' => $this->oSpot->getNewFeed($this->asReq['id']),
|
||||
'add_post' => $this->oSpot->addPost($this->asReq['name'], $this->asReq['content']),
|
||||
'subscribe' => $this->oSpot->subscribe(),
|
||||
'unsubscribe' => $this->oSpot->unsubscribe(),
|
||||
'login' => $this->oSpot->login($this->asReq['email'], $this->asReq['password'], $this->asReq['name']),
|
||||
'logout' => $this->oSpot->logout(),
|
||||
'update_project' => $this->oSpot->updateProject(),
|
||||
'markers' => $this->oLivetrail->getMarkers(),
|
||||
'last_update' => $this->oLivetrail->getLastUpdate(),
|
||||
'next_feed' => $this->oLivetrail->getNextFeed($this->asReq['id']),
|
||||
'new_feed' => $this->oLivetrail->getNewFeed($this->asReq['id']),
|
||||
'add_post' => $this->oLivetrail->addPost($this->asReq['name'], $this->asReq['content']),
|
||||
'subscribe' => $this->oLivetrail->subscribe(),
|
||||
'unsubscribe' => $this->oLivetrail->unsubscribe(),
|
||||
'login' => $this->oLivetrail->login($this->asReq['email'], $this->asReq['password'], $this->asReq['name']),
|
||||
'logout' => $this->oLivetrail->logout(),
|
||||
'update_project' => $this->oLivetrail->updateProject(),
|
||||
default => $this->dispatchAdmin($sAction)
|
||||
};
|
||||
}
|
||||
|
||||
private function dispatchAdmin(string $sAction): string
|
||||
{
|
||||
if(!$this->oSpot->checkUserClearance(User::CLEARANCE_ADMIN)) {
|
||||
return Spot::getJsonResult(false, Spot::NOT_FOUND);
|
||||
if(!$this->oLivetrail->checkUserClearance(User::CLEARANCE_ADMIN)) {
|
||||
return Livetrail::getJsonResult(false, Livetrail::NOT_FOUND);
|
||||
}
|
||||
|
||||
return match($sAction) {
|
||||
'upload' => $this->oSpot->upload(),
|
||||
'add_comment' => $this->oSpot->addComment($this->asReq['id_entity'], $this->asReq['content']),
|
||||
'add_position' => $this->oSpot->addPosition($this->asReq['latitude'], $this->asReq['longitude'], $this->asReq['timestamp']),
|
||||
'admin_get' => $this->oSpot->getAdminSettings(),
|
||||
'admin_set' => $this->oSpot->setAdminSettings($this->asReq['type'], $this->asReq['id_entity'], $this->asReq['field'], $this->asReq['value']),
|
||||
'admin_create' => $this->oSpot->createAdminSettings($this->asReq['type']),
|
||||
'admin_delete' => $this->oSpot->deleteAdminSettings($this->asReq['type'], $this->asReq['id_entity']),
|
||||
'sql' => $this->oSpot->getDbBuildScript(),
|
||||
default => Spot::getJsonResult(false, Spot::NOT_FOUND)
|
||||
'upload' => $this->oLivetrail->upload(),
|
||||
'add_comment' => $this->oLivetrail->addComment($this->asReq['id_entity'], $this->asReq['content']),
|
||||
'add_position' => $this->oLivetrail->addPosition($this->asReq['latitude'], $this->asReq['longitude'], $this->asReq['timestamp']),
|
||||
'admin_get' => $this->oLivetrail->getAdminSettings(),
|
||||
'admin_set' => $this->oLivetrail->setAdminSettings($this->asReq['type'], $this->asReq['id_entity'], $this->asReq['field'], $this->asReq['value']),
|
||||
'admin_create' => $this->oLivetrail->createAdminSettings($this->asReq['type']),
|
||||
'admin_delete' => $this->oLivetrail->deleteAdminSettings($this->asReq['type'], $this->asReq['id_entity']),
|
||||
'sql' => $this->oLivetrail->getDbBuildScript(),
|
||||
default => Livetrail::getJsonResult(false, Livetrail::NOT_FOUND)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Franzz\Spot;
|
||||
namespace Franzz\Livetrail;
|
||||
use Franzz\Objects\PhpObject;
|
||||
|
||||
/**
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Franzz\Spot;
|
||||
namespace Franzz\Livetrail;
|
||||
use Franzz\Objects\PhpObject;
|
||||
use Franzz\Objects\Mask;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
@@ -57,13 +57,13 @@ class Email extends PhpObject {
|
||||
$oPHPMailer->Password = Settings::MAIL_PASS; //SMTP password
|
||||
$oPHPMailer->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; //Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
|
||||
$oPHPMailer->Port = 587; //TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above
|
||||
$oPHPMailer->setFrom(Settings::MAIL_FROM, Spot::PROJECT_NAME);
|
||||
$oPHPMailer->addReplyTo(Settings::MAIL_FROM, Spot::PROJECT_NAME);
|
||||
$oPHPMailer->setFrom(Settings::MAIL_FROM, Livetrail::PROJECT_NAME);
|
||||
$oPHPMailer->addReplyTo(Settings::MAIL_FROM, Livetrail::PROJECT_NAME);
|
||||
|
||||
$bSuccess = true;
|
||||
foreach($this->asDests as $asDest) {
|
||||
//Message
|
||||
$this->oTemplate->setLanguage($asDest['language'], Spot::DEFAULT_LANG);
|
||||
$this->oTemplate->setLanguage($asDest['language'], Livetrail::DEFAULT_LANG);
|
||||
$this->oTemplate->setTimezone($asDest['timezone']);
|
||||
|
||||
//Unsubscribe Link
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Franzz\Spot;
|
||||
namespace Franzz\Livetrail;
|
||||
use Franzz\Objects\PhpObject;
|
||||
use Franzz\Objects\Db;
|
||||
use Franzz\Objects\Translator;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Franzz\Spot;
|
||||
namespace Franzz\Livetrail;
|
||||
use Franzz\Objects\PhpObject;
|
||||
use \Settings;
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Franzz\Spot;
|
||||
namespace Franzz\Livetrail;
|
||||
|
||||
class GeoJson extends Geo {
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Franzz\Spot;
|
||||
namespace Franzz\Livetrail;
|
||||
use Franzz\Objects\ToolBox;
|
||||
|
||||
class Gpx extends Geo {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Franzz\Spot;
|
||||
namespace Franzz\Livetrail;
|
||||
use Franzz\Objects\Db;
|
||||
use Franzz\Objects\Main;
|
||||
use Franzz\Objects\Translator;
|
||||
@@ -32,7 +32,7 @@ use \Settings;
|
||||
* - timezone: Site Timezone (stored user's timezone for emails)
|
||||
*/
|
||||
|
||||
class Spot extends Main
|
||||
class Livetrail extends Main
|
||||
{
|
||||
//Database
|
||||
const POST_TABLE = 'posts';
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Franzz\Spot;
|
||||
namespace Franzz\Livetrail;
|
||||
use Franzz\Objects\PhpObject;
|
||||
use Franzz\Objects\Db;
|
||||
use \Settings;
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Franzz\Spot;
|
||||
namespace Franzz\Livetrail;
|
||||
use Franzz\Objects\PhpObject;
|
||||
use Franzz\Objects\Db;
|
||||
use Franzz\Objects\ToolBox;
|
||||
@@ -57,7 +57,7 @@ class Media extends PhpObject {
|
||||
}
|
||||
else $sError = 'media.no_id';
|
||||
|
||||
return Spot::getResult(($sError==''), $sError, $asData);
|
||||
return Livetrail::getResult(($sError==''), $sError, $asData);
|
||||
}
|
||||
|
||||
public function getMediasInfo($oMediaIds=null) {
|
||||
@@ -138,7 +138,7 @@ class Media extends PhpObject {
|
||||
}
|
||||
}
|
||||
|
||||
return Spot::getResult(($sError==''), $sError, $asParams);
|
||||
return Livetrail::getResult(($sError==''), $sError, $asParams);
|
||||
}
|
||||
|
||||
private function getMediaInfoFromFile($sMediaName)
|
||||
@@ -173,7 +173,7 @@ class Media extends PhpObject {
|
||||
//Taken On
|
||||
if(isset($asExif['format']['tags']['com.apple.quicktime.creationdate'])) {
|
||||
$sTakenOn = $asExif['format']['tags']['com.apple.quicktime.creationdate']; //contains Time Zone
|
||||
$sTimeZone = Spot::getTimeZoneFromDate($sTakenOn) ?? $sTimeZone;
|
||||
$sTimeZone = Livetrail::getTimeZoneFromDate($sTakenOn) ?? $sTimeZone;
|
||||
}
|
||||
else $sTakenOn = $asExif['format']['tags']['creation_time'] ?? $asExif['streams'][0]['tags']['creation_time'];
|
||||
|
||||
@@ -207,7 +207,7 @@ class Media extends PhpObject {
|
||||
* 3. Timezone extracted from DateTimeOriginal
|
||||
* 4. Uploader Browser Time Zone (PHP Default Time Zone)
|
||||
*/
|
||||
$sTimeZone = $asExif['EXIF']['OffsetTimeOriginal'] ?? $asExif['EXIF']['UndefinedTag:0x9011'] ?? Spot::getTimeZoneFromDate($sTakenOn) ?? $sTimeZone;
|
||||
$sTimeZone = $asExif['EXIF']['OffsetTimeOriginal'] ?? $asExif['EXIF']['UndefinedTag:0x9011'] ?? Livetrail::getTimeZoneFromDate($sTakenOn) ?? $sTimeZone;
|
||||
}
|
||||
|
||||
//Location
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Franzz\Spot;
|
||||
namespace Franzz\Livetrail;
|
||||
use Franzz\Objects\PhpObject;
|
||||
use Franzz\Objects\Db;
|
||||
use \Settings;
|
||||
@@ -153,8 +153,8 @@ class Project extends PhpObject {
|
||||
case 2: $asProject['mode'] = self::MODE_HISTO; break;
|
||||
}
|
||||
$asProject['editable'] = $this->isModeEditable($asProject['mode']);
|
||||
$asProject['gpxfilepath'] = Spot::addTimestampToFilePath(Gpx::getFrontendFilePath($sCodeName));
|
||||
$asProject['geofilepath'] = Spot::addTimestampToFilePath(GeoJson::getFrontendFilePath($sCodeName));
|
||||
$asProject['gpxfilepath'] = Livetrail::addTimestampToFilePath(Gpx::getFrontendFilePath($sCodeName));
|
||||
$asProject['geofilepath'] = Livetrail::addTimestampToFilePath(GeoJson::getFrontendFilePath($sCodeName));
|
||||
$asProject['codename'] = $sCodeName;
|
||||
$asProject['default'] = ($sCodeName == $sDefaultProjectCodeName);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Franzz\Spot;
|
||||
namespace Franzz\Livetrail;
|
||||
use Franzz\Objects\UploadHandler;
|
||||
use Franzz\Objects\Translator;
|
||||
|
||||
|
||||
+7
-7
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Franzz\Spot;
|
||||
namespace Franzz\Livetrail;
|
||||
use Franzz\Objects\PhpObject;
|
||||
use Franzz\Objects\Db;
|
||||
use \Settings;
|
||||
@@ -116,16 +116,16 @@ class User extends PhpObject {
|
||||
$this->updateGravatar($iUserId, $sEmail);
|
||||
}
|
||||
|
||||
return Spot::getResult($bSuccess, $sDesc, [Db::getId(self::USER_TABLE) => $iUserId]);
|
||||
return Livetrail::getResult($bSuccess, $sDesc, [Db::getId(self::USER_TABLE) => $iUserId]);
|
||||
}
|
||||
|
||||
public function setSubscription($bSubscribed) {
|
||||
if($this->getUserId() > 0) {
|
||||
$iSubscribed = $bSubscribed?1:0;
|
||||
$iUserId = $this->oDb->updateRow(self::USER_TABLE, $this->getUserId(), array('subscribed'=>$iSubscribed));
|
||||
if(!$iUserId) return Spot::getResult(false, 'lang:error.commit_db');
|
||||
if(!$iUserId) return Livetrail::getResult(false, 'lang:error.commit_db');
|
||||
$this->asUserInfo['subscribed'] = $iSubscribed;
|
||||
return Spot::getResult(true, $iSubscribed?'lang:account.subscribed':'lang:account.unsubscribed');
|
||||
return Livetrail::getResult(true, $iSubscribed?'lang:account.subscribed':'lang:account.unsubscribed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ class User extends PhpObject {
|
||||
$this->setTokenCookie();
|
||||
}
|
||||
|
||||
return Spot::getResult($bSuccess, $sDesc);
|
||||
return Livetrail::getResult($bSuccess, $sDesc);
|
||||
}
|
||||
|
||||
public function logout() {
|
||||
@@ -208,7 +208,7 @@ class User extends PhpObject {
|
||||
$this->clearSession();
|
||||
$this->clearCookie();
|
||||
$this->setUserId(0);
|
||||
return Spot::getResult(true, 'lang:account.logged_out');
|
||||
return Livetrail::getResult(true, 'lang:account.logged_out');
|
||||
}
|
||||
|
||||
public function updateNickname($sNickname) {
|
||||
@@ -239,7 +239,7 @@ class User extends PhpObject {
|
||||
}
|
||||
}
|
||||
|
||||
return Spot::getResult($bSuccess, $sDesc);
|
||||
return Livetrail::getResult($bSuccess, $sDesc);
|
||||
}
|
||||
|
||||
/* Session */
|
||||
|
||||
Reference in New Issue
Block a user