From a611e251fcd0c5f42eb0c19e9153f3509c79c098 Mon Sep 17 00:00:00 2001 From: pezcurrel Date: Sun, 25 Feb 2024 09:55:59 +0100 Subject: [PATCH] =?UTF-8?q?Fixed=20a=20bug=20that=20was=20preventing=20cra?= =?UTF-8?q?wler.php=20and=20peerscrawl.php=20to=20use=20the=20actual=20gra?= =?UTF-8?q?celine=20they=20should=20be=20using=20when=20the=20=E2=80=9C--g?= =?UTF-8?q?racetime=E2=80=9D=20option=20was=20used?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/clitools/crawler.php | 2 ++ web/clitools/peerscrawl.php | 3 +++ web/lib/grace.php | 10 ++++++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/web/clitools/crawler.php b/web/clitools/crawler.php index 7b8351a..0b36012 100755 --- a/web/clitools/crawler.php +++ b/web/clitools/crawler.php @@ -135,6 +135,7 @@ for ($i=1; $i<$argc; $i++) { $i++; $opts['gracetime']=$time; } elseif ($argv[$i]=='-G' || $argv[$i]=='--graceline') { + $graceline=getgraceline($opts['gracetime']); echo 'Graceline: '.$graceline.' ('.date('Y-m-d H:i:s',$graceline).').'.N; exit(0); } elseif ($argv[$i]=='-p' || $argv[$i]=='--peersfp') { @@ -164,6 +165,7 @@ for ($i=1; $i<$argc; $i++) { } } +$graceline=getgraceline($opts['gracetime']); $rundirpath=__DIR__.'/run'; $lockfp=$rundirpath.'/'.FNAME.'.lock'; diff --git a/web/clitools/peerscrawl.php b/web/clitools/peerscrawl.php index d0dd638..03d3888 100755 --- a/web/clitools/peerscrawl.php +++ b/web/clitools/peerscrawl.php @@ -163,6 +163,7 @@ for ($i=1; $i<$argc; $i++) { $i++; $opts['minmsgimplev']=array_search(ucfirst(strtolower($argv[$i])),$msglevs); } elseif ($argv[$i]=='-G' || $argv[$i]=='--graceline') { + $graceline=getgraceline($opts['gracetime']); echo 'Graceline: '.$graceline.' ('.date('Y-m-d H:i:s',$graceline).').'.N; exit(0); } elseif ($argv[$i]=='-h' || $argv[$i]=='--help') { @@ -173,6 +174,8 @@ for ($i=1; $i<$argc; $i++) { } } +$graceline=getgraceline($opts['gracetime']); + $lockfp=__DIR__.'/'.BNAME.'.lock'; if (is_file($lockfp) && !$opts['ignorelock']) mexit(3,'lockfile exists: it seems the program is already running; if you’re sure it’s not, you can use «-I» to force execution.'.N,1,false); if (@touch($lockfp)===false) mexit(3,'could not create lockfile «'.$lockfp.'».'.N,1,false); diff --git a/web/lib/grace.php b/web/lib/grace.php index b6fc811..090d9f8 100644 --- a/web/lib/grace.php +++ b/web/lib/grace.php @@ -2,9 +2,11 @@ $graceminfreq=48*60*60;// 2 days $gracetime=30*24*60*60;// 30 days -$now=time(); -$graceline=gmmktime(0,0,0,gmdate('n',$now),gmdate('j',$now),gmdate('Y',$now))-$gracetime;// we fix the graceline at start of today minus $gracetime -//$graceline=$now-$gracetime;// we fix the graceline at now minus $gracetime -unset($now); +$graceline=getgraceline($gracetime); + +function getgraceline($gracetime) { + $now=time(); + return gmmktime(0,0,0,gmdate('n',$now),gmdate('j',$now),gmdate('Y',$now))-$gracetime;// we fix the graceline at start of today minus $gracetime +} ?>