Added check for “Visible” column to every query; added btu variable; changed fnum syntax everywhere according to fnum modifications; made “debug” function output human readable times even when they are very short

This commit is contained in:
pezcurrel 2023-12-28 12:34:43 +01:00
parent a5381f057c
commit 89f4d38704

View file

@ -6,6 +6,7 @@ if (!defined('N')) {
}
$bt=hrtime(true);
$btu=time();
$dlanguc=strtoupper($dlang);
@ -18,19 +19,20 @@ use function mysqli_real_escape_string as myesc;
$dtzbl=['ca'=>'Europe/Madrid','en'=>'Europe/London','es'=>'Europe/Madrid','fr'=>'Europe/Paris','it'=>'Europe/Rome'];
date_default_timezone_set($dtzbl[$dlang]);*/
$debug='';
$lc=localeconv();
$debug='';
debug(date('r',$btu).N,$debug);
debug('REQUEST_URI: '.$_SERVER['REQUEST_URI'].N,$debug);
debug('$_GET: '.print_r($_GET,true),$debug);
debug('LOCALE: '.$locale.N,$debug);
debug('LOCALE: '.setlocale(LC_ALL,0).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)
$oldline=30*24*60*60;
// an instance is considered dead if the last time it responded is before the graceline (see code below); we fix it at start of today - $gracetime
// $gracetime is defined in mustard/include/gracetime.php
$bti=round(microtime(true));
$graceline=gmmktime(0,0,0,gmdate('n',$bti),gmdate('j',$bti),gmdate('Y',$bti))-$gracetime;
$graceline=gmmktime(0,0,0,gmdate('n',$btu),gmdate('j',$btu),gmdate('Y',$btu))-$gracetime;
if (array_key_exists('id',$_GET) && preg_match('/^\d+$/',$_GET['id'])===1) {
$_GET['id']+=0;
@ -174,14 +176,14 @@ function presub() {
setfedipact();
$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 Visible=1 AND LastOkCheckTS>='.$graceline.' AND Threads IS NULL';
if ($cfedipact>0)
$que.=' AND URI NOT IN ('.$fedipact['uris_me'].')';
$res=tquery($que,__LINE__);
$row=mysqli_fetch_assoc($res);
$metastats['unknown']=['instances'=>$row['Unknown'], 'users'=>nulltozero($row['UnknownU'])];
$que='SELECT COUNT(ID) AS Suspending, SUM(UserCount) AS SuspendingU FROM Instances WHERE IsMastodon=1 AND LastOkCheckTS>='.$graceline;
$que='SELECT COUNT(ID) AS Suspending, SUM(UserCount) AS SuspendingU FROM Instances WHERE IsMastodon=1 AND Visible=1 AND LastOkCheckTS>='.$graceline;
if ($cfedipact>0)
$que.=' AND (Threads="suspended" OR URI IN ('.$fedipact['uris_me'].'))';
else
@ -190,7 +192,7 @@ function presub() {
$row=mysqli_fetch_assoc($res);
$metastats['suspending']=['instances'=>$row['Suspending'], 'users'=>nulltozero($row['SuspendingU'])];
$res=tquery('SELECT COUNT(ID) AS Silencing, SUM(UserCount) AS SilencingU FROM Instances WHERE IsMastodon=1 AND LastOkCheckTS>='.$graceline.' AND Threads="limited"',__LINE__);
$res=tquery('SELECT COUNT(ID) AS Silencing, SUM(UserCount) AS SilencingU FROM Instances WHERE IsMastodon=1 AND Visible=1 AND LastOkCheckTS>='.$graceline.' AND Threads="limited"',__LINE__);
$row=mysqli_fetch_assoc($res);
$metastats['limiting']=['instances'=>$row['Silencing'], 'users'=>nulltozero($row['SilencingU'])];
@ -200,11 +202,11 @@ function presub() {
$metastats['fpliars']['users']=0;
$metastats['fpliars']['instlist']=[];
if ($cfedipact>0) {
$res=tquery('SELECT COUNT(ID) AS FPSuspending, SUM(UserCount) AS FPSuspendingU FROM Instances WHERE IsMastodon=1 AND LastOkCheckTS>='.$graceline.' AND URI IN ('.$fedipact['uris_me'].')',__LINE__);
$res=tquery('SELECT COUNT(ID) AS FPSuspending, SUM(UserCount) AS FPSuspendingU FROM Instances WHERE IsMastodon=1 AND Visible=1 AND LastOkCheckTS>='.$graceline.' AND URI IN ('.$fedipact['uris_me'].')',__LINE__);
$row=mysqli_fetch_assoc($res);
$metastats['fpsuspending']['instances']=$row['FPSuspending'];
$metastats['fpsuspending']['users']=nulltozero($row['FPSuspendingU']);
$res=tquery('SELECT URI, UserCount FROM Instances WHERE IsMastodon=1 AND LastOkCheckTS>='.$graceline.' AND Threads="accessible" AND URI IN ('.$fedipact['uris_me'].')',__LINE__);
$res=tquery('SELECT URI, UserCount FROM Instances WHERE IsMastodon=1 AND Visible=1 AND LastOkCheckTS>='.$graceline.' AND Threads="accessible" AND URI IN ('.$fedipact['uris_me'].')',__LINE__);
while ($row=mysqli_fetch_assoc($res)) {
$metastats['fpliars']['instances']++;
$metastats['fpliars']['users']+=nulltozero($row['UserCount']);
@ -212,10 +214,10 @@ function presub() {
}
}
$res=tquery('SELECT COUNT(ID) AS tinsts, SUM(UserCount) AS tusers, SUM(StatusCount) AS tstatuses, SUM(ActiveUsersMonth) AS tactusers FROM Instances WHERE IsMastodon=1 AND LastOkCheckTS>='.$graceline,__LINE__);
$res=tquery('SELECT COUNT(ID) AS tinsts, SUM(UserCount) AS tusers, SUM(StatusCount) AS tstatuses, SUM(ActiveUsersMonth) AS tactusers FROM Instances WHERE IsMastodon=1 AND Visible=1 AND LastOkCheckTS>='.$graceline,__LINE__);
$row=mysqli_fetch_assoc($res);
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 its 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. [<a id="msswitch" onclick="swmetastats();" style="cursor:pointer;">Show Threads moderation statistics</a>]</p>'), fnum($row['tinsts'],0,$dlang), fnum($row['tusers'],0,$dlang), fnum($row['tactusers'],0,$dlang), fnum($row['tstatuses'],0,$dlang));
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. [<a id="msswitch" onclick="swmetastats();" style="cursor:pointer;">Show Threads moderation statistics</a>]</p>'), fnum($row['tinsts'],$lc), fnum($row['tusers'],$lc), fnum($row['tactusers'],$lc), fnum($row['tstatuses'],$lc));
//echo '<pre>'.print_r($metastats,true).'</pre>'.N;
@ -278,39 +280,39 @@ function presub() {
<h4>'._('Statistics on the state of Threads moderation<br>related to instances on which it is known').'</h4>
<table class="ms_leg_tab"><tr><td class="ms_suspending"></td><td class="ms_leg_td">&nbsp;'._('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_limiting"></td><td class="ms_leg_td">&nbsp;'._('Instances limiting Threads').': '.fnum($metastats['limiting']['instances'],0,$dlang).' / '.fnum($metastats['known']['instances'],0,$dlang).' ('.fnum($metastats['limiting']['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_limiting"></td><td class="ms_leg_td">&nbsp;'._('Instances suspending or limiting Threads').': '.fnum($metastats['suspending']['instances']+$metastats['limiting']['instances'],0,$dlang).' / '.fnum($metastats['known']['instances'],0,$dlang).' ('.fnum($metastats['suspending']['kiperc']+$metastats['limiting']['kiperc'],2,$dlang).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_notsusporlim"></td><td class="ms_leg_td">&nbsp;'._('Instances not suspending or limiting Threads').': '.fnum($metastats['notsusporlim']['instances'],0,$dlang).' / '.fnum($metastats['known']['instances'],0,$dlang).' ('.fnum($metastats['notsusporlim']['kiperc'],2,$dlang).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_suspending"></td><td class="ms_leg_td">&nbsp;'._('Instances suspending Threads').': '.fnum($metastats['suspending']['instances'],$lc).' / '.fnum($metastats['known']['instances'],$lc).' ('.fnum($metastats['suspending']['kiperc'],$lc,2).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_limiting"></td><td class="ms_leg_td">&nbsp;'._('Instances limiting Threads').': '.fnum($metastats['limiting']['instances'],$lc).' / '.fnum($metastats['known']['instances'],$lc).' ('.fnum($metastats['limiting']['kiperc'],$lc,2).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_suspending"></td><td class="ms_leg_td">+</td><td class="ms_limiting"></td><td class="ms_leg_td">&nbsp;'._('Instances suspending or limiting Threads').': '.fnum($metastats['suspending']['instances']+$metastats['limiting']['instances'],$lc).' / '.fnum($metastats['known']['instances'],$lc).' ('.fnum($metastats['suspending']['kiperc']+$metastats['limiting']['kiperc'],$lc,2).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_notsusporlim"></td><td class="ms_leg_td">&nbsp;'._('Instances not suspending or limiting Threads').': '.fnum($metastats['notsusporlim']['instances'],$lc).' / '.fnum($metastats['known']['instances'],$lc).' ('.fnum($metastats['notsusporlim']['kiperc'],$lc,2).'%)</td></tr></table>
<table class="ms_cont"><tr><td class="ms_suspending" style="width:'.$metastats['suspending']['kiperc'].'%"></td><td class="ms_limiting" style="width:'.$metastats['limiting']['kiperc'].'%"></td><td class="ms_notsusporlim" style="width:'.$metastats['notsusporlim']['kiperc'].'%"></td></tr></table>
<div class="sep"></div>
<table class="ms_leg_tab"><tr><td class="ms_suspending_u"></td><td class="ms_leg_td">&nbsp;'._('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_limiting_u"></td><td class="ms_leg_td">&nbsp;'._('Users on instances limiting Threads').': '.fnum($metastats['limiting']['users'],0,$dlang).' / '.fnum($metastats['known']['users'],0,$dlang).' ('.fnum($metastats['limiting']['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_limiting_u"></td><td class="ms_leg_td">&nbsp;'._('Users on instances suspending or limiting Threads').': '.fnum($metastats['suspending']['users']+$metastats['limiting']['users'],0,$dlang).' / '.fnum($metastats['known']['instances'],0,$dlang).' ('.fnum($metastats['suspending']['kuperc']+$metastats['limiting']['kuperc'],2,$dlang).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_notsusporlim_u"></td><td class="ms_leg_td">&nbsp;'._('Users on instances not suspending or limiting Threads').': '.fnum($metastats['notsusporlim']['users'],0,$dlang).' / '.fnum($metastats['known']['users'],0,$dlang).' ('.fnum($metastats['notsusporlim']['kuperc'],2,$dlang).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_suspending_u"></td><td class="ms_leg_td">&nbsp;'._('Users on instances suspending Threads').': '.fnum($metastats['suspending']['users'],$lc).' / '.fnum($metastats['known']['users'],$lc).' ('.fnum($metastats['suspending']['kuperc'],$lc,2).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_limiting_u"></td><td class="ms_leg_td">&nbsp;'._('Users on instances limiting Threads').': '.fnum($metastats['limiting']['users'],$lc).' / '.fnum($metastats['known']['users'],$lc).' ('.fnum($metastats['limiting']['kuperc'],$lc,2).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_suspending_u"></td><td class="ms_leg_td">+</td><td class="ms_limiting_u"></td><td class="ms_leg_td">&nbsp;'._('Users on instances suspending or limiting Threads').': '.fnum($metastats['suspending']['users']+$metastats['limiting']['users'],$lc).' / '.fnum($metastats['known']['instances'],$lc).' ('.fnum($metastats['suspending']['kuperc']+$metastats['limiting']['kuperc'],$lc,2).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_notsusporlim_u"></td><td class="ms_leg_td">&nbsp;'._('Users on instances not suspending or limiting Threads').': '.fnum($metastats['notsusporlim']['users'],$lc).' / '.fnum($metastats['known']['users'],$lc).' ('.fnum($metastats['notsusporlim']['kuperc'],$lc,2).'%)</td></tr></table>
<table class="ms_cont"><tr><td class="ms_suspending_u" style="width:'.$metastats['suspending']['kuperc'].'%"></td><td class="ms_limiting_u" style="width:'.$metastats['limiting']['kuperc'].'%"></td><td class="ms_notsusporlim_u" style="width:'.$metastats['notsusporlim']['kuperc'].'%"></td></tr></table>
<h4>'._('Statistics on the state of Threads<br>moderation related to all instances.').'</h4>
<table class="ms_leg_tab"><tr><td class="ms_suspending"></td><td class="ms_leg_td">&nbsp;'._('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_limiting"></td><td class="ms_leg_td">&nbsp;'._('Instances limiting Threads').': '.fnum($metastats['limiting']['instances'],0,$dlang).' / '.fnum($row['tinsts'],0,$dlang).' ('.fnum($metastats['limiting']['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_limiting"></td><td class="ms_leg_td">&nbsp;'._('Instances suspending or limiting Threads').': '.fnum($metastats['suspending']['instances']+$metastats['limiting']['instances'],0,$dlang).' / '.fnum($row['tinsts'],0,$dlang).' ('.fnum($metastats['suspending']['iperc']+$metastats['limiting']['iperc'],2,$dlang).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_notsusporlim"></td><td class="ms_leg_td">&nbsp;'._('Instances not suspending or limiting Threads').': '.fnum($metastats['notsusporlim']['instances'],0,$dlang).' / '.fnum($row['tinsts'],0,$dlang).' ('.fnum($metastats['notsusporlim']['iperc'],2,$dlang).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_unknown"></td><td class="ms_leg_td">&nbsp;'._('Instances whose Threads moderation status is unknown').': '.fnum($metastats['unknown']['instances'],0,$dlang).' / '.fnum($row['tinsts'],0,$dlang).' ('.fnum($metastats['unknown']['iperc'],2,$dlang).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_suspending"></td><td class="ms_leg_td">&nbsp;'._('Instances suspending Threads').': '.fnum($metastats['suspending']['instances'],$lc).' / '.fnum($row['tinsts'],$lc).' ('.fnum($metastats['suspending']['iperc'],$lc,2).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_limiting"></td><td class="ms_leg_td">&nbsp;'._('Instances limiting Threads').': '.fnum($metastats['limiting']['instances'],$lc).' / '.fnum($row['tinsts'],$lc).' ('.fnum($metastats['limiting']['iperc'],$lc,2).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_suspending"></td><td class="ms_leg_td">+</td><td class="ms_limiting"></td><td class="ms_leg_td">&nbsp;'._('Instances suspending or limiting Threads').': '.fnum($metastats['suspending']['instances']+$metastats['limiting']['instances'],$lc).' / '.fnum($row['tinsts'],$lc).' ('.fnum($metastats['suspending']['iperc']+$metastats['limiting']['iperc'],$lc,2).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_notsusporlim"></td><td class="ms_leg_td">&nbsp;'._('Instances not suspending or limiting Threads').': '.fnum($metastats['notsusporlim']['instances'],$lc).' / '.fnum($row['tinsts'],$lc).' ('.fnum($metastats['notsusporlim']['iperc'],$lc,2).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_unknown"></td><td class="ms_leg_td">&nbsp;'._('Instances whose Threads moderation status is unknown').': '.fnum($metastats['unknown']['instances'],$lc).' / '.fnum($row['tinsts'],$lc).' ('.fnum($metastats['unknown']['iperc'],$lc,2).'%)</td></tr></table>
<table class="ms_cont"><tr><td class="ms_suspending" style="width:'.$metastats['suspending']['iperc'].'%"></td><td class="ms_limiting" style="width:'.$metastats['limiting']['iperc'].'%"></td><td class="ms_notsusporlim" style="width:'.$metastats['notsusporlim']['iperc'].'%"></td><td class="ms_unknown" style="width:'.$metastats['unknown']['iperc'].'%"></td></tr></table>
<div class="sep"></div>
<table class="ms_leg_tab"><tr><td class="ms_suspending_u"></td><td class="ms_leg_td">&nbsp;'._('Users on instances suspending Threads').': '.fnum($metastats['suspending']['users'],0,$dlang).' / '.fnum($row['tusers'],0,$dlang).' ('.fnum($metastats['suspending']['uperc'],2,$dlang).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_limiting_u"></td><td class="ms_leg_td">&nbsp;'._('Users on instances limiting Threads').': '.fnum($metastats['limiting']['users'],0,$dlang).' / '.fnum($row['tusers'],0,$dlang).' ('.fnum($metastats['limiting']['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_limiting_u"></td><td class="ms_leg_td">&nbsp;'._('Users on instances suspending or limiting Threads').': '.fnum($metastats['suspending']['users']+$metastats['limiting']['users'],0,$dlang).' / '.fnum($row['tusers'],0,$dlang).' ('.fnum($metastats['suspending']['uperc']+$metastats['limiting']['uperc'],2,$dlang).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_notsusporlim_u"></td><td class="ms_leg_td">&nbsp;'._('Users on instances not suspending or limiting Threads').': '.fnum($metastats['notsusporlim']['users'],0,$dlang).' / '.fnum($row['tusers'],0,$dlang).' ('.fnum($metastats['notsusporlim']['uperc'],2,$dlang).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_unknown_u"></td><td class="ms_leg_td">&nbsp;'._('Users on instances whose Threads mod. status is unknown').': '.fnum($metastats['unknown']['users'],0,$dlang).' / '.fnum($row['tusers'],0,$dlang).' ('.fnum($metastats['unknown']['uperc'],2,$dlang).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_suspending_u"></td><td class="ms_leg_td">&nbsp;'._('Users on instances suspending Threads').': '.fnum($metastats['suspending']['users'],$lc).' / '.fnum($row['tusers'],$lc).' ('.fnum($metastats['suspending']['uperc'],$lc,2).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_limiting_u"></td><td class="ms_leg_td">&nbsp;'._('Users on instances limiting Threads').': '.fnum($metastats['limiting']['users'],$lc).' / '.fnum($row['tusers'],$lc).' ('.fnum($metastats['limiting']['uperc'],$lc,2).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_suspending_u"></td><td class="ms_leg_td">+</td><td class="ms_limiting_u"></td><td class="ms_leg_td">&nbsp;'._('Users on instances suspending or limiting Threads').': '.fnum($metastats['suspending']['users']+$metastats['limiting']['users'],$lc).' / '.fnum($row['tusers'],$lc).' ('.fnum($metastats['suspending']['uperc']+$metastats['limiting']['uperc'],$lc,2).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_notsusporlim_u"></td><td class="ms_leg_td">&nbsp;'._('Users on instances not suspending or limiting Threads').': '.fnum($metastats['notsusporlim']['users'],$lc).' / '.fnum($row['tusers'],$lc).' ('.fnum($metastats['notsusporlim']['uperc'],$lc,2).'%)</td></tr></table>
<table class="ms_leg_tab"><tr><td class="ms_unknown_u"></td><td class="ms_leg_td">&nbsp;'._('Users on instances whose Threads mod. status is unknown').': '.fnum($metastats['unknown']['users'],$lc).' / '.fnum($row['tusers'],$lc).' ('.fnum($metastats['unknown']['uperc'],$lc,2).'%)</td></tr></table>
<table class="ms_cont"><tr><td class="ms_suspending_u" style="width:'.$metastats['suspending']['uperc'].'%"></td><td class="ms_limiting_u" style="width:'.$metastats['limiting']['uperc'].'%"></td><td class="ms_notsusporlim_u" style="width:'.$metastats['notsusporlim']['uperc'].'%"></td><td class="ms_unknown_u" style="width:'.$metastats['unknown']['uperc'].'%"></td></tr></table>
@ -403,8 +405,8 @@ function presub() {
];
if (!array_key_exists('ord',$_GET) || !array_key_exists($_GET['ord'],$order))
$_GET['ord']='rand';
// $res=tquery('SELECT COUNT(Instances.ID) AS Recomm FROM Instances LEFT JOIN InstOurLangs ON InstOurLangs.InstID=Instances.ID WHERE InstOurLangs.OurLangID='.$_GET['lang'].' AND Instances.IsMastodon=1 AND Instances.LastOkCheckTS>='.$graceline.' AND InstOurLangs.Pos=1 AND Instances.Priority>127',__LINE__);
$res=tquery('SELECT InstOurLangs.OurLangID FROM Instances LEFT JOIN InstOurLangs ON InstOurLangs.InstID=Instances.ID WHERE Instances.IsMastodon=1 AND Instances.LastOkCheckTS>='.$graceline.' AND InstOurLangs.Pos=1 AND Instances.Priority>127 GROUP BY InstOurLangs.OurLangID',__LINE__);
// $res=tquery('SELECT COUNT(Instances.ID) AS Recomm FROM Instances LEFT JOIN InstOurLangs ON InstOurLangs.InstID=Instances.ID WHERE InstOurLangs.OurLangID='.$_GET['lang'].' AND Instances.IsMastodon=1 AND Instances.Visible=1 AND Instances.LastOkCheckTS>='.$graceline.' AND InstOurLangs.Pos=1 AND Instances.Priority>127',__LINE__);
$res=tquery('SELECT InstOurLangs.OurLangID FROM Instances LEFT JOIN InstOurLangs ON InstOurLangs.InstID=Instances.ID WHERE Instances.IsMastodon=1 AND Instances.Visible=1 AND Instances.LastOkCheckTS>='.$graceline.' AND InstOurLangs.Pos=1 AND Instances.Priority>127 GROUP BY InstOurLangs.OurLangID',__LINE__);
$langswri=[];// langs with recommended instances
while ($row=mysqli_fetch_assoc($res))
$langswri[]=$row['OurLangID'];
@ -443,7 +445,7 @@ function presub() {
<select id="lang" name="lang" class="sselect" onchange="updord();">
<option value="0"'.$selected.'>'._('Irrelevant').'</option>'.N;
$res=tquery('SELECT Languages.ID AS Lid, CONCAT(Name'.$dlanguc.', \' [\', Code, \'] (\', COUNT(Languages.ID), \')\') AS Txt FROM InstOurLangs LEFT JOIN Instances ON Instances.ID=InstOurLangs.InstID LEFT JOIN Languages ON Languages.ID=OurLangID WHERE InstOurLangs.Pos=1 AND Instances.IsMastodon=1 AND Instances.LastOkCheckTS>='.$graceline.' GROUP BY Languages.ID ORDER BY Languages.Name'.$dlanguc.' ASC',__LINE__);
$res=tquery('SELECT Languages.ID AS Lid, CONCAT(Name'.$dlanguc.', \' [\', Code, \'] (\', COUNT(Languages.ID), \')\') AS Txt FROM InstOurLangs LEFT JOIN Instances ON Instances.ID=InstOurLangs.InstID LEFT JOIN Languages ON Languages.ID=OurLangID WHERE InstOurLangs.Pos=1 AND Instances.IsMastodon=1 AND Instances.Visible=1 AND Instances.LastOkCheckTS>='.$graceline.' GROUP BY Languages.ID ORDER BY Languages.Name'.$dlanguc.' ASC',__LINE__);
while ($row=mysqli_fetch_assoc($res)) {
($_GET['lang']==$row['Lid']) ? $selected=' selected' : $selected='';
@ -546,7 +548,7 @@ function presub() {
$joins=[];
$wheres=[];
$wheres[]='Instances.IsMastodon=1 AND Instances.LastOkCheckTS>='.$graceline;
$wheres[]='Instances.IsMastodon=1 AND Instances.Visible=1 AND Instances.LastOkCheckTS>='.$graceline;
if ($_GET['exnox']==1) $wheres[]='Instances.Noxious=0';
if ($_GET['exregc']==1) $wheres[]='Instances.RegOpen=1';
if ($_GET['exappr']==1) $wheres[]='Instances.RegReqApproval=0';
@ -622,16 +624,16 @@ while ($if<$il && $row=mysqli_fetch_assoc($res)) {
(!is_null($row['Priority'])) ? $out.='<span class="ivgood">'._('Si!').'</span>' : $out.=_('No');
$out.='</div>'.N;*/
$out.='<div><span class="ilab">'._('Languages').'</span> '.nully(implode(', ',$buf)).'</div>'.N;
$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">'._('Users').'</span> '.nully(fnum($row['UserCount'],$lc)).'</div>'.N;
$out.='<div><span class="ilab">'._('Active users (last month)').'</span> '.nully(fnum($row['ActiveUsersMonth'],$lc)).'</div>'.N;
$out.='<div><span class="ilab">'._('Active users (last six months)').'</span> '.nully(fnum($row['ActiveUsersHalfYear'],$lc)).'</div>'.N;
$out.='<div><span class="ilab">'._('Characters per post (max)').'</span> ';
if (nullemp(fnum($row['MaxTootChars'],0,$dlang)))
if (nullemp(fnum($row['MaxTootChars'],$lc)))
$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><span class="ilab">'._('Known instances').'</span> '.nully(fnum($row['DomainCount'],$lc)).'</div>'.N;
$out.='</div>'.N;
$out.='<div class="icol">'.N;
@ -649,7 +651,7 @@ while ($if<$il && $row=mysqli_fetch_assoc($res)) {
($row['Noxious']==1) ? $out.='<span class="ibad">'._('Yes (see why below)').'</span>' : $out.='<span class="igood">'._('No').'</span>';
$out.='</div>'.N;
$out.='<div><span class="ilab">'._('New').'</span> ';
($bt-$row['InsertTS']<=$oldline) ? $out.='<span class="ivgood">'._('Yes!').'</span>' : $out.=_('No');
($btu-$row['InsertTS']<=$oldline) ? $out.='<span class="ivgood">'._('Yes!').'</span>' : $out.=_('No');
$out.='</div>'.N;
$software='';
if (!is_null($row['Software'])) $software.=ucfirst($row['Software']);
@ -853,7 +855,7 @@ function setfedipact() {
$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__);
$res=tquery('SELECT ID, URI FROM Instances WHERE IsMastodon=1 AND Visible=1 AND LastOkCheckTS>='.$graceline.' AND URI IN ('.$fedipact['uris_me'].')', __LINE__);
$fedipact['uris']=[];
$fedipact['uris_me']=[];
while ($row=mysqli_fetch_assoc($res)) {
@ -954,9 +956,9 @@ function hrte($bt) {
function tquery($query,$line) {
global $link, $debug;
$bt=hrtime(true);
//usleep(rand(10000,100000));
//usleep(rand(10000,1050000));
$res=mysqli_query($link,$query) or muorimeglio('Error on line '.$line.': '.mysqli_error($link),true);
debug(hrte($bt).' secs. for query «'.$query.'»'.N,$debug);
debug(sprintf('%f secs. for query «'.$query.'»'.N,hrte($bt)),$debug);
return $res;
}