Added code for Threads stats; fixed a little bug
This commit is contained in:
parent
ee3a2db157
commit
aacbafd942
1 changed files with 88 additions and 14 deletions
|
@ -48,7 +48,7 @@ $maxudef=30000;
|
|||
$maxumax=4294967295;
|
||||
$minaudef=10;
|
||||
$minaumax=4294967295;
|
||||
$mincdef='""';
|
||||
$mincdef='';
|
||||
$mincmax=16777215;
|
||||
|
||||
$link=mysqli_connect($conf['db_host'],$conf['db_user_name'],$conf['db_user_password'],$conf['db_name'],$conf['db_port'],$conf['db_socket']) or muorimeglio(_('Couldn’t connect to database: ').mysqli_connect_error().' ['.mysqli_connect_errno().']',false);
|
||||
|
@ -103,6 +103,22 @@ function swhelpi(over) {
|
|||
himg.src="'.$prepath.'imgs/helpbutt"+ia+".svg";
|
||||
}
|
||||
|
||||
let msshow=true;
|
||||
|
||||
function swmetastats() {
|
||||
let msdiv=document.getElementById("metastats");
|
||||
let msswitch=document.getElementById("msswitch");
|
||||
if (msshow) {
|
||||
msdiv.style.height="0px";
|
||||
msswitch.innerText="Show Threads suspension / limitation stats";
|
||||
msshow=false;
|
||||
} else {
|
||||
msdiv.style.height=msdiv.scrollHeight+"px";
|
||||
msswitch.innerText="Hide Threads suspension / limitation stats";
|
||||
msshow=true;
|
||||
}
|
||||
}
|
||||
|
||||
function swp(pn) {
|
||||
document.curvf.p.value=pn;
|
||||
document.curvf.submit();
|
||||
|
@ -126,7 +142,6 @@ function presub() {
|
|||
</script>
|
||||
'.N);
|
||||
|
||||
|
||||
$res=mysqli_query($link,'SELECT COUNT(Instances.ID) AS Unknown, SUM(Instances.UserCount) AS UnknownU FROM Instances WHERE Instances.IsMastodon=1 AND Instances.BlockListAvailable=0 AND Instances.LastOkCheckTS>='.$graceline) or muorimeglio(__LINE__.': '.mysqli_error($link),true);
|
||||
$row=mysqli_fetch_assoc($res);
|
||||
$metastats['unknown']=['instances'=>$row['Unknown'], 'users'=>nulltozero($row['UnknownU'])];
|
||||
|
@ -141,33 +156,92 @@ function presub() {
|
|||
|
||||
$res=mysqli_query($link,'SELECT COUNT(ID) AS tinsts, SUM(UserCount) AS tusers, SUM(StatusCount) AS tstatuses, SUM(ActiveUsersMonth) AS tactusers FROM Instances WHERE Instances.IsMastodon=1 AND Instances.LastOkCheckTS>='.$graceline) or muorimeglio(__LINE__.': '.mysqli_error($link),true);
|
||||
$row=mysqli_fetch_assoc($res);
|
||||
echo(_('<div id="help" class="helpd"><p class="intro">This search engine for Mastodon instances is based on a database that gets updated by our crawler every night (CET). Instances are considered new for 30 days after they are discovered. When an instance has not responded to our daily checks for more than 30 days it’s no longer considered in statistics and searches and it gets checked only on the first of the month, rather than daily, until it possibly responds again. “Random ordering” of results varies daily.</p><p class="intro">Default search criteria reflect our fondness for a decentralized and egalitarian Fediverse and our attempt to exclude instances accepting fascist, racist, sexist, ableist or sovereignist contents by marking them as noxious.</p></div>').N);
|
||||
echo(_('<div id="help" class="hiddiv"><p class="intro">This search engine for Mastodon instances is based on a database that gets updated by our crawler every night (CET). Instances are considered new for 30 days after they are discovered. When an instance has not responded to our daily checks for more than 30 days it’s no longer considered in statistics and searches and it gets checked only on the first of the month, rather than daily, until it possibly responds again. “Random ordering” of results varies daily.</p><p class="intro">Default search criteria reflect our fondness for a decentralized and egalitarian Fediverse and our attempt to exclude instances accepting fascist, racist, sexist, ableist or sovereignist contents by marking them as noxious.</p></div>').N);
|
||||
printf(_('<p class="intro">We currently count <span class="statd">%s</span> Mastodon instances, with <span class="statd">%s</span> users (<span class="statd">%s</span> active during last month) and <span class="statd">%s</span> published statuses.</p>').N, fnum($row['tinsts'],0,$dlang), fnum($row['tusers'],0,$dlang), fnum($row['tactusers'],0,$dlang), fnum($row['tstatuses'],0,$dlang));
|
||||
|
||||
$metastats['unknown']['iperc']=fnum(100/$row['tinsts']*$metastats['unknown']['instances'],1,$dlang);
|
||||
$metastats['unknown']['uperc']=fnum(100/$row['tusers']*$metastats['unknown']['users'],1,$dlang);
|
||||
$metastats['known']=[
|
||||
'instances'=>$row['tinsts']-$metastats['unknown']['instances'],
|
||||
'users'=>$row['tusers']-$metastats['unknown']['users'],
|
||||
];
|
||||
$metastats['known']['iperc']=100/$row['tinsts']*$metastats['known']['instances'];
|
||||
$metastats['known']['uperc']=100/$row['tusers']*$metastats['known']['users'];
|
||||
|
||||
$metastats['suspending']['iperc']=fnum(100/$row['tinsts']*$metastats['suspending']['instances'],1,$dlang);
|
||||
$metastats['suspending']['uperc']=fnum(100/$row['tusers']*$metastats['suspending']['users'],1,$dlang);
|
||||
$metastats['unknown']['iperc']=100/$row['tinsts']*$metastats['unknown']['instances'];
|
||||
$metastats['unknown']['uperc']=100/$row['tusers']*$metastats['unknown']['users'];
|
||||
|
||||
$metastats['silencing']['iperc']=fnum(100/$row['tinsts']*$metastats['silencing']['instances'],1,$dlang);
|
||||
$metastats['silencing']['uperc']=fnum(100/$row['tusers']*$metastats['silencing']['users'],1,$dlang);
|
||||
$metastats['suspending']['iperc']=100/$row['tinsts']*$metastats['suspending']['instances'];
|
||||
$metastats['suspending']['uperc']=100/$row['tusers']*$metastats['suspending']['users'];
|
||||
$metastats['suspending']['kiperc']=100/$metastats['known']['instances']*$metastats['suspending']['instances'];
|
||||
$metastats['suspending']['kuperc']=100/$metastats['known']['users']*$metastats['suspending']['users'];
|
||||
|
||||
$metastats['silencing']['iperc']=100/$row['tinsts']*$metastats['silencing']['instances'];
|
||||
$metastats['silencing']['uperc']=100/$row['tusers']*$metastats['silencing']['users'];
|
||||
$metastats['silencing']['kiperc']=100/$metastats['known']['instances']*$metastats['silencing']['instances'];
|
||||
$metastats['silencing']['kuperc']=100/$metastats['known']['users']*$metastats['silencing']['users'];
|
||||
|
||||
$metastats['notsuspsil']=[
|
||||
'instances'=>$row['tinsts']-$metastats['unknown']['instances']-$metastats['suspending']['instances']-$metastats['silencing']['instances'],
|
||||
'users'=>$row['tusers']-$metastats['unknown']['users']-$metastats['suspending']['users']-$metastats['silencing']['users']
|
||||
];
|
||||
$metastats['notsuspsil']['iperc']=fnum(100/$row['tinsts']*$metastats['notsuspsil']['instances'],1,$dlang);
|
||||
$metastats['notsuspsil']['uperc']=fnum(100/$row['tusers']*$metastats['notsuspsil']['users'],1,$dlang);
|
||||
$metastats['notsuspsil']['iperc']=100/$row['tinsts']*$metastats['notsuspsil']['instances'];
|
||||
$metastats['notsuspsil']['uperc']=100/$row['tusers']*$metastats['notsuspsil']['users'];
|
||||
$metastats['notsuspsil']['kiperc']=100/$metastats['known']['instances']*$metastats['notsuspsil']['instances'];
|
||||
$metastats['notsuspsil']['kuperc']=100/$metastats['known']['users']*$metastats['notsuspsil']['users'];
|
||||
|
||||
$metastats['suspsil']=[
|
||||
'instances'=>$metastats['suspending']['instances']+$metastats['silencing']['instances'],
|
||||
'users'=>$metastats['suspending']['users']+$metastats['silencing']['users']
|
||||
];
|
||||
$metastats['suspsil']['iperc']=fnum(100/$row['tinsts']*$metastats['suspsil']['instances'],1,$dlang);
|
||||
$metastats['suspsil']['uperc']=fnum(100/$row['tusers']*$metastats['suspsil']['users'],1,$dlang);
|
||||
$metastats['suspsil']['iperc']=100/$row['tinsts']*$metastats['suspsil']['instances'];
|
||||
$metastats['suspsil']['uperc']=100/$row['tusers']*$metastats['suspsil']['users'];
|
||||
$metastats['suspsil']['kiperc']=100/$metastats['known']['instances']*$metastats['suspsil']['instances'];
|
||||
$metastats['suspsil']['kuperc']=100/$metastats['known']['users']*$metastats['suspsil']['users'];
|
||||
|
||||
//printf(_('<p class="introe">Threads is neither suspended nor limited by <span class="statd">%s</span> instances (<span class="statd">%s</span>%%) with <span class="statd">%s</span> users (<span class="statd">%s</span>%%); it is suspended or limited by <span class="statd">%s</span> instances (<span class="statd">%s</span>%%) with <span class="statd">%s</span> users (<span class="statd">%s</span>%%); it is suspended by <span class="statd">%s</span> instances (<span class="statd">%s</span>%%) with <span class="statd">%s</span> users (<span class="statd">%s</span>%%); it is limited by <span class="statd">%s</span> instances (<span class="statd">%s</span>%%) with <span class="statd">%s</span> users (<span class="statd">%s</span>%%); it is impossible to access the list of moderated instances on <span class="statd">%s</span> instances (<span class="statd">%s</span>%%) with <span class="statd">%s</span> users (<span class="statd">%s</span>%%).</p>').N, $metastats['notsuspsil']['instances'], $metastats['notsuspsil']['iperc'], $metastats['notsuspsil']['users'], $metastats['notsuspsil']['uperc'], $metastats['suspsil']['instances'], $metastats['suspsil']['iperc'], $metastats['suspsil']['users'], $metastats['suspsil']['uperc'], $metastats['suspending']['instances'], $metastats['suspending']['iperc'], $metastats['suspending']['users'], $metastats['suspending']['uperc'], $metastats['silencing']['instances'], $metastats['silencing']['iperc'], $metastats['silencing']['users'], $metastats['silencing']['uperc'], $metastats['unknown']['instances'], $metastats['unknown']['iperc'], $metastats['unknown']['users'], $metastats['unknown']['uperc']);
|
||||
|
||||
echo
|
||||
'<h4><a id="msswitch" onclick="swmetastats();" style="cursor:pointer;">Show Threads suspension / limitation stats</a></h4>
|
||||
|
||||
<div id="metastats" class="hiddiv">
|
||||
|
||||
<script language="JavaScript">swmetastats();</script>
|
||||
|
||||
<h5>Stats relative to instances with accessible list of moderated instances</h5>
|
||||
|
||||
<table class="ms_leg_tab"><tr><td class="ms_suspending"></td><td class="ms_leg_td"> '._('Instances suspending Threads').': '.fnum($metastats['suspending']['instances'],0,$dlang).' / '.fnum($metastats['known']['instances'],0,$dlang).' ('.fnum($metastats['suspending']['kiperc'],2,$dlang).'%)</td></tr></table>
|
||||
<table class="ms_leg_tab"><tr><td class="ms_silencing"></td><td class="ms_leg_td"> '._('Instances limiting Threads').': '.fnum($metastats['silencing']['instances'],0,$dlang).' / '.fnum($metastats['known']['instances'],0,$dlang).' ('.fnum($metastats['silencing']['kiperc'],2,$dlang).'%)</td></tr></table>
|
||||
<table class="ms_leg_tab"><tr><td class="ms_suspending"></td><td class="ms_leg_td">+</td><td class="ms_silencing"></td><td class="ms_leg_td"> '._('Instances suspending or limiting Threads').': '.fnum($metastats['suspending']['instances']+$metastats['silencing']['instances'],0,$dlang).' / '.fnum($metastats['known']['instances'],0,$dlang).' ('.fnum($metastats['suspending']['kiperc']+$metastats['silencing']['kiperc'],2,$dlang).'%)</td></tr></table>
|
||||
<table class="ms_leg_tab"><tr><td class="ms_notsuspsil"></td><td class="ms_leg_td"> '._('Instances not suspending or limiting Threads').': '.fnum($metastats['notsuspsil']['instances'],0,$dlang).' / '.fnum($metastats['known']['instances'],0,$dlang).' ('.fnum($metastats['notsuspsil']['kiperc'],2,$dlang).'%)</td></tr></table>
|
||||
|
||||
<table class="ms_cont"><tr><td class="ms_suspending" style="width:'.$metastats['suspending']['kiperc'].'%"></td><td class="ms_silencing" style="width:'.$metastats['silencing']['kiperc'].'%"></td><td class="ms_notsuspsil" style="width:'.$metastats['notsuspsil']['kiperc'].'%"></td></tr></table>
|
||||
|
||||
<table class="ms_leg_tab"><tr><td class="ms_suspending_u"></td><td class="ms_leg_td"> '._('Users on instances suspending Threads').': '.fnum($metastats['suspending']['users'],0,$dlang).' / '.fnum($metastats['known']['users'],0,$dlang).' ('.fnum($metastats['suspending']['kuperc'],2,$dlang).'%)</td></tr></table>
|
||||
<table class="ms_leg_tab"><tr><td class="ms_silencing_u"></td><td class="ms_leg_td"> '._('Users on instances limiting Threads').': '.fnum($metastats['silencing']['users'],0,$dlang).' / '.fnum($metastats['known']['users'],0,$dlang).' ('.fnum($metastats['silencing']['kuperc'],2,$dlang).'%)</td></tr></table>
|
||||
<table class="ms_leg_tab"><tr><td class="ms_suspending_u"></td><td class="ms_leg_td">+</td><td class="ms_silencing_u"></td><td class="ms_leg_td"> '._('Users on instances suspending or limiting Threads').': '.fnum($metastats['suspending']['users']+$metastats['silencing']['users'],0,$dlang).' / '.fnum($metastats['known']['instances'],0,$dlang).' ('.fnum($metastats['suspending']['kuperc']+$metastats['silencing']['kuperc'],2,$dlang).'%)</td></tr></table>
|
||||
<table class="ms_leg_tab"><tr><td class="ms_notsuspsil_u"></td><td class="ms_leg_td"> '._('Users on instances not suspending or limiting Threads').': '.fnum($metastats['notsuspsil']['users'],0,$dlang).' / '.fnum($metastats['known']['users'],0,$dlang).' ('.fnum($metastats['notsuspsil']['kuperc'],2,$dlang).'%)</td></tr></table>
|
||||
|
||||
<table class="ms_cont"><tr><td class="ms_suspending_u" style="width:'.$metastats['suspending']['kuperc'].'%"></td><td class="ms_silencing_u" style="width:'.$metastats['silencing']['kuperc'].'%"></td><td class="ms_notsuspsil_u" style="width:'.$metastats['notsuspsil']['kuperc'].'%"></td></tr></table>
|
||||
|
||||
<h5>Stats relative to all instances</h5>
|
||||
|
||||
<table class="ms_leg_tab"><tr><td class="ms_suspending"></td><td class="ms_leg_td"> '._('Instances suspending Threads').': '.fnum($metastats['suspending']['instances'],0,$dlang).' / '.fnum($row['tinsts'],0,$dlang).' ('.fnum($metastats['suspending']['iperc'],2,$dlang).'%)</td></tr></table>
|
||||
<table class="ms_leg_tab"><tr><td class="ms_silencing"></td><td class="ms_leg_td"> '._('Instances limiting Threads').': '.fnum($metastats['silencing']['instances'],0,$dlang).' / '.fnum($row['tinsts'],0,$dlang).' ('.fnum($metastats['silencing']['iperc'],2,$dlang).'%)</td></tr></table>
|
||||
<table class="ms_leg_tab"><tr><td class="ms_suspending"></td><td class="ms_leg_td">+</td><td class="ms_silencing"></td><td class="ms_leg_td"> '._('Instances suspending or limiting Threads').': '.fnum($metastats['suspending']['instances']+$metastats['silencing']['instances'],0,$dlang).' / '.fnum($row['tinsts'],0,$dlang).' ('.fnum($metastats['suspending']['iperc']+$metastats['silencing']['iperc'],2,$dlang).'%)</td></tr></table>
|
||||
<table class="ms_leg_tab"><tr><td class="ms_notsuspsil"></td><td class="ms_leg_td"> '._('Instances not suspending or limiting Threads').': '.fnum($metastats['notsuspsil']['instances'],0,$dlang).' / '.fnum($row['tinsts'],0,$dlang).' ('.fnum($metastats['notsuspsil']['iperc'],2,$dlang).'%)</td></tr></table>
|
||||
<table class="ms_leg_tab"><tr><td class="ms_unknown"></td><td class="ms_leg_td"> '._('Instances with unaccessible list of moderated instances').': '.fnum($metastats['unknown']['instances'],0,$dlang).' / '.fnum($row['tinsts'],0,$dlang).' ('.fnum($metastats['unknown']['iperc'],2,$dlang).'%)</td></tr></table>
|
||||
|
||||
<table class="ms_cont"><tr><td class="ms_suspending" style="width:'.$metastats['suspending']['iperc'].'%"></td><td class="ms_silencing" style="width:'.$metastats['silencing']['iperc'].'%"></td><td class="ms_notsuspsil" style="width:'.$metastats['notsuspsil']['iperc'].'%"></td><td class="ms_unknown" style="width:'.$metastats['unknown']['iperc'].'%"></td></tr></table>
|
||||
|
||||
<table class="ms_leg_tab"><tr><td class="ms_suspending_u"></td><td class="ms_leg_td"> '._('Users on instances suspending Threads').': '.fnum($metastats['suspending']['users'],0,$dlang).' / '.fnum($row['tinsts'],0,$dlang).' ('.fnum($metastats['suspending']['uperc'],2,$dlang).'%)</td></tr></table>
|
||||
<table class="ms_leg_tab"><tr><td class="ms_silencing_u"></td><td class="ms_leg_td"> '._('Users on instances limiting Threads').': '.fnum($metastats['silencing']['users'],0,$dlang).' / '.fnum($row['tinsts'],0,$dlang).' ('.fnum($metastats['silencing']['uperc'],2,$dlang).'%)</td></tr></table>
|
||||
<table class="ms_leg_tab"><tr><td class="ms_suspending_u"></td><td class="ms_leg_td">+</td><td class="ms_silencing_u"></td><td class="ms_leg_td"> '._('Users on instances suspending or limiting Threads').': '.fnum($metastats['suspending']['users']+$metastats['silencing']['users'],0,$dlang).' / '.fnum($row['tinsts'],0,$dlang).' ('.fnum($metastats['suspending']['uperc']+$metastats['silencing']['uperc'],2,$dlang).'%)</td></tr></table>
|
||||
<table class="ms_leg_tab"><tr><td class="ms_notsuspsil_u"></td><td class="ms_leg_td"> '._('Users on instances not suspending or limiting Threads').': '.fnum($metastats['notsuspsil']['users'],0,$dlang).' / '.fnum($row['tinsts'],0,$dlang).' ('.fnum($metastats['notsuspsil']['uperc'],2,$dlang).'%)</td></tr></table>
|
||||
<table class="ms_leg_tab"><tr><td class="ms_unknown_u"></td><td class="ms_leg_td"> '._('Users on instances with unaccessible list of moderated instances').': '.fnum($metastats['unknown']['users'],0,$dlang).' / '.fnum($row['tinsts'],0,$dlang).' ('.fnum($metastats['unknown']['uperc'],2,$dlang).'%)</td></tr></table>
|
||||
|
||||
<table class="ms_cont"><tr><td class="ms_suspending_u" style="width:'.$metastats['suspending']['uperc'].'%"></td><td class="ms_silencing_u" style="width:'.$metastats['silencing']['uperc'].'%"></td><td class="ms_notsuspsil_u" style="width:'.$metastats['notsuspsil']['uperc'].'%"></td><td class="ms_unknown_u" style="width:'.$metastats['unknown']['uperc'].'%"></td></tr></table>
|
||||
|
||||
</div>'.N;
|
||||
|
||||
printf(_('<p class="introe">Threads is neither suspended nor limited by <span class="statd">%s</span> instances (<span class="statd">%s</span>%%) with <span class="statd">%s</span> users (<span class="statd">%s</span>%%); it is suspended or limited by <span class="statd">%s</span> instances (<span class="statd">%s</span>%%) with <span class="statd">%s</span> users (<span class="statd">%s</span>%%); it is suspended by <span class="statd">%s</span> instances (<span class="statd">%s</span>%%) with <span class="statd">%s</span> users (<span class="statd">%s</span>%%); it is limited by <span class="statd">%s</span> instances (<span class="statd">%s</span>%%) with <span class="statd">%s</span> users (<span class="statd">%s</span>%%); it is impossible to access the list of moderated instances on <span class="statd">%s</span> instances (<span class="statd">%s</span>%%) with <span class="statd">%s</span> users (<span class="statd">%s</span>%%).</p>').N, $metastats['notsuspsil']['instances'], $metastats['notsuspsil']['iperc'], $metastats['notsuspsil']['users'], $metastats['notsuspsil']['uperc'], $metastats['suspsil']['instances'], $metastats['suspsil']['iperc'], $metastats['suspsil']['users'], $metastats['suspsil']['uperc'], $metastats['suspending']['instances'], $metastats['suspending']['iperc'], $metastats['suspending']['users'], $metastats['suspending']['uperc'], $metastats['silencing']['instances'], $metastats['silencing']['iperc'], $metastats['silencing']['users'], $metastats['silencing']['uperc'], $metastats['unknown']['instances'], $metastats['unknown']['iperc'], $metastats['unknown']['users'], $metastats['unknown']['uperc']);
|
||||
|
||||
if ((array_key_exists('exnox',$_GET) && $_GET['exnox']=='1') || !array_key_exists('exnox',$_GET)) {
|
||||
$_GET['cbexnox']=' checked';
|
||||
|
|
Loading…
Reference in a new issue