#!/usr/bin/php . */ define('N',"\n"); require __DIR__.'/../lib/delinstbyid.php'; $levs=['Debug', 'Info', 'Warning', 'Error']; $opts=[ 'url'=>'https://fedipact.online/', 'ofpath'=>__DIR__.'/fedipact.list' ]; $help='mustool.php DESCRIPTION fedipact.php downloads the list of Anti-Meta Fedi Pact signers from «'.$opts['url'].'», parses it, creates a machine readable signers list and saves it to «'.$opts['ofpath'].'». SYNOPSIS fedipact.php OPTIONS -h, --help Shows this help text and exits. This program comes with ABSOLUTELY NO WARRANTY; for details see the source. This is free software, and you are welcome to redistribute it under certain conditions; see for details.'.N; for ($i=1; $i<$argc; $i++) { if ($argv[$i]=='-h' || $argv[$i]=='--help') { echo($help); exit(0); } else { mexit('don’t know how to interpret «'.$argv[$i].'» (use «-h» to read help).'.N,1); } } $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)) { $doms=[]; foreach ($cont as $line) // if (preg_match('#
  • \s*🖤\s*[a-z0-9\.\-\_]+@([a-z0-9\.\-\_]+)\s*
  • #iu',$line,$matches)===1) if (preg_match('#
  • \s*[a-z0-9\.\-\_]+@([a-z0-9\.\-\_]+)\s*
  • #iu',$line,$matches)===1) 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 '.$cdoms.' entries into «'.$opts['ofpath'].'» :-)'.N,1); } else { mexit('couldn’t find any domain in «'.$opts['url'].'» :-('.N,2); } } else { mexit('couldn’t open «'.$opts['url'].'».'.N,3); } exit(0); // functions function mexit($msg,$code) { global $link; if (isset($link) && $link!==false) mysqli_close($link); if ($code==0) eecho($msg,1); else eecho($msg,3); exit($code); } function eecho($msg,$lev=1) { global $levs; $time=microtime(false); $time=explode(' ',$time); $time=date('Y-m-d H:i:s',$time[1]).'.'.substr($time[0],2); $msg=$time.' '.$levs[$lev].': '.$msg; if ($lev<2) echo($msg); else fwrite(STDERR,$msg); } ?>