Generate Cron File

This commit is contained in:
2020-04-10 09:14:59 +02:00
parent a81f7a596b
commit e34c2b690d
5 changed files with 21 additions and 4 deletions

1
.gitignore vendored
View File

@@ -15,3 +15,4 @@
/files/**/*.mov
/files/**/*.MOV
/geo/*.geojson
/spot_cron.sh

View File

@@ -101,8 +101,13 @@ class Feed extends PhpObject {
}
public function checkUpdateFeed($sProjectMode) {
//Feed updated once every hour in Blog Mode
if($sProjectMode == Project::MODE_BLOG && date('Y-m-d-H', $this->iLastUpdate) != date('Y-m-d-H')) $this->updateFeed();
//Feed updated once every hour in Blog Mode (no need for timezone when substracting 2 dates)
if($sProjectMode == Project::MODE_BLOG) {
$oLastUpdate = new DateTime('@'.$this->iLastUpdate);
$oNow = new DateTime('now');
if(intval($oNow->diff($oLastUpdate)->format('%H')) > 0) $this->updateFeed();
}
}
private function updateFeed() {

View File

@@ -140,7 +140,9 @@ class Spot extends Main
),
'consts' => array(
'geo_server' => Settings::GEO_SERVER,
'modes' => Project::MODES )
'modes' => Project::MODES,
'default_timezone' => Settings::TIMEZONE
)
),
'index',
array(
@@ -169,6 +171,12 @@ class Spot extends Main
}
}
public function genCronFile() {
//$bResult = (file_put_contents('spot_cron.sh', '#!/bin/bash'."\n".'cd '.dirname($_SERVER['SCRIPT_FILENAME'])."\n".'php -f index.php a=update_feed')!==false);
$bResult = (file_put_contents('spot_cron.sh', '#!/bin/bash'."\n".'wget -qO- '.$this->asContext['serv_name'].'index.php?a=dummy > /dev/null')!==false);
return $bResult?self::SUCCESS:self::ERROR;
}
public function getMarkers()
{
$asMessages = $this->getSpotMessages();

View File

@@ -75,6 +75,9 @@ if($sAction!='')
case 'unsubscribe_email':
$sResult = $oSpot->unsubscribeFromEmail($iId);
break;
case 'generate_cron':
$sResult = $oSpot->genCronFile();
break;
default:
$sResult = Main::getJsonResult(false, Main::NOT_FOUND);
}

View File

@@ -5,7 +5,7 @@ function Spot(asGlobals)
this.consts.hash_sep = '-';
this.consts.title = 'Spotty';
this.consts.default_page = 'project';
this.consts.timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
this.consts.timezone = Intl.DateTimeFormat().resolvedOptions().timeZone || this.consts.default_timezone;
/* Initialization */