Move files (again)

This commit is contained in:
franzz committed 2023-11-07 19:41:28 +01:00
1 parent ab914a391f
commit 97645b3476
31 files changed
+155 -38

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
#!/bin/bash
wget -qO- https://spot.lutran.fr/index.php?a=update_project > /dev/null
#Crontab job: 0 * * * * . /var/www/spot/spot_cron.sh > /dev/null
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+11 -7
View File
@@ -36,18 +36,18 @@ class Converter extends PhpObject {
public static function isGeoJsonValid($sCodeName) { public static function isGeoJsonValid($sCodeName) {
$bResult = false; $bResult = false;
$sGpxFilePath = Geo::getFilePath($sCodeName, Gpx::EXT); $sGpxFilePath = Gpx::getFilePath($sCodeName);
$sGeoJsonFilePath = Geo::getFilePath($sCodeName, GeoJson::EXT); $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(Geo::getFilePath($sCodeName, Gpx::EXT))) $bResult = true; if(!file_exists($sGpxFilePath) || file_exists($sGeoJsonFilePath) && filemtime($sGeoJsonFilePath) > filemtime(Gpx::getFilePath($sCodeName))) $bResult = true;
return $bResult; return $bResult;
} }
} }
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;
@@ -55,12 +55,16 @@ class Geo extends PhpObject {
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);
$this->asTracks = array(); $this->asTracks = array();
} }
public static function getFilePath($sCodeName, $sExt) { public static function getFilePath($sCodeName) {
return self::GEO_FOLDER.$sCodeName.$sExt; return self::GEO_FOLDER.$sCodeName.static::EXT;
}
public static function getDistFilePath($sCodeName) {
return 'geo/'.$sCodeName.static::EXT;
} }
public function getLog() { public function getLog() {
View File
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
+1 -1
View File
@@ -12,7 +12,7 @@ class Media extends PhpObject {
const MEDIA_TABLE = 'medias'; const MEDIA_TABLE = 'medias';
//Media folders //Media folders
const MEDIA_FOLDER = 'files/'; const MEDIA_FOLDER = '../files/';
const THUMB_FOLDER = self::MEDIA_FOLDER.'thumbs/'; const THUMB_FOLDER = self::MEDIA_FOLDER.'thumbs/';
const THUMB_MAX_WIDTH = 400; const THUMB_MAX_WIDTH = 400;
+2 -2
View File
@@ -144,8 +144,8 @@ class Project extends PhpObject {
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(GeoJson::getDistFilePath($sCodeName));
$asProject['gpxfilepath'] = Spot::addTimestampToFilePath(Geo::getFilePath($sCodeName, Gpx::EXT)); $asProject['gpxfilepath'] = Spot::addTimestampToFilePath(Gpx::getDistFilePath($sCodeName));
$asProject['codename'] = $sCodeName; $asProject['codename'] = $sCodeName;
} }
return $bSpecificProj?$asProject:$asProjects; return $bSpecificProj?$asProject:$asProjects;
+30 -28
View File
@@ -40,6 +40,8 @@ class Spot extends Main
const DEFAULT_LANG = 'en'; const DEFAULT_LANG = 'en';
const MAIN_PAGE = 'index';
private Project $oProject; private Project $oProject;
private Media $oMedia; private Media $oMedia;
private User $oUser; private User $oUser;
@@ -158,42 +160,42 @@ class Spot extends Main
); );
} }
public function getAppMainPage() public function getAppParams() {
{
//Cache Page List //Cache Page List
$asPages = array_diff($this->asMasks, array('email_update', 'email_conf')); $asPages = array_diff($this->asMasks, array('email_update', 'email_conf'));
if(!$this->oUser->checkUserClearance(User::CLEARANCE_ADMIN)) { if(!$this->oUser->checkUserClearance(User::CLEARANCE_ADMIN)) {
$asPages = array_diff($asPages, array('admin', 'upload')); $asPages = array_diff($asPages, array('admin', 'upload'));
} }
$asGlobalVars = array(
'vars' => array(
'chunk_size' => self::FEED_CHUNK_SIZE,
'default_project_codename' => $this->oProject->getProjectCodeName(),
'projects' => $this->oProject->getProjects(),
'user' => $this->oUser->getUserInfo()
),
'consts' => array(
'server' => $this->asContext['serv_name'],
'modes' => Project::MODES,
'clearances' => User::CLEARANCES,
'default_timezone' => Settings::TIMEZONE
)
);
return self::getJsonResult(true, '', parent::getParams($asGlobalVars, self::MAIN_PAGE, $asPages));
}
public function getAppMainPage()
{
return parent::getMainPage( return parent::getMainPage(
self::MAIN_PAGE,
array( array(
'vars' => array( 'language' => $this->oLang->getLanguage(),
'chunk_size' => self::FEED_CHUNK_SIZE, 'host_url' => $this->asContext['serv_name'],
'default_project_codename' => $this->oProject->getProjectCodeName(), 'filepath_css' => self::addTimestampToFilePath('spot.css'),
'projects' => $this->oProject->getProjects(), 'filepath_js' => self::addTimestampToFilePath('../dist/app.js')
'user' => $this->oUser->getUserInfo() )
),
'consts' => array(
'server' => $this->asContext['serv_name'],
'modes' => Project::MODES,
'clearances' => User::CLEARANCES,
'default_timezone' => Settings::TIMEZONE
)
),
'index',
array(
'language' => $this->oLang->getLanguage(),
'host_url' => $this->asContext['serv_name'],
'filepath_css' => self::addTimestampToFilePath('style/spot.css'),
'filepath_js_d3' => self::addTimestampToFilePath('script/d3.min.js'),
'filepath_js_leaflet' => self::addTimestampToFilePath('script/leaflet.min.js'),
'filepath_js_jquery' => self::addTimestampToFilePath('script/jquery.min.js'),
'filepath_js_jquery_mods' => self::addTimestampToFilePath('script/jquery.mods.js'),
'filepath_js_spot' => self::addTimestampToFilePath('script/spot.js'),
'filepath_js_lightbox' => self::addTimestampToFilePath('script/lightbox.js')
),
$asPages
); );
} }
File renamed without changes.
View File
File renamed without changes.
Executable
+107
View File
@@ -0,0 +1,107 @@
<?php
/* Requests Handler */
//Start buffering
ob_start();
//Run from /dist/
$oLoader = require __DIR__.'/../vendor/autoload.php';
use Franzz\Objects\ToolBox;
use Franzz\Objects\Main;
use Franzz\Spot\Spot;
use Franzz\Spot\User;
ToolBox::fixGlobalVars($argv ?? array());
//Available variables
$sAction = $_REQUEST['a'] ?? '';
$sTimezone = $_REQUEST['t'] ?? '';
$sName = $_GET['name'] ?? '';
$sContent = $_GET['content'] ?? '';
$iProjectId = $_REQUEST['id_project'] ?? 0 ;
$sField = $_REQUEST['field'] ?? '';
$oValue = $_REQUEST['value'] ?? '';
$iId = $_REQUEST['id'] ?? 0 ;
$sType = $_REQUEST['type'] ?? '';
$sEmail = $_REQUEST['email'] ?? '';
//Initiate class
$oSpot = new Spot(__FILE__, $sTimezone);
$oSpot->setProjectId($iProjectId);
$sResult = '';
if($sAction!='')
{
switch($sAction)
{
case 'params':
$sResult = $oSpot->getAppParams();
break;
case 'markers':
$sResult = $oSpot->getMarkers();
break;
case 'next_feed':
$sResult = $oSpot->getNextFeed($iId);
break;
case 'new_feed':
$sResult = $oSpot->getNewFeed($iId);
break;
case 'add_post':
$sResult = $oSpot->addPost($sName, $sContent);
break;
case 'subscribe':
$sResult = $oSpot->subscribe($sEmail, $sName);
break;
case 'unsubscribe':
$sResult = $oSpot->unsubscribe();
break;
case 'unsubscribe_email':
$sResult = $oSpot->unsubscribeFromEmail($iId);
break;
case 'update_project':
$sResult = $oSpot->updateProject();
break;
default:
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 '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->getAppMainPage();
$sDebug = ob_get_clean();
if(Settings::DEBUG && $sDebug!='') $oSpot->addUncaughtError($sDebug);
echo $sResult;