. */ // Logorrh, Verbose, Charliero, Tashugo? require 'lib/gettlds.php'; $tlds=gettlds(); $retlds=implode('|',$tlds); $jstlds="const tlds=['".implode("', '",$tlds)."'];\n"; if (@file_put_contents('js/tlds.js',$jstlds)===false) dieyoung('Error: could not save «js/tlds.js»'); unset($tlds,$jstlds); require 'lib/mastodon.php'; require 'lib/ckratelimit.php'; require 'lib/getfirstbrowserlang.php'; require 'lib/ght.php'; require 'lib/booltostr.php'; const SNAME='Verbose'; const SVERS='0.3.5'; const SREPO='https://git.lattuga.net/pongrebio/verbose'; const DEFAC=500; const MINAC=100; const MAXAC=100000; const MINCL=40; const MAXPOSTC=50000; const MAXREPTOLEN=1500; const POSTPAUSE=250;// pause between sending split posts (in milliseconds) const REQSTOPRESV=10;// requests to preserve const CONFFN='conf.ini'; $sname=SNAME; $svers=SVERS; $now=time(); $timeout=5; $formact=preg_replace('#[^/]+$#','',$_SERVER['REQUEST_URI']); $dodebug=false; $debug=''; ini_set('max_execution_time',360);// 6 minutes: default mastodon ratelimits: https://docs.joinmastodon.org/api/rate-limits/ $conf=['link'=>"\n\n[This post was split using ".SREPO.']']; if (file_exists(CONFFN)) { $fconf=@parse_ini_file(CONFFN,false,INI_SCANNER_RAW); if ($fconf===false) { dieyoung('Error: configuration file «'.CONFFN.'» was found but could not be opened for reading.'); } else { if (isset($fconf['link'])) $conf['link']="\n\n{$fconf['link']}"; if (isset($fconf['footer'])) $conf['footer']=$fconf['footer']; if (isset($fconf['webservertimeout'])) { if (preg_match('#^\d+$#',$fconf['webservertimeout'])===1) $conf['webservertimeout']=$fconf['webservertimeout']+0; else dieyoung('Error: configuration file «'.CONFFN.'»: value «'.$fconf['webservertimeout'].'» is not valid for «webservertimeout».'); } else { dieyoung('Error: configuration file «'.CONFFN.'» does not define «webservertimeout».'); } } unset($fconf); } else { dieyoung('Error: configuration file «'.CONFFN.'» was not found.'); } $debug.='CONF: '.preprint($conf)."
\n"; $coopts=[ 'expires'=>$now+365*24*60*60, 'path'=>preg_replace('#[^/]+$#','',$_SERVER['REQUEST_URI']), 'domain'=>$_SERVER['SERVER_NAME'], 'secure'=>false, 'httponly'=>false, 'samesite'=>'Lax'// None || Lax || Strict ]; $cooptsx=$coopts; $cooptsx['expires']=$now-3600; /*setcookie('verbose_client_id','',$cooptsx); setcookie('verbose_client_secret','',$cooptsx); setcookie('verbose_host','',$cooptsx); setcookie('verbose_token','',$cooptsx);*/ $debug.='COOKIES: '.preprint($_COOKIE); $debug.='POST: '.preprint($_POST); $blang=getfirstbrowserlang(); $blang=preg_replace('#^([a-z]+).*#','$1',$blang); $host=false; $token=false; (isset($_SERVER['HTTPS'])) ? $proto='https' : $proto='http'; $rediruri=$proto.'://'.$_SERVER['HTTP_HOST'].preg_replace('#^([^?]*).*#','$1',$_SERVER['REQUEST_URI']); $authmsgs=''; $scope='read write:statuses'; $provided='you provided'; setcookie('verbose_client_id','',$cooptsx); setcookie('verbose_client_secret','',$cooptsx); (isset($_POST['host'])) ? $_POST['host']=trim($_POST['host']) : $_POST['host']=''; (isset($_POST['token'])) ? $_POST['token']=trim($_POST['token']) : $_POST['token']=''; if (isset($_GET['code']) && isset($_COOKIE['verbose_host']) && isset($_COOKIE['verbose_client_id']) && isset($_COOKIE['verbose_client_secret'])) { $host=$_COOKIE['verbose_host']; $postcont=['grant_type'=>'authorization_code', 'code'=>$_GET['code'], 'client_id'=>$_COOKIE['verbose_client_id'], 'client_secret'=>$_COOKIE['verbose_client_secret'], 'redirect_uri'=>$rediruri, 'scope'=>$scope]; $res=mastpost($host,null,'/oauth/token',$postcont,$timeout); if ($res['ok']) { $res=$res['data']; $token=$res['access_token']; setcookie('verbose_token',$token,$coopts); $authmsgs.="
You successfully authorized {$sname} to use your account on {$host}.
\nYour access token is {$token}
\nPlease save it somewhere safe, like in a password manager (i suggest KeePassXC), because {$sname} does not save it on the server, but only in a cookie in your browser that lasts one year since your last visit, so it may expire or you may loose it and, without your access token, you would have to repeat the authorization process.
\n"; } else { $authmsgs.='
Sorry, there was an error trying to authorize you: '.htmlentities($res['error'])."
\n"; } } elseif (isset($_POST['act']) && $_POST['act']=='login' && $_POST['host']!='' && $_POST['token']=='') { $host=$_POST['host']; $postcont=['client_name'=>'Verbose','redirect_uris'=>$rediruri,'scopes'=>$scope,'website'=>'https://git.lattuga.net/pongrebio/verbose']; $res=mastpost($host,$token,'/api/v1/apps',$postcont,$timeout); //$debug.='AUTH RESULTS: '.preprint($res); if ($res['ok']) { $res=$res['data']; setcookie('verbose_host',$host,$coopts); setcookie('verbose_client_id',$res['client_id'],$coopts); setcookie('verbose_client_secret',$res['client_secret'],$coopts); $location='https://'.$host.'/oauth/authorize?client_id=' . $res['client_id'] . '&redirect_uri=' . urlencode($rediruri) . '&response_type=code&scope='. urlencode($postcont['scopes']) . '&force_login=0&lang='.$blang; if ($debug) header('Location: '.$location,true,302); else echo "".htmlentities($location)."
\n"; exit(0); } else { $authmsgs.='
Sorry, there was an error trying to authorize you: '.htmlentities($res['error'])."
\n"; } } elseif (isset($_POST['act']) && $_POST['act']=='login' && $_POST['host']!='' && $_POST['token']!='') { $host=$_POST['host']; $token=$_POST['token']; } elseif (isset($_POST['act']) && $_POST['act']=='logout') { setcookie('verbose_host','',$cooptsx); setcookie('verbose_token','',$cooptsx); $_COOKIE=[]; //$authmsgs.="
You have been successfully logged out :-)
\n"; } elseif (isset($_COOKIE['verbose_host']) && isset($_COOKIE['verbose_token'])) { $host=$_COOKIE['verbose_host']; $token=$_COOKIE['verbose_token']; $provided='provided by your cookies'; } (isset($_POST['round'])) ? $_POST['round']++ : $_POST['round']=0; $loggedin=false; if ($host!==false && $token!==false && trim($token)!='') {// trim($token)!='' is to keep it usable without js $res=mastget($host,$token,'/api/v1/apps/verify_credentials',$timeout); //$debug.='TOKEN: '.$token."
\nRES:".preprint($res); if ($res['ok']) { $myacc=mastget($host,$token,'/api/v1/accounts/verify_credentials',$timeout); //$debug.=preprint($myacc); if ($myacc['ok']) { setcookie('verbose_host',$host,$coopts); setcookie('verbose_token',$token,$coopts); $myacc=$myacc['data']; $loggedin=true; if ($_POST['round']==0 || $_POST['act']=='login') { $res=mastget($host,$token,'/api/v1/instance',$timeout); if ($res['ok'] && isset($res['data']['configuration']['statuses']['max_characters']) && preg_match('#^\d+$#',$res['data']['configuration']['statuses']['max_characters'])===1) { $avchars=$res['data']['configuration']['statuses']['max_characters']+0; } else { $authmsgs.="
Sorry, {$sname} could not detect how many characters per post your instance allows.
\n"; } } } else { $authmsgs.='
Sorry, verification of your account’s credentials failed (error: '.htmlentities($myacc['error']).")
\n"; setcookie('verbose_host','',$cooptsx); setcookie('verbose_token','',$cooptsx); } } else { $authmsgs.="
Sorry, authentication with the credentials {$provided} failed (error: ".htmlentities($res['error']).")
\n"; setcookie('verbose_host','',$cooptsx); setcookie('verbose_token','',$cooptsx); } } $splitmsgs=''; if (isset($avchars)) { $_POST['avchars']=$avchars; } elseif (isset($_POST['avchars'])) { //if (!$loggedin) $authmsgs='
Warning: if you authorize now you’ll loose your current split session
'; (preg_match('#^\d+$#',$_POST['avchars'])===1) ? $_POST['avchars']+=0 : $_POST['avchars']=DEFAC; } else { $_POST['avchars']=DEFAC; } if ($_POST['avchars']MAXAC) $_POST['avchars']=MAXAC; $maxcwprec=$_POST['avchars']-MINCL; if (!isset($_POST['cw']) || trim($_POST['cw'])=='') $_POST['cw']=''; $cwlen=mb_strlen($_POST['cw'],'UTF-8'); if (!isset($_POST['pre']) || trim($_POST['pre'])=='') $_POST['pre']=''; $prelen=mb_strlen($_POST['pre'],'UTF-8')+2; $cwprelen=$cwlen+$prelen; if ($cwprelen>$maxcwprec) $splitmsgs.="
“Content Warning” + “Text to prepend” is {$cwprelen} characters long, that is ".($cwprelen-$maxcwprec)." characters longer than its maximum allowed length ({$maxcwprec} characters, that is {$_POST['avchars']} available characters minus ".MINCL." characters)
\n"; //$_POST['pre']=mb_substr($_POST['pre'],0,$maxprec,'UTF-8'); if (!isset($_POST['post']) || trim($_POST['post'])=='') $_POST['post']=''; $postlen=mb_strlen($_POST['post'],'UTF-8'); if ($postlen>MAXPOSTC) $splitmsgs.="
“Post to split” is {$postlen} characters long, that is ".($postlen-MAXPOSTC)." characters longer than its maximum allowed length, ".MAXPOSTC." characters
\n"; //$_POST['post']=mb_substr($_POST['post'],0,MAXPOSTC,'UTF-8'); $rbsck=[ 'cntpos_before'=>'', 'cntpos_after'=>'', 'addref_no'=>'', 'addref_ifav'=>'', ]; if (isset($_POST['cntpos']) && $_POST['cntpos']=='before') { $cntbef=true; $rbsck['cntpos_before']=' checked'; } else { $_POST['cntpos']='after'; $cntbef=false; $rbsck['cntpos_after']=' checked'; } if (isset($_POST['addref']) && $_POST['addref']=='no') { $aliif=false;// "add link if it fits" $rbsck['addref_no']=' checked'; } else { $_POST['addref']='ifav'; $aliif=true; $rbsck['addref_ifav']=' checked'; } if (!isset($_POST['replyto']) || trim($_POST['replyto'])=='') $_POST['replyto']=''; if (strlen($_POST['replyto'])>MAXREPTOLEN) { $_POST['replyto']=''; $splitmsgs.='
The “URL of post to reply to” you specified is too long (its maximum allowed length is '.MAXREPTOLEN." characters)
\n"; } if (!isset($_POST['lang']) || trim($_POST['lang'])=='') $_POST['lang']=$blang; if (!isset($_POST['visib']) || trim($_POST['visib'])=='') $_POST['visib']='public'; if ($_POST['round']==0) { $_POST['setcws']='1'; $setcwsck=' checked'; $_POST['setments']='1'; $setmentsck=' checked'; $_POST['setvisib']='1'; $setvisibck=' checked'; $_POST['setlang']='1'; $setlangck=' checked'; } else { (isset($_POST['setcws']) && $_POST['setcws']=='1') ? $setcwsck=' checked' : $setcwsck=''; (isset($_POST['setments']) && $_POST['setments']=='1') ? $setmentsck=' checked' : $setmentsck=''; (isset($_POST['setvisib']) && $_POST['setvisib']=='1') ? $setvisibck=' checked' : $setvisibck=''; (isset($_POST['setlang']) && $_POST['setlang']=='1') ? $setlangck=' checked' : $setlangck=''; } function getpostmentions($post,$exclude,$format) { $ments=[]; if (isset($post['account']['acct']) && !in_array($post['account']['acct'],$exclude)) $ments[]=$post['account']['acct']; if (isset($post['mentions']) && is_array($post['mentions'])) foreach ($post['mentions'] as $ment) if (isset($ment['acct']) && !in_array($ment['acct'],$exclude) && !in_array($ment['acct'],$ments)) $ments[]=$ment['acct']; if ($format=='array') return $ments; elseif ($format=='list') return implode(' ',$ments); elseif ($format=='recipients') return '@'.implode(' @',$ments); } $reptoid=''; if ($loggedin && $_POST['replyto']!='') { //https://livellosegreto.it/@geranio/110627337076323759 $res=mastget($host,$token,'/api/v2/search?type=statuses&resolve=1&limit=1&q='.urlencode($_POST['replyto']),$timeout); $debug.='accsearch res:
'.preprint($res)."
\n"; if ($res['ok']) { if (isset($res['data']['statuses'][0]['id'])) $reptopost=$res['data']['statuses'][0]; else $splitmsgs.="
Sorry, {$sname} found no post with the URL you provided as “URL of post to reply to”, please check it and make sure it points to a post you have access to.
\n"; } else { $splitmsgs.="
Sorry, {$sname} encountered the following error while trying to retrieve the URL you provided as “URL of post to reply to”: ".htmlentities($res['error'])."; please check the URL and make sure it points to a post you have access to.
\n"; } if (isset($reptopost)) { if (isset($reptopost['id'])) $reptoid=$reptopost['id']; if (isset($_POST['setcws']) && $_POST['setcws']=='1' && isset($reptopost['spoiler_text']) && trim($reptopost['spoiler_text'])!='') $_POST['cw']=$reptopost['spoiler_text']; if (isset($_POST['setments']) && $_POST['setments']=='1' && isset($reptopost['mentions'])) $_POST['pre']=getpostmentions($reptopost,[$myacc['acct']],'recipients'); if (isset($_POST['setvisib']) && $_POST['setvisib']=='1' && isset($reptopost['visibility'])) $_POST['visib']=$reptopost['visibility']; if (isset($_POST['setlang']) && $_POST['setlang']=='1' && isset($reptopost['language'])) $_POST['lang']=$reptopost['language']; } } $headmsgs=''; $intro="

Hello, this is a {$sname} instance, it can split your long post considering Mastodon rules: every http(s) link counts for 23 characters and every mention counts only for its username part. Each split post comes with “…” signs where it makes sense and with a counter in “[n/t]” form, where “n” is current post number and “t” is total posts number.

{$sname} doesn’t save anywhere what you write or paste into it, it doesn’t use third parties’ cookies, it sets some cookies of its own only if you choose to connect it to your account, and it can be used even without Javascript.

If you find issues please report them to me on Mastodon, or here.

\n"; $postmsgs=''; $postsoffset=0; $postscount=0; $postingok=true; $postwait=0; $postwaituntil=0; $pbtext='Post all'; if (isset($_POST['postsoffset']) && preg_match('#^\d+$#',$_POST['postsoffset'])===1) $postsoffset=$_POST['postsoffset']+0; if ($loggedin && isset($_POST['postwaituntil']) && preg_match('#^\d+$#',$_POST['postwaituntil'])===1 && isset($_POST['postscount']) && preg_match('#^\d+$#',$_POST['postscount'])===1 && isset($_POST['act']) && $_POST['act']=='sendposts' && isset($_POST['cw']) && isset($_POST['post_'.$postsoffset]) && isset($_POST['mastlen_'.$postsoffset])) { $postscount=$_POST['postscount']+0; if (isset($_POST['lastsentpostid']) && $_POST['lastsentpostid']!='') $lspostid=$_POST['lastsentpostid']; $posts=[]; $i=$postsoffset; do { $_POST['post_'.$i]=str_replace("\r\n","\n",$_POST['post_'.$i]); $posts[$i]=['cw'=>$_POST['cw'],'post'=>$_POST['post_'.$i],'mastlen'=>$_POST['mastlen_'.$i]]; $i++; } while (isset($_POST['post_'.$i])); if ($now<$_POST['postwaituntil']) { $debug.="WAIT MORE!!!
\n"; $postingok=false; $postwait=$_POST['postwaituntil']-$now+1; $postwaituntil=$_POST['postwaituntil']+1; $postmsgs.="
Sorry, you have to wait ".ght($postwait)." more before {$sname} can post the remaining split post(s).
\n"; $pbtext='Please wait '.ght($postwait).' before posting'; } else { for ($i=$postsoffset; $i<$postscount; $i++) { if (time()-$now+1>=$conf['webservertimeout']) { $postingok=false; $postsoffset=$i; $postmsgs.="
{$sname} could not post all the split posts because «{$_SERVER['SERVER_NAME']}» HTTP server was reaching its timeout (".ght($conf['webservertimeout']).'). You can send the remaining split posts '.($i+1)."-{$postscount} below.
\n"; break; } else { $post=$posts[$i]; $cont=[ 'status'=>$post['post'], 'visibility'=>$_POST['visib'], 'language'=>$_POST['lang'] ]; if ($post['cw']!='') $cont['spoiler_text']=$post['cw']; if ($i==0 && $reptoid!='') $cont['in_reply_to_id']=$reptoid; elseif (isset($lspostid)) $cont['in_reply_to_id']=$lspostid; if ($i>0 && $_POST['visib']=='public') $cont['visibility']='unlisted'; //echo ($i+1).preprint($cont)."
\n"; $res=mastpost($host,$token,'/api/v1/statuses',$cont,$timeout); //if ($i==2) $res=['ok'=>false,'error'=>'server exploded'];// test err //$res=['ok'=>true,'data'=>['id'=>'12345']];// test err if ($res['ok']) { $lspostid=$res['data']['id']; $debug.="lspostid: {$lspostid}
\n"; $rls=ckratelimit($res['headers'],'necho',true,false); //if ($i==2) $rls=['remaining'=>0,'secstoreset'=>3895];// test err //$rls=['remaining'=>0,'secstoreset'=>5];// test err if (!is_null($rls)) { if ($rls['remaining']<=REQSTOPRESV && $i<$postscount-1) { $postingok=false; $postwait=$rls['secstoreset']; $postwaituntil=time()+$postwait; $postsoffset=$i+1; $postmsgs.='
Sending split post '.($i+1)."/{$postscount}, {$sname} reached your {$host}’s account posting rate limit, so it stopped sending; you’ll find the rest of your split posts (those which have not been sent, ".($i+2)."-{$postscount}) below; before posting them, you’ll have to wait ".ght($postwait)." for rate limit reset.
\n"; $pbtext='Please wait '.ght($postwait).' before posting'; break; } } if ($i<$postscount-1) usleep(POSTPAUSE*1000); } else { $postingok=false; $postsoffset=$i; $postmsgs.='
Trying to send split post '.($i+1)."/{$postscount}, {$sname} encountered the following error: «".htmlentities($res['error']).'»; so it stopped sending. You can (re)try sending split posts '.($i+1)."-{$postscount} below.
\n"; break; } } } if ($postingok) { $postmsgs.="
{$sname} successfully sent {$i}/{$postscount} split posts :-)
\n"; $posts=[]; $postscount=0; } } } $replyto=''; $language=''; $displang=''; $visibility=''; $dispvisib=''; if (!$loggedin) { $auth="

Connect?

{$authmsgs}

If you don’t want to connect {$sname} to your account, you can just skip to the “Split post” section, but after splitting your long post you’ll have to copy and paste by hand each split post in sequence into Mastodon (i recommend “chain posting”, that is replying to the first post with the second, to the second with the third, and so on).

If you choose instead to connect {$sname} to your account, you’ll be able to post all split posts at once directly from within {$sname}, they will be automatically “chain posted” and, before posting them, you may set their visibility, language, and a post to reply to with the first split post.

 

To connect {$sname} to your account

".oldpost2hid()."
\n"; $replyto=''; $visibility=''; $language=''; } else { $auth="

Connected :-)

\n{$authmsgs}\n
\n".oldpost2hid()."
{$sname} is connected to your {$myacc['acct']}@{$host} account.
\n
\n
\n"; $replyto='
'; $optsa=['public'=>'Public','unlisted'=>'Unlisted','private'=>'Followers-only','direct'=>'Direct']; $buff=''; foreach ($optsa as $key=>$val) { if ($key==$_POST['visib']) { $selected=' selected'; $dispvisib=$val; } else { $selected=''; } $buff.="\n"; } $visibility='
'; // taken from 'preferences' -> 'other' on mastodon 4.1.2 $optsa=[['aa','Afar','Afaraf'],['ab','Abkhaz','аҧсуа бызшәа'],['ae','Avestan','avesta'],['af','Afrikaans','Afrikaans'],['ak','Akan','Akan'],['am','Amharic','አማርኛ'],['an','Aragonese','aragonés'],['ar','Arabic','اللغة العربية'],['as','Assamese','অসমীয়া'],['av','Avaric','авар мацӀ'],['ay','Aymara','aymar aru'],['az','Azerbaijani','azərbaycan dili'],['ba','Bashkir','башҡорт теле'],['be','Belarusian','беларуская мова'],['bg','Bulgarian','български език'],['bh','Bihari','भोजपुरी'],['bi','Bislama','Bislama'],['bm','Bambara','bamanankan'],['bn','Bengali','বাংলা'],['bo','Tibetan','བོད་ཡིག'],['br','Breton','brezhoneg'],['bs','Bosnian','bosanski jezik'],['ca','Catalan','Català'],['ce','Chechen','нохчийн мотт'],['ch','Chamorro','Chamoru'],['co','Corsican','corsu'],['cr','Cree','ᓀᐦᐃᔭᐍᐏᐣ'],['cs','Czech','čeština'],['cu','Old Church Slavonic','ѩзыкъ словѣньскъ'],['cv','Chuvash','чӑваш чӗлхи'],['cy','Welsh','Cymraeg'],['da','Danish','dansk'],['de','German','Deutsch'],['dv','Divehi','Dhivehi'],['dz','Dzongkha','རྫོང་ཁ'],['ee','Ewe','Eʋegbe'],['el','Greek','Ελληνικά'],['en','English','English'],['eo','Esperanto','Esperanto'],['es','Spanish','Español'],['et','Estonian','eesti'],['eu','Basque','euskara'],['fa','Persian','فارسی'],['ff','Fula','Fulfulde'],['fi','Finnish','suomi'],['fj','Fijian','Vakaviti'],['fo','Faroese','føroyskt'],['fr','French','Français'],['fy','Western Frisian','Frysk'],['ga','Irish','Gaeilge'],['gd','Scottish Gaelic','Gàidhlig'],['gl','Galician','galego'],['gu','Gujarati','ગુજરાતી'],['gv','Manx','Gaelg'],['ha','Hausa','هَوُسَ'],['he','Hebrew','עברית'],['hi','Hindi','हिन्दी'],['ho','Hiri Motu','Hiri Motu'],['hr','Croatian','Hrvatski'],['ht','Haitian','Kreyòl ayisyen'],['hu','Hungarian','magyar'],['hy','Armenian','Հայերեն'],['hz','Herero','Otjiherero'],['ia','Interlingua','Interlingua'],['id','Indonesian','Bahasa Indonesia'],['ie','Interlingue','Interlingue'],['ig','Igbo','Asụsụ Igbo'],['ii','Nuosu','ꆈꌠ꒿ Nuosuhxop'],['ik','Inupiaq','Iñupiaq'],['io','Ido','Ido'],['is','Icelandic','Íslenska'],['it','Italian','Italiano'],['iu','Inuktitut','ᐃᓄᒃᑎᑐᑦ'],['ja','Japanese','日本語'],['jv','Javanese','basa Jawa'],['ka','Georgian','ქართული'],['kg','Kongo','Kikongo'],['ki','Kikuyu','Gĩkũyũ'],['kj','Kwanyama','Kuanyama'],['kk','Kazakh','қазақ тілі'],['kl','Kalaallisut','kalaallisut'],['km','Khmer','ខេមរភាសា'],['kn','Kannada','ಕನ್ನಡ'],['ko','Korean','한국어'],['kr','Kanuri','Kanuri'],['ks','Kashmiri','कश्मीरी'],['ku','Kurmanji (Kurdish)','Kurmancî'],['kv','Komi','коми кыв'],['kw','Cornish','Kernewek'],['ky','Kyrgyz','Кыргызча'],['la','Latin','latine'],['lb','Luxembourgish','Lëtzebuergesch'],['lg','Ganda','Luganda'],['li','Limburgish','Limburgs'],['ln','Lingala','Lingála'],['lo','Lao','ລາວ'],['lt','Lithuanian','lietuvių kalba'],['lu','Luba-Katanga','Tshiluba'],['lv','Latvian','latviešu valoda'],['mg','Malagasy','fiteny malagasy'],['mh','Marshallese','Kajin M̧ajeļ'],['mi','Māori','te reo Māori'],['mk','Macedonian','македонски јазик'],['ml','Malayalam','മലയാളം'],['mn','Mongolian','Монгол хэл'],['mr','Marathi','मराठी'],['ms','Malay','Bahasa Melayu'],['mt','Maltese','Malti'],['my','Burmese','ဗမာစာ'],['na','Nauru','Ekakairũ Naoero'],['nb','Norwegian Bokmål','Norsk bokmål'],['nd','Northern Ndebele','isiNdebele'],['ne','Nepali','नेपाली'],['ng','Ndonga','Owambo'],['nl','Dutch','Nederlands'],['nn','Norwegian Nynorsk','Norsk Nynorsk'],['no','Norwegian','Norsk'],['nr','Southern Ndebele','isiNdebele'],['nv','Navajo','Diné bizaad'],['ny','Chichewa','chiCheŵa'],['oc','Occitan','occitan'],['oj','Ojibwe','ᐊᓂᔑᓈᐯᒧᐎᓐ'],['om','Oromo','Afaan Oromoo'],['or','Oriya','ଓଡ଼ିଆ'],['os','Ossetian','ирон æвзаг'],['pa','Panjabi','ਪੰਜਾਬੀ'],['pi','Pāli','पाऴि'],['pl','Polish','Polski'],['ps','Pashto','پښتو'],['pt','Portuguese','Português'],['qu','Quechua','Runa Simi'],['rm','Romansh','rumantsch grischun'],['rn','Kirundi','Ikirundi'],['ro','Romanian','Română'],['ru','Russian','Русский'],['rw','Kinyarwanda','Ikinyarwanda'],['sa','Sanskrit','संस्कृतम्'],['sc','Sardinian','sardu'],['sd','Sindhi','सिन्धी'],['se','Northern Sami','Davvisámegiella'],['sg','Sango','yângâ tî sängö'],['si','Sinhala','සිංහල'],['sk','Slovak','slovenčina'],['sl','Slovenian','slovenščina'],['sn','Shona','chiShona'],['so','Somali','Soomaaliga'],['sq','Albanian','Shqip'],['sr','Serbian','српски језик'],['ss','Swati','SiSwati'],['st','Southern Sotho','Sesotho'],['su','Sundanese','Basa Sunda'],['sv','Swedish','Svenska'],['sw','Swahili','Kiswahili'],['ta','Tamil','தமிழ்'],['te','Telugu','తెలుగు'],['tg','Tajik','тоҷикӣ'],['th','Thai','ไทย'],['ti','Tigrinya','ትግርኛ'],['tk','Turkmen','Türkmen'],['tl','Tagalog','Wikang Tagalog'],['tn','Tswana','Setswana'],['to','Tonga','faka Tonga'],['tr','Turkish','Türkçe'],['ts','Tsonga','Xitsonga'],['tt','Tatar','татар теле'],['tw','Twi','Twi'],['ty','Tahitian','Reo Tahiti'],['ug','Uyghur','ئۇيغۇرچە‎'],['uk','Ukrainian','Українська'],['ur','Urdu','اردو'],['uz','Uzbek','Ўзбек'],['ve','Venda','Tshivenḓa'],['vi','Vietnamese','Tiếng Việt'],['vo','Volapük','Volapük'],['wa','Walloon','walon'],['wo','Wolof','Wollof'],['xh','Xhosa','isiXhosa'],['yi','Yiddish','ייִדיש'],['yo','Yoruba','Yorùbá'],['za','Zhuang','Saɯ cueŋƅ'],['zh','Chinese','中文'],['zu','Zulu','isiZulu'],['ast','Asturian','Asturianu'],['ckb','Sorani (Kurdish)','سۆرانی'],['cnr','Montenegrin','crnogorski'],['jbo','Lojban','la .lojban.'],['kab','Kabyle','Taqbaylit'],['kmr','Kurmanji (Kurdish)','Kurmancî'],['ldn','Láadan','Láadan'],['lfn','Lingua Franca Nova','lingua franca nova'],['sco','Scots','Scots'],['sma','Southern Sami','Åarjelsaemien Gïele'],['smj','Lule Sami','Julevsámegiella'],['szl','Silesian','ślůnsko godka'],['tai','Tai','ภาษาไท or ภาษาไต'],['tok','Toki Pona','toki pona'],['zba','Balaibalan','باليبلن'],['zgh','Standard Moroccan Tamazight','ⵜⴰⵎⴰⵣⵉⵖⵜ']]; $buff=''; foreach ($optsa as $val) { if ($val[0]==$_POST['lang']) { $displang=$val[2].' ('.$val[1].')'; $selected=' selected'; } else { $selected=''; } $buff.="\n"; } $language="
\n"; unset($buff,$optsa); } $auth.="
\n"; if ($dodebug) { $debug='
'.$debug.'
'; $svers.='-'.rand(10000,999999); } else { $debug=''; } (isset($_POST['act']) && $_POST['act']=='split') ? $splitfh='' : $splitfh=' class="fullheight"'; header('Content-Language: en'); echo " {$sname}: a post splitter for Mastodon
Elo!
Uz!
Elo!
{$debug}
{$headmsgs}

{$sname}: a post splitter for Mastodon

{$intro}
{$auth}

Split post

{$splitmsgs}
{$replyto}
{$visibility} {$language}
\n
\n
\n"; if ($splitmsgs=='') { if (isset($_POST['act']) && $_POST['act']=='split' && $_POST['post']!='') { $linklen=postlength($conf['link']); ($_POST['pre']!='') ? $pre=$_POST['pre']."\n\n" : $pre=''; $posts=splitpost($_POST['post'],$_POST['avchars'],$_POST['cw'],$pre,$cntbef); $postscount=count($posts); $errposts=[]; for ($i=0; $i<$postscount; $i++) if ($posts[$i]['mastlen']>$_POST['avchars']) $errposts[]="{$i}"; $epc=count($errposts); if ($epc>0) { if ($epc==1) echo "

Sorry, the length of one split post (namely {$errposts[0]}) exceeds {$_POST['avchars']} characters."; else echo "

Sorry, the length of {$epc} split posts (namely ".implode(', ',$errposts).") exceeds {$_POST['avchars']} characters."; echo " Please report this bug here, possibly citing the original post text.

\n"; } if ($postscount>1 && $aliif && $posts[$postscount-1]['mastlen']+$linklen<=$_POST['avchars']) { $posts[$postscount-1]['post'].=$conf['link']; $posts[$postscount-1]['mastlen']+=$linklen; } } if ($postscount>0) { //if ($loggedin) $postmsgs.="
“Post all” button is at the bottom ;-)
\n"; echo "
\n

