#!/usr/bin/php . */ const N="\n"; const RN="\r\n"; define('SNAME',basename(__FILE__)); chdir(__DIR__); require '../lib/parsetime.php'; require '../lib/gurl.php'; require '../lib/gethttpcode.php'; require '../lib/tables.php'; require '../lib/mb_ucfirst.php'; require '../lib/mb_lcfirst.php'; require '../lib/ghs.php'; require '../lib/ght.php'; require '../lib/fnum.php'; require '../lib/supplangs.php'; require '../lib/gettlds.php'; require '../lib/mastodon_postlen.php'; require '../lib/ckratelimit.php'; require '../lib/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, 'bothost'=>null, 'bottoken'=>null, 'botmaxchars'=>null, '_sendtoot'=>false, 'proxy'=>null, 'useproxyfor'=>null ]; $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