Generate Cron File
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -15,3 +15,4 @@
|
||||
/files/**/*.mov
|
||||
/files/**/*.MOV
|
||||
/geo/*.geojson
|
||||
/spot_cron.sh
|
||||
|
||||
@@ -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() {
|
||||
|
||||
10
inc/spot.php
10
inc/spot.php
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user