diff --git a/.gitignore b/.gitignore index 38210d7..4d69aa9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,5 @@ -/build.xml /settings.php -/.externalToolBuilders/ -/.sass-cache/ -/.buildpath -/.project /style/.sass-cache/ -/.settings/ /files/**/*.jpg /files/**/*.JPG /files/**/*.jpeg @@ -17,3 +11,4 @@ /geo/*.geojson /spot_cron.sh /vendor/* +/log.html \ No newline at end of file diff --git a/composer.lock b/composer.lock index d372eaa..bc29141 100644 --- a/composer.lock +++ b/composer.lock @@ -12,7 +12,7 @@ "dist": { "type": "path", "url": "../objects", - "reference": "25c0f66cff31e30c730a6891e5e15b1cc209af67" + "reference": "e1cf78b992a6f52742d6834f7508c0ef373ac860" }, "type": "library", "autoload": { @@ -27,16 +27,16 @@ }, { "name": "phpmailer/phpmailer", - "version": "v6.6.4", + "version": "v6.8.0", "source": { "type": "git", "url": "https://github.com/PHPMailer/PHPMailer.git", - "reference": "a94fdebaea6bd17f51be0c2373ab80d3d681269b" + "reference": "df16b615e371d81fb79e506277faea67a1be18f1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/a94fdebaea6bd17f51be0c2373ab80d3d681269b", - "reference": "a94fdebaea6bd17f51be0c2373ab80d3d681269b", + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/df16b615e371d81fb79e506277faea67a1be18f1", + "reference": "df16b615e371d81fb79e506277faea67a1be18f1", "shasum": "" }, "require": { @@ -46,22 +46,24 @@ "php": ">=5.5.0" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", - "doctrine/annotations": "^1.2", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.2", + "doctrine/annotations": "^1.2.6 || ^1.13.3", "php-parallel-lint/php-console-highlighter": "^1.0.0", "php-parallel-lint/php-parallel-lint": "^1.3.2", "phpcompatibility/php-compatibility": "^9.3.5", "roave/security-advisories": "dev-latest", - "squizlabs/php_codesniffer": "^3.6.2", - "yoast/phpunit-polyfills": "^1.0.0" + "squizlabs/php_codesniffer": "^3.7.1", + "yoast/phpunit-polyfills": "^1.0.4" }, "suggest": { "ext-mbstring": "Needed to send email in multibyte encoding charset or decode encoded addresses", + "ext-openssl": "Needed for secure SMTP sending and DKIM signing", + "greew/oauth2-azure-provider": "Needed for Microsoft Azure XOAUTH2 authentication", "hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication", "league/oauth2-google": "Needed for Google XOAUTH2 authentication", "psr/log": "For optional PSR-3 debug logging", - "stevenmaguire/oauth2-microsoft": "Needed for Microsoft XOAUTH2 authentication", - "symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)" + "symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)", + "thenetworg/oauth2-azure": "Needed for Microsoft XOAUTH2 authentication" }, "type": "library", "autoload": { @@ -93,7 +95,7 @@ "description": "PHPMailer is a full-featured email creation and transfer class for PHP", "support": { "issues": "https://github.com/PHPMailer/PHPMailer/issues", - "source": "https://github.com/PHPMailer/PHPMailer/tree/v6.6.4" + "source": "https://github.com/PHPMailer/PHPMailer/tree/v6.8.0" }, "funding": [ { @@ -101,7 +103,7 @@ "type": "github" } ], - "time": "2022-08-22T09:22:00+00:00" + "time": "2023-03-06T14:43:22+00:00" } ], "packages-dev": [], @@ -114,5 +116,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.3.0" } diff --git a/inc/Converter.php b/inc/Converter.php index a657ae8..e46342f 100644 --- a/inc/Converter.php +++ b/inc/Converter.php @@ -19,7 +19,7 @@ use \Settings; class Converter extends PhpObject { public function __construct() { - parent::__construct(__CLASS__, Settings::DEBUG); + parent::__construct(__CLASS__); } public static function convertToGeoJson($sCodeName) { @@ -36,8 +36,11 @@ class Converter extends PhpObject { public static function isGeoJsonValid($sCodeName) { $bResult = false; + $sGpxFilePath = Geo::getFilePath($sCodeName, Gpx::EXT); $sGeoJsonFilePath = Geo::getFilePath($sCodeName, GeoJson::EXT); - if(file_exists($sGeoJsonFilePath) && filemtime($sGeoJsonFilePath) > filemtime(Geo::getFilePath($sCodeName, Gpx::EXT))) $bResult = true; + + //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; return $bResult; } } @@ -80,33 +83,36 @@ class Gpx extends Geo { private function parseFile() { $this->addNotice('Parsing: '.$this->sFilePath); - $oXml = simplexml_load_file($this->sFilePath); + if(!file_exists($this->sFilePath)) $this->addError($this->sFilePath.' file missing'); + else { + $oXml = simplexml_load_file($this->sFilePath); - //Tracks - $this->addNotice('Converting '.count($oXml->trk).' tracks'); - foreach($oXml->trk as $aoTrack) { - $asTrack = array( - 'name' => (string) $aoTrack->name, - 'desc' => str_replace("\n", '', ToolBox::fixEOL((strip_tags($aoTrack->desc)))), - 'cmt' => ToolBox::fixEOL((strip_tags($aoTrack->cmt))), - 'color' => (string) $aoTrack->extensions->children('gpxx', true)->TrackExtension->DisplayColor, - 'points'=> array() - ); + //Tracks + $this->addNotice('Converting '.count($oXml->trk).' tracks'); + foreach($oXml->trk as $aoTrack) { + $asTrack = array( + 'name' => (string) $aoTrack->name, + 'desc' => str_replace("\n", '', ToolBox::fixEOL((strip_tags($aoTrack->desc)))), + 'cmt' => ToolBox::fixEOL((strip_tags($aoTrack->cmt))), + 'color' => (string) $aoTrack->extensions->children('gpxx', true)->TrackExtension->DisplayColor, + 'points'=> array() + ); - foreach($aoTrack->trkseg as $asSegment) { - foreach($asSegment as $asPoint) { - $asTrack['points'][] = array( - 'lon' => (float) $asPoint['lon'], - 'lat' => (float) $asPoint['lat'], - 'ele' => (int) $asPoint->ele - ); + foreach($aoTrack->trkseg as $asSegment) { + foreach($asSegment as $asPoint) { + $asTrack['points'][] = array( + 'lon' => (float) $asPoint['lon'], + 'lat' => (float) $asPoint['lat'], + 'ele' => (int) $asPoint->ele + ); + } } + $this->asTracks[] = $asTrack; } - $this->asTracks[] = $asTrack; - } - //Waypoints - $this->addNotice('Ignoring '.count($oXml->wpt).' waypoints'); + //Waypoints + $this->addNotice('Ignoring '.count($oXml->wpt).' waypoints'); + } } } diff --git a/inc/Email.php b/inc/Email.php index cd91c70..11b52cb 100644 --- a/inc/Email.php +++ b/inc/Email.php @@ -22,6 +22,7 @@ class Email extends PhpObject { private $asDests; public function __construct($sServName, $sTemplateName='') { + parent::__construct(__CLASS__); $this->sServName = $sServName; $this->setTemplate($sTemplateName); $this->asDests = array(); diff --git a/inc/Feed.php b/inc/Feed.php index 56c727d..22561e7 100644 --- a/inc/Feed.php +++ b/inc/Feed.php @@ -54,7 +54,7 @@ class Feed extends PhpObject { private $iLastUpdate; public function __construct(Db &$oDb, $iFeedId=0) { - parent::__construct(__CLASS__, Settings::DEBUG); + parent::__construct(__CLASS__); $this->oDb = &$oDb; if($iFeedId > 0) $this->setFeedId($iFeedId); } diff --git a/inc/Map.php b/inc/Map.php index 14d4cd7..4a2db6a 100644 --- a/inc/Map.php +++ b/inc/Map.php @@ -15,7 +15,7 @@ class Map extends PhpObject { private $asMaps; public function __construct(Db &$oDb) { - parent::__construct(__CLASS__, Settings::DEBUG); + parent::__construct(__CLASS__); $this->oDb = &$oDb; $this->setMaps(); } diff --git a/inc/Media.php b/inc/Media.php index 8157637..11b31d1 100644 --- a/inc/Media.php +++ b/inc/Media.php @@ -35,7 +35,7 @@ class Media extends PhpObject { private $iMediaId; public function __construct(Db &$oDb, &$oProject, $iMediaId=0) { - parent::__construct(__CLASS__, Settings::DEBUG); + parent::__construct(__CLASS__); $this->oDb = &$oDb; $this->oProject = &$oProject; $this->asMedia = array(); diff --git a/inc/Project.php b/inc/Project.php index 649e059..26378ec 100644 --- a/inc/Project.php +++ b/inc/Project.php @@ -22,14 +22,16 @@ class Project extends PhpObject { */ private $oDb; + private $iProjectId; - private $sMode; private $sName; private $sCodeName; + private $sMode; private $asActive; + private $asGeo; public function __construct(Db &$oDb, $iProjectId=0) { - parent::__construct(__CLASS__, Settings::DEBUG); + parent::__construct(__CLASS__); $this->oDb = &$oDb; if($iProjectId > 0) $this->setProjectId($iProjectId); } @@ -179,10 +181,10 @@ class Project extends PhpObject { if($this->getProjectId() > 0) { $asProject = $this->getProject(); + $this->sName = $asProject['name']; + $this->sCodeName = $asProject['codename']; $this->sMode = $asProject['mode']; $this->asActive = array('from'=>$asProject['active_from'], 'to'=>$asProject['active_to']); - $this->sCodeName = $asProject['codename']; - $this->sName = $asProject['name']; $this->asGeo = array('geofile'=>$asProject['geofilepath'], 'gpxfile'=>$asProject['gpxfilepath']); } else $this->addError('Error while setting project: no project ID'); diff --git a/inc/Spot.php b/inc/Spot.php index e0efc7a..c347648 100755 --- a/inc/Spot.php +++ b/inc/Spot.php @@ -47,7 +47,7 @@ class Spot extends Main public function __construct($sProcessPage, $sTimezone) { - parent::__construct($sProcessPage, true, __FILE__, $sTimezone); + parent::__construct($sProcessPage, true, $sTimezone); $this->oUser = new User($this->oDb); @@ -248,8 +248,7 @@ class Spot extends Main } $bSuccess = $oEmail->send(); - if(!$bSuccess) $sDesc = $oEmail->ErrorInfo; - else $sDesc = 'mail_sent'; + $sDesc = $bSuccess?'mail_sent':'mail_failure'; } else $sDesc = 'no_new_msg'; diff --git a/inc/User.php b/inc/User.php index 6cfad08..8c62eee 100644 --- a/inc/User.php +++ b/inc/User.php @@ -31,7 +31,7 @@ class User extends PhpObject { private $asUserInfo; public function __construct(Db &$oDb) { - parent::__construct(__CLASS__, Settings::DEBUG); + parent::__construct(__CLASS__); $this->oDb = &$oDb; $this->iUserId = 0; $this->asUserInfo = array( diff --git a/settings-sample.php b/settings-sample.php index 6b0b3cf..632f4e3 100755 --- a/settings-sample.php +++ b/settings-sample.php @@ -16,4 +16,5 @@ class Settings const WEATHER_TOKEN = ''; //visualcrossing.com const TIMEZONE_USER = ''; //geonames.org const DEBUG = true; + const LOG_FOLDER = __DIR__; }