Added some sort criteria; added “first sight” and “last successful check”

This commit is contained in:
pezcurrel 2022-12-29 23:33:23 +01:00
parent e66a6f9e2b
commit a2c6b49403

View file

@ -163,6 +163,15 @@ function endisadvcri() {
}
ckadvcri();
}
function presub() {
document.getElementById("p").value=1;
if (document.getElementById("ord").value=="noxd") {
document.getElementById("cbnoxious").checked=false;
document.getElementById("noxious").value=0;
}
}
</script>
'.N);
@ -210,10 +219,12 @@ function strip($str,$uri) {
$str=preg_replace(['#<b>#i','#</b>#i','#<i>#i','#</i>#i'],['<strong>','</strong>','<em>','</em>'],$str);
$str=preg_replace('#<p>\s*</p>#is','',$str);
$str=strip_tags($str,'<a><br><ol><ul><li><p><div><strong><em><small><img>');
$str=preg_replace('#^\s*#m','',$str);
$str=preg_replace('#[\r\n]#',' ',$str);
$str=preg_replace('#(</p>|</ol>|</ul>|</div>)#i','$1'.N,$str);
$str=rtrim($str);
// all this part below is to try and assign the css "nobott" css class to a possible closing <p>/<ol>/<ul>/<div>,
// to avoid the useless and UGLY last bottom-margin :-))
$str=preg_replace('#^\s*#m','',$str);// strip all spaces from empty lines
$str=preg_replace('#[\r\n]#',' ',$str);// strip all "wrap chars"
$str=preg_replace('#(</p>|</ol>|</ul>|</div>)#i','$1'.N,$str);// now add a newline after every </p> and so on
$str=rtrim($str);// trim the newline at the end of the whole text block in order for the next preg_replace to match against $ as end of the whole text block
$str=preg_replace(['#<p[^>]*>(.*)</p>$#i', '#<ol[^>]*>(.*)</ol>$#i', '#<ul[^>]*>(.*)</ul>$#i', '#<div[^>]*>(.*)</div>$#i'],['<p class="nobott">$1</p>', '<ol class="nobott">$1</ol>', '<ul class="nobott">$1</ul>', '<div class="nobott">$1</div>'],$str);
return($str);
}
@ -306,21 +317,17 @@ ckgnum('minau',$minaudef,$minaumax);
$order=array(
'rand'=>array('t'=>_('Random, recommended first'),'q'=>'Instances.Priority DESC, Instances.RPos ASC'),
// 'feat'=>array('t'=>_('Prima le consigliate'),'q'=>'Instances.Priority DESC'),
// partecipazione: totusers/activeusers
// 'part'=>array('t'=>_('Partecipazione (decr.)'),'q'=>'(Instances.UserCount / Instances.ActiveUsersMonth) ASC'),
'tusersa'=>array('t'=>_('By number of users, ascending'),'q'=>'Instances.UserCount ASC'),
'invold'=>array('t'=>_('By users involvement (active users / users), descending'),'q'=>'(Instances.ActiveUsersMonth / Instances.UserCount) DESC'),
'invola'=>array('t'=>_('By users involvement (active users / users), ascending'),'q'=>'(Instances.ActiveUsersMonth / Instances.UserCount) ASC'),
'fseend'=>array('t'=>_('By date and time of first sighting, descending'),'q'=>'Instances.FirstSeen DESC'),
'fseena'=>array('t'=>_('By date and time of first sighting, ascending'),'q'=>'Instances.FirstSeen ASC'),
'tusersd'=>array('t'=>_('By number of users, descending'),'q'=>'Instances.UserCount DESC'),
'tusersa'=>array('t'=>_('By number of users, ascending'),'q'=>'Instances.UserCount ASC'),
'ausersd'=>array('t'=>_('By number of active users, descending'),'q'=>'Instances.ActiveUsersMonth DESC'),
'ausersa'=>array('t'=>_('By number of active users, ascending'),'q'=>'Instances.ActiveUsersMonth ASC'),
'charsd'=>array('t'=>_('By maximum number of characters per toot, descending'),'q'=>'Instances.MaxTootChars DESC'),
// 'open'=>array('t'=>_('Prima quelle con iscriz. aperte'),'q'=>'Instances.RegOpen DESC, Instances.RegReqApproval ASC'),
// 'alph'=>array('t'=>_('Alfabetico'),'q'=>'Instances.URI ASC'),
// new non ha senso di esistere visto che c'è firstseen
// 'new'=>array('t'=>_('Prima le nuove'),'q'=>'Instances.New DESC'),
// 'name'=>array('t'=>_('Nome (crescente)'),'q'=>'Instances.Title ASC'),
// 'admc'=>array('t'=>_('Data creazione account admin'),'q'=>'IF (Instances.AdmCreatedAt IS NULL, 9999999999, Instances.AdmCreatedAt) ASC'),
// 'fseena'=>array('t'=>_('Data di “avvistamento” cresc.'),'q'=>'Instances.FirstSeen ASC'),
// 'fseend'=>array('t'=>_('Data di “avvistamento” decr.'),'q'=>'Instances.FirstSeen DESC'),
// 'charsa'=>array('t'=>_('By maximum number of characters per toot, ascending'),'q'=>'Instances.MaxTootChars ASC'),
'noxd'=>array('t'=>_('Noxious first (switches off “Exclude noxious”)'),'q'=>'Instances.Noxious DESC')
);
if (!(array_key_exists('ord',$_GET) && array_key_exists($_GET['ord'],$order)))
$_GET['ord']='rand';
@ -344,7 +351,7 @@ echo('<form method="get" id="curvf" name="curvf">
<input name="p" type="hidden" value="'.$p.'">
</form>'.N);
($_GET['lang']==0) ? $selected=' selected' : $selected='';
echo('<form method="get" id="searchf" class="sdbox" onsubmit="document.getElementById(\'p\').value=1;">
echo('<form method="get" id="searchf" class="sdbox" onsubmit="presub();">
<div class="sdtit">'._('Search criteria').'</div>
<div class="sdrow">
<div class="sdlabel"><label for="lang" title="'._('Include only instances where the most used language is the one selected here').'">'._('Most used language is').'</label></div>
@ -521,16 +528,18 @@ while ($if<$il && $row=mysqli_fetch_assoc($res)) {
$out.='<div><span class="ilab">'._('Users').'</span> '.nully(fnum($row['UserCount'],0,$dlang)).'</div>'.N;
$out.='<div><span class="ilab">'._('Active users (last month)').'</span> '.nully(fnum($row['ActiveUsersMonth'],0,$dlang)).'</div>'.N;
$out.='<div><span class="ilab">'._('Active users (last six months)').'</span> '.nully(fnum($row['ActiveUsersHalfYear'],0,$dlang)).'</div>'.N;
$out.='<div><span class="ilab">'._('Known instances').'</span> '.nully(fnum($row['DomainCount'],0,$dlang)).'</div>'.N;
$out.='</div>'.N;
$out.='<div class="icol">'.N;
$out.='<div><span class="ilab">'._('Characters per toot (max)').'</span> ';
if (nullemp(fnum($row['MaxTootChars'],0,$dlang)))
$out.='<span class="null">500</span>';
else
$out.=$row['MaxTootChars'];
$out.='</div>'.N;
$out.='<div><span class="ilab">'._('Known instances').'</span> '.nully(fnum($row['DomainCount'],0,$dlang)).'</div>'.N;
$out.='</div>'.N;
$out.='<div class="icol">'.N;
$out.='<div><span class="ilab">'._('First sight').'</span> '.nully(ldate($row['FirstSeen'],true)).'</div>'.N;
$out.='<div><span class="ilab">'._('Last successful check').'</span> '.nully(ldate($row['LastOkCheckTS'],true)).'</div>'.N;
$out.='<div><span class="ilab">'._('Noxious').'</span> ';
($row['Noxious']==1) ? $out.='<span class="ibad">'._('Yes (see why below)').'</span>' : $out.='<span class="igood">'._('No').'</span>';
$out.='</div>'.N;