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 +} ?>