#!/usr/bin/php . */ const N="\n"; define('SNAME',basename(__FILE__)); const LIBDP='/../lib'; require __DIR__.LIBDP.'/parsetime.php'; require __DIR__.LIBDP.'/gurl.php'; require __DIR__.LIBDP.'/tables.php'; require __DIR__.LIBDP.'/mb_ucfirst.php'; require __DIR__.LIBDP.'/mb_lcfirst.php'; require __DIR__.LIBDP.'/ghs.php'; require __DIR__.LIBDP.'/ght.php'; require __DIR__.LIBDP.'/supplangs.php'; require __DIR__.LIBDP.'/vendor/autoload.php'; use LanguageDetection\Language; use function mysqli_real_escape_string as myesc; (strtoupper(substr(PHP_OS,0,3))==='WIN') ? $iswin=true : $iswin=false; declare(ticks=1); if (function_exists('pcntl_signal')) { function signalHandler($signal) { echo(N); mexit('received signal «'.$signal.'», shutting down.'.N,0); } pcntl_signal(SIGTERM,'signalHandler');// Termination ('kill' was called) pcntl_signal(SIGHUP,'signalHandler');// Terminal log-out pcntl_signal(SIGINT,'signalHandler');// Interrupted (Ctrl-C is pressed) } $opts=[ 'hostname'=>null, 'conntimeout'=>10, 'functimeout'=>20, 'ldtoots'=>40,// number of toots to check with the automatic language detection function 'dryrun'=>false, 'fetchusers'=>false, 'udiratts'=>5, 'udirfailst'=>90, 'minmsgimplev'=>1 ]; $msglevs=['Debug', 'Info', 'Warning', 'Error', 'None']; $help='SYNOPSIS '.SNAME.' [options] DESCRIPTION This script tries to fetch info about the fediverse instance at the given hostname and insert or update them in mastostart’s database. OPTIONS -l, --ldtoots This option defines the number of toots the script will try to fetch from the local public timelines, to try and guess the most used languages of each instance. Its minimum value is 10, its maximum value is 40. DEFAULT: '.$opts['ldtoots'].' -f, --fetchusers If this option is set, the script will try to fetch users’ info from the considered instance’s users directory, and store them in the database. -r, --udiratts This option defines how many attempts the script will do at fetching a chunk of users’ info from the profile directory, before giving up. DEFAULT: '.$opts['udiratts'].' -s, --udirfailst