$errors='<div class="warning">There are some errors in the values you submitted<ul><li>'.implode('</li><li>',$errors).'</li></ul></div><div class="horsep"></div>';
<pclass=\"firstp\">Hello, this is a {$usname} instance. {$usname} is a tool to easily check if a Mastodon instance is censoring a given Mastodon post (currently, it works only with Mastodon posts, but i’ll try to make it work with other platforms’ posts too). This {$usname} instance is set to check «{$conf['host']}», {$conf['hostdesc']}. It works by querying {$conf['host']}’s <a href=\"https://docs.joinmastodon.org/methods/search/#v2\">/api/v2/search</a> API endpoint with the credentials of an application defined inside a {$conf['host']} account, but to avoid false positives it does so only after it has verified that the URL you passed to it actually points to a publicly accessible ActivityPub object.</p>
echo"<div class=\"error\">Error: {$usname} could not connect to «{$purlhn}» and won’t proceed with the check.</div>\n";
}elseif($hcode[0]!='2'){
if($hcode[0]=='5')
echo"<div class=\"error\">«{$purlhn}» returned a server error. {$usname} won’t proceed with the check.</div>\n";
elseif($hcode[0]=='4')
echo"<div class=\"error\">Error: {$usname} could not access the “Post URL” you passed to it: probably the post visibility is not public/unlisted, or you passed a wrong URL. {$usname} won’t proceed with the check.</div>\n";
elseif($hcode[0]=='3')
echo"<div class=\"error\">Error: the “Post URL” you passed to {$usname} redirects, and since its programmer is lazy, {$usname} currently only accepts URLs which point to original posts (on Mastodon web you can copy a post’s original URL by opening the “three vertical dots” menu you find on every post and selecting “Copy link to post”). {$usname} won’t proceed with the check.</div>\n";
elseif($hcode[0]=='1')
echo"<div class=\"error\">«{$purlhn}» returned an unexpected and useless informational message. {$usname} won’t proceed with the check.</div>\n";
else
echo"<div class=\"error\">«{$purlhn}» returned an unexpected HTTP code. {$usname} won’t proceed with the check.</div>\n";
}elseif(null===$res=@json_decode($res,true)){
echo"<div class=\"error\">Error: «{$purlhn}» returned data which could not be parsed as JSON (".json_last_error().': '.json_last_error_msg().").</div>\n";
}elseif(isset($res['error'])){
echo"<div class=\"error\">Error: «{$purlhn}» returned «".htmlentities($res['error'])."». {$usname} won’t proceed with the check.</div>\n";
echo"<div class=\"error\">Error: the “Post URL” you passed to {$usname} doesn’t point to an ActivityPub post. {$usname} won’t proceed with the check.</div>\n";
echo"<div class=\"warning\">Warning: could not write to rate limit state file.</div>\n";
/*if($rl['remaining']==0)
break;
usleep(250000);
}*/
if($res===false){
echo"<div class=\"error\">Error: could not connect to «{$hhost}».</div>\n";
}elseif(null===$res=@json_decode($res,true)){
echo"<div class=\"error\">Error: «{$hurl}» returned data which could not be parsed as JSON (".json_last_error().': '.json_last_error_msg().").</div>\n";
}elseif(isset($res['error'])){
echo"<div class=\"error\">Error: «{$hurl}» replied with this error message: «".htmlentities($res['error'])."».</div>\n";
}elseif(!isset($res['statuses'])){
echo"<div class=\"error\">Error: «{$hurl}» returned data in an unexpected format.</div>\n";
}else{
if(isset($res['statuses'][0]['id']))
echo"<div class=\"neutral\">\nPost is not censored.\n</div>\n";
else
echo"<div class=\"neutral\">\nPost is censored.\n</div>\n";