Now, when “Include only if Threads is surely suspended” is active, it returns also instances listed into Anti-Meta Fedi Pact page; also, made the “Meta’s Threads moderation” text more detailed

This commit is contained in:
pezcurrel 2023-12-27 19:19:18 +01:00
parent 605dd9f06f
commit 641eb734fc

View file

@ -21,7 +21,7 @@ date_default_timezone_set($dtzbl[$dlang]);*/
$debug=''; $debug='';
debug('REQUEST_URI: '.$_SERVER['REQUEST_URI'].N,$debug); debug('REQUEST_URI: '.$_SERVER['REQUEST_URI'].N,$debug);
debug('$_GET: '.print_r($_GET,1),$debug); debug('$_GET: '.print_r($_GET,true),$debug);
debug('LOCALE: '.$locale.N,$debug); debug('LOCALE: '.$locale.N,$debug);
// an instance is displayed as "New" if its age, relative to the InsertTS field, is less or equal than this (currently 30 days) // an instance is displayed as "New" if its age, relative to the InsertTS field, is less or equal than this (currently 30 days)
@ -68,6 +68,7 @@ echo('</nav>
<section class="sectcontm">'.N); <section class="sectcontm">'.N);
if ($single) { if ($single) {
setfedipact();
echo('<p><a href="'.$conf['instpath'].'/instances/'.$dlang.'">↑ '._('Go to search').'</a></p>'.N); echo('<p><a href="'.$conf['instpath'].'/instances/'.$dlang.'">↑ '._('Go to search').'</a></p>'.N);
$p=1; $p=1;
$que='SELECT * FROM Instances WHERE ID='.$_GET['id']; $que='SELECT * FROM Instances WHERE ID='.$_GET['id'];
@ -171,18 +172,7 @@ function presub() {
</script> </script>
'.N); '.N);
$fedipactfp='../clitools/fedipact.list'; setfedipact();
$buf=@file($fedipactfp,FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
if (!is_array($buf)) {
debug('WARNING: could not open «'.$fedipactfp.'».'.N,$debug);
$buf=[];
}
$cfedipact=count($buf);
$fedipact['uris']=$buf;
foreach ($buf as $val)
$fedipact['uris_me'][]=myesc($link,$val);
$fedipact['uris_me']='"'.implode('", "',$fedipact['uris_me']).'"';
//echo '<pre>'.print_r($fedipact,true).'</pre>'.N;
$que='SELECT COUNT(ID) AS Unknown, SUM(UserCount) AS UnknownU FROM Instances WHERE IsMastodon=1 AND LastOkCheckTS>='.$graceline.' AND Threads IS NULL'; $que='SELECT COUNT(ID) AS Unknown, SUM(UserCount) AS UnknownU FROM Instances WHERE IsMastodon=1 AND LastOkCheckTS>='.$graceline.' AND Threads IS NULL';
if ($cfedipact>0) if ($cfedipact>0)
@ -565,7 +555,12 @@ function presub() {
$joins[]='LEFT JOIN InstChecks AS InstChecks ON InstChecks.InstID=Instances.ID AND InstChecks.Time=(SELECT MAX(InstChecks.Time) AS MaxTime FROM InstChecks WHERE InstChecks.InstID=Instances.ID)'; $joins[]='LEFT JOIN InstChecks AS InstChecks ON InstChecks.InstID=Instances.ID AND InstChecks.Time=(SELECT MAX(InstChecks.Time) AS MaxTime FROM InstChecks WHERE InstChecks.InstID=Instances.ID)';
$wheres[]='InstChecks.Status=1'; $wheres[]='InstChecks.Status=1';
}*/ }*/
if ($_GET['inths']==1) $wheres[]='Instances.Threads="suspended"'; if ($_GET['inths']==1) {
if ($cfedipact>0)
$wheres[]='Instances.Threads="suspended" OR Instances.ID IN ('.implode(', ',$fedipact['instids']).')';
else
$wheres[]='Instances.Threads="suspended"';
}
if ($_GET['lang']>0) { if ($_GET['lang']>0) {
$joins[]='LEFT JOIN InstOurLangs ON InstOurLangs.InstID=Instances.ID'; $joins[]='LEFT JOIN InstOurLangs ON InstOurLangs.InstID=Instances.ID';
$wheres[]='(InstOurLangs.OurLangID='.$_GET['lang'].' AND InstOurLangs.Pos=1)'; $wheres[]='(InstOurLangs.OurLangID='.$_GET['lang'].' AND InstOurLangs.Pos=1)';
@ -607,7 +602,7 @@ $wrfsstxt=datefmt_format($dfmt,$wrfss).' UTC';
mysqli_data_seek($res,$if); mysqli_data_seek($res,$if);
while ($if<$il && $row=mysqli_fetch_assoc($res)) { while ($if<$il && $row=mysqli_fetch_assoc($res)) {
$if++; $if++;
$out='<div class="ihead"><a href="https://'.hspech($row['URI']).'" title="'._('Go to instance').'">'.hspech($row['URI']).'</a>'; $out='<div class="ihead"><a href="https://'.hspech($row['URI']).'" target="_blank" title="'._('Go to instance').'">'.hspech($row['URI']).'</a>';
if (!$single) $out.=' <a href="'.$conf['instpath'].'/instances?id='.$row['ID'].'" title="'._('Direct link to this instances card').'">('.$if.'/'.$itot.')</a>'; if (!$single) $out.=' <a href="'.$conf['instpath'].'/instances?id='.$row['ID'].'" title="'._('Direct link to this instances card').'">('.$if.'/'.$itot.')</a>';
$out.='</div>'.N; $out.='</div>'.N;
($if<$il) ? $out.='<div class="ibody">'.N : $out.='<div class="ibodylast">'.N; ($if<$il) ? $out.='<div class="ibody">'.N : $out.='<div class="ibodylast">'.N;
@ -616,13 +611,13 @@ while ($if<$il && $row=mysqli_fetch_assoc($res)) {
while ($rrow=mysqli_fetch_assoc($rres)) while ($rrow=mysqli_fetch_assoc($rres))
$buf[]=hspech($rrow['Lang']); $buf[]=hspech($rrow['Lang']);
($row['Thumb']=='unavailable') ? $thumb=$prepath.'imgs/InstThumbUnavailable.svg' : $thumb=$row['Thumb']; ($row['Thumb']=='unavailable') ? $thumb=$prepath.'imgs/InstThumbUnavailable.svg' : $thumb=$row['Thumb'];
$out.='<div class="iimgc"><a href="https://'.hspech($row['URI']).'" title="'._('Go to instance').'"><img class="iimg" src="'.$thumb.'"></a>'; $out.='<div class="iimgc"><a href="https://'.hspech($row['URI']).'" target="_blank" title="'._('Go to instance').'"><img class="iimg" src="'.$thumb.'"></a>';
// if (!is_null($row['Priority'])) $out.='<img src="'.$prepath.'imgs/featured-it.svg" class="ifeat">'; // if (!is_null($row['Priority'])) $out.='<img src="'.$prepath.'imgs/featured-it.svg" class="ifeat">';
if (!is_null($row['Priority'])) $out.='<div class="dfeat">'._('Recommended').'</div>'; if (!is_null($row['Priority'])) $out.='<div class="dfeat">'._('Recommended').'</div>';
if ($row['Thumb']=='unavailable' && $row['WasLastCheckOk']==1) $out.='<div class="unavmsg">'._('It seems like this instances server thumbnails URL points to a non existent file. This is usually easily fixable by the instances admin(s) by uploading again the image to their server. Note that the change wont be displayed here before the nightly automatic update of this instances infos occurs.').'</div>'; if ($row['Thumb']=='unavailable' && $row['WasLastCheckOk']==1) $out.='<div class="unavmsg">'._('It seems like this instances server thumbnails URL points to a non existent file. This is usually easily fixable by the instances admin(s) by uploading again the image to their server. Note that the change wont be displayed here before the nightly automatic update of this instances infos occurs.').'</div>';
$out.='</div>'.N; $out.='</div>'.N;
$out.='<div class="icol">'.N; $out.='<div class="icol">'.N;
$out.='<div><span class="ilab">'._('Name').'</span> <a href="https://'.hspech($row['URI']).'" title="'._('Go to instance').'">'.nully(hspech($row['Title'])).'</a></div>'.N; $out.='<div><span class="ilab">'._('Name').'</span> <a href="https://'.hspech($row['URI']).'" target="_blank" title="'._('Go to instance').'">'.nully(hspech($row['Title'])).'</a></div>'.N;
/*$out.='<div><span class="ilab">'._('Consigliata').'</span> '; /*$out.='<div><span class="ilab">'._('Consigliata').'</span> ';
(!is_null($row['Priority'])) ? $out.='<span class="ivgood">'._('Si!').'</span>' : $out.=_('No'); (!is_null($row['Priority'])) ? $out.='<span class="ivgood">'._('Si!').'</span>' : $out.=_('No');
$out.='</div>'.N;*/ $out.='</div>'.N;*/
@ -679,16 +674,29 @@ while ($if<$il && $row=mysqli_fetch_assoc($res)) {
$out.='</div>'.N; $out.='</div>'.N;
$out.='<div><span class="ilab">'._('Metas Threads moderation').'</span> '; $out.='<div><span class="ilab">'._('Metas Threads moderation').'</span> ';
if (in_array($row['ID'],$fedipact['instids'])) {
$out.=_('Threads is <i>suspended</i>').', '._('according to the <a href="https://fedipact.online/" target="_blank">Anti-Meta Fedi Pact</a> list');
if (is_null($row['Threads'])) if (is_null($row['Threads']))
$out.=_('Unknown (the list of moderated instances is not accessible)'); $out.=', '._('but its currently impossible to verify it because this instances list of moderated instances is not accessible').'.';
elseif ($row['Threads']=='accessible') elseif ($row['Threads']=='accessible')
$out.=_('Threads is neither suspended nor limited'); $out.=', '._('but it appears to be <i>accessible</i>, instead').', '._('according to this instances list of moderated instances').'.';
elseif ($row['Threads']=='suspended') elseif ($row['Threads']=='suspended')
$out.=_('Threads is suspended'); $out.=', '._('and also').' '._('according to this instances list of moderated instances').'.';
elseif ($row['Threads']=='limited') elseif ($row['Threads']=='limited')
$out.=_('Threads is limited'); $out.=', '._('but it appears to be only <i>limited</i>, instead').', '._('according to this instances list of moderated instances').'.';
else else
$out.=_('Unknown value').': «'.htmlentities($row['Threads']).'»; '._('please contact masthelp[at]insicuri.net'); $out.='.';
} elseif (is_null($row['Threads'])) {
$out.=_('<i>Unknown</i> (this instance is not listed in the <a href="https://fedipact.online/" target="_blank">Anti-Meta Fedi Pact</a> list), and its list of moderated instances is not accessible').'.';
} elseif ($row['Threads']=='accessible') {
$out.=_('Threads is neither <i>suspended</i> nor <i>limited<i>').', '._('according to this instances list of moderated instances').'.';
} elseif ($row['Threads']=='suspended') {
$out.=_('Threads is <i>suspended</i>').', '._('according to this instances list of moderated instances').'.';
} elseif ($row['Threads']=='limited') {
$out.=_('Threads is <i>limited</i>').', '._('according to this instances list of moderated instances').'.';
} else {
$out.=_('<i>Unknown value</i>').': «'.htmlentities($row['Threads']).'»; '._('please contact masthelp[at]insicuri.net').'.';
}
$out.='</div>'.N; $out.='</div>'.N;
$out.='<div><span class="ilab">'._('Most used hashtags (last week)').'</span> '; $out.='<div><span class="ilab">'._('Most used hashtags (last week)').'</span> ';
@ -696,7 +704,7 @@ while ($if<$il && $row=mysqli_fetch_assoc($res)) {
if (mysqli_num_rows($rres)>0) { if (mysqli_num_rows($rres)>0) {
$buf=[]; $buf=[];
while ($rrow=mysqli_fetch_assoc($rres)) while ($rrow=mysqli_fetch_assoc($rres))
$buf[]='<a href="'.hspech($rrow['URL']).'">'.hspech($rrow['Name']).'</a>'; $buf[]='<a href="'.hspech($rrow['URL']).'" target="_blank">'.hspech($rrow['Name']).'</a>';
$out.=implode(', ',$buf); $out.=implode(', ',$buf);
} else { } else {
$out.='<span class="null">'._('Not available{plural}').'</span>'; $out.='<span class="null">'._('Not available{plural}').'</span>';
@ -741,7 +749,7 @@ while ($if<$il && $row=mysqli_fetch_assoc($res)) {
$admacc=nully(null); $admacc=nully(null);
$thumb=$prepath.'imgs/AdmAccThumbUnavailable.svg'; $thumb=$prepath.'imgs/AdmAccThumbUnavailable.svg';
if (!is_null($row['AdmAccount']) && $row['AdmAccount']!='OPTED OUT') { if (!is_null($row['AdmAccount']) && $row['AdmAccount']!='OPTED OUT') {
$admacc='<a href="https://'.hspech($row['URI']).'/@'.hspech($row['AdmAccount']).'">'.hspech($row['AdmAccount']).'@'.hspech($row['URI']).'</a>'; $admacc='<a href="https://' . hspech($row['URI']) . '/@' . hspech($row['AdmAccount']) . '" target="_blank">' . hspech($row['AdmAccount']) . '@' . hspech($row['URI']) . '</a>';
if ($row['AdmAvatar']!='unavailable') $thumb=$row['AdmAvatar']; if ($row['AdmAvatar']!='unavailable') $thumb=$row['AdmAvatar'];
} elseif ($row['AdmAccount']=='OPTED OUT') { } elseif ($row['AdmAccount']=='OPTED OUT') {
$admacc='<span class="null">'._('Opted out of search engines indexing').'</span>'; $admacc='<span class="null">'._('Opted out of search engines indexing').'</span>';
@ -830,6 +838,37 @@ if (array_key_exists('debug',$_GET) && $_GET['debug']=='1') echo('<!--'.N.'--- D
// functions // functions
function setfedipact() {
global $link, $graceline, $fedipact, $cfedipact;
$fedipact=['uris'=>[], 'uris_me'=>[], 'instids'=>[]];
$fedipactfp='../clitools/fedipact.list';
$fedipact['uris']=@file($fedipactfp,FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
if (!is_array($fedipact['uris'])) {
debug('WARNING: could not open «'.$fedipactfp.'».'.N,$debug);
$fedipact['uris']=[];
}
$cfedipact=count($fedipact['uris']);
if ($cfedipact>0) {
foreach ($fedipact['uris'] as $val)
$fedipact['uris_me'][]=myesc($link,$val);
$fedipact['uris_me']='"'.implode('", "',$fedipact['uris_me']).'"';
//echo '<pre>'.print_r($fedipact,true).'</pre>'.N;
$res=tquery('SELECT ID, URI FROM Instances WHERE IsMastodon=1 AND LastOkCheckTS>='.$graceline.' AND URI IN ('.$fedipact['uris_me'].')', __LINE__);
$fedipact['uris']=[];
$fedipact['uris_me']=[];
while ($row=mysqli_fetch_assoc($res)) {
$fedipact['uris'][]=$row['URI'];
$fedipact['instids'][]=$row['ID'];
}
foreach ($fedipact['uris'] as $val)
$fedipact['uris_me'][]=myesc($link,$val);
$fedipact['uris_me']='"'.implode('", "',$fedipact['uris_me']).'"';
$cfedipact=count($fedipact['instids']);
} else {
$fedipact['uris_me']='';
}
}
function debug($msg,&$debug) { function debug($msg,&$debug) {
if (array_key_exists('debug',$_GET) && $_GET['debug']=='1') if (array_key_exists('debug',$_GET) && $_GET['debug']=='1')
$debug.=$msg; $debug.=$msg;