From 6a3948783ff97c2c0d9029e0da72d2b30a55d211 Mon Sep 17 00:00:00 2001 From: pezcurrel Date: Thu, 28 Dec 2023 12:37:38 +0100 Subject: [PATCH] Began working on checks --- web/clitools/fedipact.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/web/clitools/fedipact.php b/web/clitools/fedipact.php index d2cc615..a7d3770 100755 --- a/web/clitools/fedipact.php +++ b/web/clitools/fedipact.php @@ -49,21 +49,25 @@ for ($i=1; $i<$argc; $i++) { } } +$codoms=0; +$ocont=@file($opts['ofpath'],FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); +if (is_array($ocont)) + $codoms=count($ocont); $cont=@file($opts['url'],FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES); if (is_array($cont)) { - $domlist=[]; + $doms=[]; foreach ($cont as $line) if (preg_match('#
  • \s*🖤\s*[a-z0-9\.\-\_]+@([a-z0-9\.\-\_]+)\s*
  • #iu',$line,$matches)===1) - if (!in_array($matches[1],$domlist)) - $domlist[]=mb_strtolower($matches[1]); - $cdomlist=count($domlist); - if ($cdomlist>0) { - sort($domlist); - $domlist=implode(N,$domlist); - if (@file_put_contents($opts['ofpath'],$domlist.N)===false) + if (!in_array($matches[1],$doms)) + $doms[]=mb_strtolower($matches[1]); + $cdoms=count($doms); + if ($cdoms>0) { + sort($doms); + $doms=implode(N,$doms); + if (@file_put_contents($opts['ofpath'],$doms.N)===false) mexit('couldn’t save domain list into «'.$opts['ofpath'].'» :-('.N,3); else - eecho('done saving '.$cdomlist.' entries into «'.$opts['ofpath'].'» :-)'.N,1); + eecho('done saving '.$cdoms.' entries into «'.$opts['ofpath'].'» :-)'.N,1); } else { mexit('couldn’t find any domain in «'.$opts['url'].'» :-('.N,2); }