Split results

\n{$postmsgs}
\n"; $info='Content Warning: '; ($posts[$postsoffset]['cw']!='') ? $info.=htmlentities($_POST['cw']) : $info.='not set'; if ($loggedin) $info.='
Visibility: '.$dispvisib.'
Language: '.htmlentities($displang); ($loggedin) ? $postdivclass='postdivnobut' : $postdivclass='postdiv'; for ($i=$postsoffset; $i<$postscount; $i++) { $io=$i+1; ($posts[$i]['mastlen']>$_POST['avchars']) ? $phclass='errposthead' : $phclass='posthead'; echo "
Post {$io}/{$postscount} (“Mastodon length”: {$posts[$i]['mastlen']}; real length: ".(mb_strlen($posts[$i]['post'],'UTF-8')+$cwlen).")
\n
{$info}
\n
".nl2br(htmlentities($posts[$i]['post']))."
\n
\n
\n"; } if ($loggedin) { if (!isset($lspostid)) $lspostid=''; echo "
\n
\n
\n
\n
\n
\n".oldpost2hid()."\n\n\n\n\n"; } echo "
\n"; } elseif ($postmsgs!='') { echo "
\n{$postmsgs}"; } } if (isset($conf['footer'])) echo "
{$conf['footer']}
\n"; echo "
".SNAME." ".SVERS."
\n"; function preprint($var) { return '
'.print_r($var,true)."
\n"; } function necho($var) { // do nothing :-) } function dieyoung($msg) { echo $msg; exit(1); } function cb2hid($pkey) { if (isset($_POST[$pkey]) && $_POST[$pkey]=='1') return '1'; else return '0'; } function oldpost2hid() { return "\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; } ?>