From 980f7422712d7a221ffa204dff24f2a54fae0f79 Mon Sep 17 00:00:00 2001 From: pezcurrel Date: Tue, 29 Oct 2024 15:28:23 +0100 Subject: [PATCH] =?UTF-8?q?Refined=20the=20regex=20to=20check=20if=20the?= =?UTF-8?q?=20state=20file=20is=20well=20formed;=20changed=20=E2=80=9Cgrac?= =?UTF-8?q?eTime=E2=80=9D=20from=201=20year=20to=203=20years;=20changed=20?= =?UTF-8?q?the=20help=20text=20accordingly;=20bumped=20version=20to=200.5.?= =?UTF-8?q?2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ganciof2f | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ganciof2f b/ganciof2f index e08b637..a8195dd 100755 --- a/ganciof2f +++ b/ganciof2f @@ -18,7 +18,7 @@ $SNAME='GancioF2F'; $ENAME=strtolower($SNAME); -$SVERS='0.5.1'; +$SVERS='0.5.2'; require __DIR__.'/lib/ckmkeys.php'; require __DIR__.'/lib/gettlds.php'; @@ -86,7 +86,7 @@ fedi_token = w6oQ_Ot2LSAm_Q31hrvp0asfl22ip3O4ipYq1kV1ceY # «state_file_absolute_path» is required to specify the absolute path of the # state file where {$SNAME} will store the references to already posted # announcements (on every run, {$SNAME} will check this file for entries older -# than one year and discard them, to avoid the state file to grow too much). +# than 3 years and discard them, to avoid the state file to grow too much). # For example: state_file_absolute_path = /var/local/cache/ganciof2f/gancio.some.domain.state @@ -322,12 +322,13 @@ if (file_exists($conf['state_file_absolute_path'])) { if (!is_readable($conf['state_file_absolute_path'])) dieYoung("Error: «{$conf['state_file_absolute_path']}» exists but it’s not readable.\n",1); if (!is_writeable($conf['state_file_absolute_path'])) dieYoung("Error: «{$conf['state_file_absolute_path']}» exists but it’s not writable.\n",1); $refs=[]; - $graceTime=365*24*60*60; + $graceTime=365*3*24*60*60; $graceLine=time()-$graceTime; $i=0; $buff=file($conf['state_file_absolute_path'],FILE_IGNORE_NEW_LINES); foreach ($buff as $key=>$val) { - if (preg_match('#^(\S+)\t(\S+)\t(\d+)$#',$val,$matches)===1) {// todo: refine the pattern + //incontro-aperto-mensile-3 2024-10-04T13:33:45.331Z 1730206671 + if (preg_match('#^([a-z0-9-_]+)\t(\d{4,}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+Z)\t(\d+)$#',$val,$matches)===1) { if ($matches[3]+0>=$graceLine) $refs[$matches[1]]=['updatedAt'=>$matches[2], 'postedAt'=>$matches[3]]; else