Made it know when among instances with a given language there’s at least one recommended instance; if so, made it use “random, recommended first” order; otherwise, made it use just “random” order; made it know to javascript too, so the first entry in the order menu gets its text changed accordingly; added a checkbox to exclude instances not blocking threads (or instances about which it is unknown if they are blocking Threads); some layout flaws fixing; some tidying of code
This commit is contained in:
parent
b2cc0f856c
commit
043ef60cf5
1 changed files with 161 additions and 115 deletions
|
@ -5,7 +5,7 @@ if (!defined('N')) {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$bt=microtime(true);
|
$bt=hrtime(true);
|
||||||
|
|
||||||
$dlanguc=strtoupper($dlang);
|
$dlanguc=strtoupper($dlang);
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ require '../lib/fnum.php';
|
||||||
|
|
||||||
use function mysqli_real_escape_string as myesc;
|
use function mysqli_real_escape_string as myesc;
|
||||||
/*$dlang='fr';
|
/*$dlang='fr';
|
||||||
$dtzbl=array('ca'=>'Europe/Madrid','en'=>'Europe/London','es'=>'Europe/Madrid','fr'=>'Europe/Paris','it'=>'Europe/Rome');
|
$dtzbl=['ca'=>'Europe/Madrid','en'=>'Europe/London','es'=>'Europe/Madrid','fr'=>'Europe/Paris','it'=>'Europe/Rome'];
|
||||||
date_default_timezone_set($dtzbl[$dlang]);*/
|
date_default_timezone_set($dtzbl[$dlang]);*/
|
||||||
|
|
||||||
$debug='';
|
$debug='';
|
||||||
|
@ -28,10 +28,10 @@ $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
|
// 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
|
// $gracetime is defined in mustard/include/gracetime.php
|
||||||
$bti=round($bt);
|
$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',$bti),gmdate('j',$bti),gmdate('Y',$bti))-$gracetime;
|
||||||
|
|
||||||
if (array_key_exists('id',$_GET) && preg_match('/^\d+$/',$_GET['id'])) {
|
if (array_key_exists('id',$_GET) && preg_match('/^\d+$/',$_GET['id'])===1) {
|
||||||
$_GET['id']+=0;
|
$_GET['id']+=0;
|
||||||
$single=true;
|
$single=true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -131,6 +131,38 @@ function sethid(obj) {
|
||||||
document.getElementById(obj).value=0;
|
document.getElementById(obj).value=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updord() {
|
||||||
|
let langsel=document.getElementById("lang"), ordsel=document.getElementById("ord");
|
||||||
|
console.log(langswri);
|
||||||
|
console.log(langsel.value);
|
||||||
|
if (langswri.indexOf(langsel.value)>=0) {
|
||||||
|
console.log("si");
|
||||||
|
ordsel.options[0].innerHTML="'._('Random, recommended first').'";
|
||||||
|
} else {
|
||||||
|
console.log("no");
|
||||||
|
ordsel.options[0].innerHTML="'._('Random').'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function nocrit() {
|
||||||
|
document.getElementById("lang").selectedIndex=0;
|
||||||
|
document.getElementById("desc").value="";
|
||||||
|
document.getElementById("minu").value="";
|
||||||
|
document.getElementById("maxu").value="";
|
||||||
|
document.getElementById("minau").value="";
|
||||||
|
document.getElementById("minc").value="";
|
||||||
|
document.getElementById("cbexnox").checked=false;
|
||||||
|
sethid("exnox");
|
||||||
|
document.getElementById("cbexregc").checked=false;
|
||||||
|
sethid("exregc");
|
||||||
|
document.getElementById("cbexthf").checked=false;
|
||||||
|
sethid("exthf");
|
||||||
|
document.getElementById("cbexappr").checked=false;
|
||||||
|
sethid("exappr");
|
||||||
|
document.getElementById("cbexlcko").checked=false;
|
||||||
|
sethid("exlcko");
|
||||||
|
}
|
||||||
|
|
||||||
function presub() {
|
function presub() {
|
||||||
document.getElementById("p").value=1;
|
document.getElementById("p").value=1;
|
||||||
if (document.getElementById("ord").value=="noxd") {
|
if (document.getElementById("ord").value=="noxd") {
|
||||||
|
@ -142,19 +174,19 @@ function presub() {
|
||||||
</script>
|
</script>
|
||||||
'.N);
|
'.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);
|
$res=tquery('SELECT COUNT(Instances.ID) AS Unknown, SUM(Instances.UserCount) AS UnknownU FROM Instances WHERE Instances.IsMastodon=1 AND Instances.Threads IS NULL AND Instances.LastOkCheckTS>='.$graceline,__LINE__);
|
||||||
$row=mysqli_fetch_assoc($res);
|
$row=mysqli_fetch_assoc($res);
|
||||||
$metastats['unknown']=['instances'=>$row['Unknown'], 'users'=>nulltozero($row['UnknownU'])];
|
$metastats['unknown']=['instances'=>$row['Unknown'], 'users'=>nulltozero($row['UnknownU'])];
|
||||||
|
|
||||||
$res=mysqli_query($link,'SELECT COUNT(Instances.ID) AS Suspending, SUM(Instances.UserCount) AS SuspendingU FROM Instances LEFT JOIN InstBlocks ON InstBlocks.InstID=Instances.ID WHERE Instances.IsMastodon=1 AND Instances.BlockListAvailable=1 AND Instances.LastOkCheckTS>='.$graceline.' AND (InstBlocks.Domain LIKE "%.threads.net" OR InstBlocks.Domain="threads.net") AND InstBlocks.Severity="suspend"') or muorimeglio(__LINE__.': '.mysqli_error($link),true);
|
$res=tquery('SELECT COUNT(Instances.ID) AS Suspending, SUM(Instances.UserCount) AS SuspendingU FROM Instances WHERE Instances.IsMastodon=1 AND Instances.Threads="suspended" AND Instances.LastOkCheckTS>='.$graceline,__LINE__);
|
||||||
$row=mysqli_fetch_assoc($res);
|
$row=mysqli_fetch_assoc($res);
|
||||||
$metastats['suspending']=['instances'=>$row['Suspending'], 'users'=>nulltozero($row['SuspendingU'])];
|
$metastats['suspending']=['instances'=>$row['Suspending'], 'users'=>nulltozero($row['SuspendingU'])];
|
||||||
|
|
||||||
$res=mysqli_query($link,'SELECT COUNT(Instances.ID) AS Silencing, SUM(Instances.UserCount) AS SilencingU FROM Instances LEFT JOIN InstBlocks ON InstBlocks.InstID=Instances.ID WHERE Instances.IsMastodon=1 AND Instances.BlockListAvailable=1 AND Instances.LastOkCheckTS>='.$graceline.' AND (InstBlocks.Domain LIKE "%.threads.net" OR InstBlocks.Domain="threads.net") AND InstBlocks.Severity="silence"') or muorimeglio(__LINE__.': '.mysqli_error($link),true);
|
$res=tquery('SELECT COUNT(Instances.ID) AS Silencing, SUM(Instances.UserCount) AS SilencingU FROM Instances WHERE Instances.IsMastodon=1 AND Instances.Threads="limited" AND Instances.LastOkCheckTS>='.$graceline,__LINE__);
|
||||||
$row=mysqli_fetch_assoc($res);
|
$row=mysqli_fetch_assoc($res);
|
||||||
$metastats['silencing']=['instances'=>$row['Silencing'], 'users'=>nulltozero($row['SilencingU'])];
|
$metastats['silencing']=['instances'=>$row['Silencing'], 'users'=>nulltozero($row['SilencingU'])];
|
||||||
|
|
||||||
$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);
|
$res=tquery('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,__LINE__);
|
||||||
$row=mysqli_fetch_assoc($res);
|
$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 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. [<a id="msswitch" onclick="swmetastats();" style="cursor:pointer;">Show Threads suspension / limitation stats</a>].</p>').N, 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 suspension / limitation stats</a>].</p>').N, fnum($row['tinsts'],0,$dlang), fnum($row['tusers'],0,$dlang), fnum($row['tactusers'],0,$dlang), fnum($row['tstatuses'],0,$dlang));
|
||||||
|
@ -163,39 +195,39 @@ function presub() {
|
||||||
'instances'=>$row['tinsts']-$metastats['unknown']['instances'],
|
'instances'=>$row['tinsts']-$metastats['unknown']['instances'],
|
||||||
'users'=>$row['tusers']-$metastats['unknown']['users'],
|
'users'=>$row['tusers']-$metastats['unknown']['users'],
|
||||||
];
|
];
|
||||||
$metastats['known']['iperc']=100/$row['tinsts']*$metastats['known']['instances'];
|
$metastats['known']['iperc']=$metastats['known']['instances']*100/$row['tinsts'];
|
||||||
$metastats['known']['uperc']=100/$row['tusers']*$metastats['known']['users'];
|
$metastats['known']['uperc']=$metastats['known']['users']*100/$row['tusers'];
|
||||||
|
|
||||||
$metastats['unknown']['iperc']=100/$row['tinsts']*$metastats['unknown']['instances'];
|
$metastats['unknown']['iperc']=$metastats['unknown']['instances']*100/$row['tinsts'];
|
||||||
$metastats['unknown']['uperc']=100/$row['tusers']*$metastats['unknown']['users'];
|
$metastats['unknown']['uperc']=$metastats['unknown']['users']*100/$row['tusers'];
|
||||||
|
|
||||||
$metastats['suspending']['iperc']=100/$row['tinsts']*$metastats['suspending']['instances'];
|
$metastats['suspending']['iperc']=$metastats['suspending']['instances']*100/$row['tinsts'];
|
||||||
$metastats['suspending']['uperc']=100/$row['tusers']*$metastats['suspending']['users'];
|
$metastats['suspending']['uperc']=$metastats['suspending']['users']*100/$row['tusers'];
|
||||||
$metastats['suspending']['kiperc']=100/$metastats['known']['instances']*$metastats['suspending']['instances'];
|
$metastats['suspending']['kiperc']=$metastats['suspending']['instances']*100/$metastats['known']['instances'];
|
||||||
$metastats['suspending']['kuperc']=100/$metastats['known']['users']*$metastats['suspending']['users'];
|
$metastats['suspending']['kuperc']=$metastats['suspending']['users']*100/$metastats['known']['users'];
|
||||||
|
|
||||||
$metastats['silencing']['iperc']=100/$row['tinsts']*$metastats['silencing']['instances'];
|
$metastats['silencing']['iperc']=$metastats['silencing']['instances']*100/$row['tinsts'];
|
||||||
$metastats['silencing']['uperc']=100/$row['tusers']*$metastats['silencing']['users'];
|
$metastats['silencing']['uperc']=$metastats['silencing']['users']*100/$row['tusers'];
|
||||||
$metastats['silencing']['kiperc']=100/$metastats['known']['instances']*$metastats['silencing']['instances'];
|
$metastats['silencing']['kiperc']=$metastats['silencing']['instances']*100/$metastats['known']['instances'];
|
||||||
$metastats['silencing']['kuperc']=100/$metastats['known']['users']*$metastats['silencing']['users'];
|
$metastats['silencing']['kuperc']=$metastats['silencing']['users']*100/$metastats['known']['users'];
|
||||||
|
|
||||||
$metastats['notsuspsil']=[
|
$metastats['notsuspsil']=[
|
||||||
'instances'=>$row['tinsts']-$metastats['unknown']['instances']-$metastats['suspending']['instances']-$metastats['silencing']['instances'],
|
'instances'=>$row['tinsts']-$metastats['unknown']['instances']-$metastats['suspending']['instances']-$metastats['silencing']['instances'],
|
||||||
'users'=>$row['tusers']-$metastats['unknown']['users']-$metastats['suspending']['users']-$metastats['silencing']['users']
|
'users'=>$row['tusers']-$metastats['unknown']['users']-$metastats['suspending']['users']-$metastats['silencing']['users']
|
||||||
];
|
];
|
||||||
$metastats['notsuspsil']['iperc']=100/$row['tinsts']*$metastats['notsuspsil']['instances'];
|
$metastats['notsuspsil']['iperc']=$metastats['notsuspsil']['instances']*100/$row['tinsts'];
|
||||||
$metastats['notsuspsil']['uperc']=100/$row['tusers']*$metastats['notsuspsil']['users'];
|
$metastats['notsuspsil']['uperc']=$metastats['notsuspsil']['users']*100/$row['tusers'];
|
||||||
$metastats['notsuspsil']['kiperc']=100/$metastats['known']['instances']*$metastats['notsuspsil']['instances'];
|
$metastats['notsuspsil']['kiperc']=$metastats['notsuspsil']['instances']*100/$metastats['known']['instances'];
|
||||||
$metastats['notsuspsil']['kuperc']=100/$metastats['known']['users']*$metastats['notsuspsil']['users'];
|
$metastats['notsuspsil']['kuperc']=$metastats['notsuspsil']['users']*100/$metastats['known']['users'];
|
||||||
|
|
||||||
$metastats['suspsil']=[
|
$metastats['suspsil']=[
|
||||||
'instances'=>$metastats['suspending']['instances']+$metastats['silencing']['instances'],
|
'instances'=>$metastats['suspending']['instances']+$metastats['silencing']['instances'],
|
||||||
'users'=>$metastats['suspending']['users']+$metastats['silencing']['users']
|
'users'=>$metastats['suspending']['users']+$metastats['silencing']['users']
|
||||||
];
|
];
|
||||||
$metastats['suspsil']['iperc']=100/$row['tinsts']*$metastats['suspsil']['instances'];
|
$metastats['suspsil']['iperc']=$metastats['suspsil']['instances']*100/$row['tinsts'];
|
||||||
$metastats['suspsil']['uperc']=100/$row['tusers']*$metastats['suspsil']['users'];
|
$metastats['suspsil']['uperc']=$metastats['suspsil']['users']*100/$row['tusers'];
|
||||||
$metastats['suspsil']['kiperc']=100/$metastats['known']['instances']*$metastats['suspsil']['instances'];
|
$metastats['suspsil']['kiperc']=$metastats['suspsil']['instances']*100/$metastats['known']['instances'];
|
||||||
$metastats['suspsil']['kuperc']=100/$metastats['known']['users']*$metastats['suspsil']['users'];
|
$metastats['suspsil']['kuperc']=$metastats['suspsil']['users']*100/$metastats['known']['users'];
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<div id="metastats" class="hiddiv">
|
'<div id="metastats" class="hiddiv">
|
||||||
|
@ -242,7 +274,6 @@ function presub() {
|
||||||
|
|
||||||
</div>'.N;
|
</div>'.N;
|
||||||
|
|
||||||
|
|
||||||
if ((array_key_exists('exnox',$_GET) && $_GET['exnox']=='1') || !array_key_exists('exnox',$_GET)) {
|
if ((array_key_exists('exnox',$_GET) && $_GET['exnox']=='1') || !array_key_exists('exnox',$_GET)) {
|
||||||
$_GET['cbexnox']=' checked';
|
$_GET['cbexnox']=' checked';
|
||||||
$_GET['exnox']=1;
|
$_GET['exnox']=1;
|
||||||
|
@ -259,6 +290,15 @@ function presub() {
|
||||||
$_GET['exregc']=0;
|
$_GET['exregc']=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if ((array_key_exists('exthf',$_GET) && $_GET['exthf']=='1') || !array_key_exists('exthf',$_GET)) {
|
||||||
|
if (array_key_exists('exthf',$_GET) && $_GET['exthf']=='1') {
|
||||||
|
$_GET['cbexthf']=' checked';
|
||||||
|
$_GET['exthf']=1;
|
||||||
|
} else {
|
||||||
|
$_GET['cbexthf']='';
|
||||||
|
$_GET['exthf']=0;
|
||||||
|
}
|
||||||
|
|
||||||
if (array_key_exists('exappr',$_GET) && $_GET['exappr']=='1') {
|
if (array_key_exists('exappr',$_GET) && $_GET['exappr']=='1') {
|
||||||
$_GET['cbexappr']=' checked';
|
$_GET['cbexappr']=' checked';
|
||||||
$_GET['exappr']=1;
|
$_GET['exappr']=1;
|
||||||
|
@ -281,7 +321,7 @@ function presub() {
|
||||||
else
|
else
|
||||||
$_GET['lang']=0;
|
$_GET['lang']=0;
|
||||||
} else {
|
} else {
|
||||||
$res=mysqli_query($link,'SELECT ID FROM Languages WHERE Code="'.$dlang.'"') or muorimeglio(__LINE__.': '.mysqli_error($link),true);
|
$res=tquery('SELECT ID FROM Languages WHERE Code="'.myesc($link,$dlang).'"',__LINE__);
|
||||||
if (mysqli_num_rows($res)>0) {
|
if (mysqli_num_rows($res)>0) {
|
||||||
$row=mysqli_fetch_assoc($res);
|
$row=mysqli_fetch_assoc($res);
|
||||||
$_GET['lang']=$row['ID'];
|
$_GET['lang']=$row['ID'];
|
||||||
|
@ -303,27 +343,33 @@ function presub() {
|
||||||
ckgnum('minau',$minaudef,$minaumax);
|
ckgnum('minau',$minaudef,$minaumax);
|
||||||
ckgnum('minc',$mincdef,$mincmax);
|
ckgnum('minc',$mincdef,$mincmax);
|
||||||
|
|
||||||
$order=array(
|
$order=[
|
||||||
'rand'=>array('t'=>_('Random, recommended first'),'q'=>'Instances.Priority DESC, Instances.RPos ASC'),
|
'rand'=>['t'=>_('Random'), 'q'=>'Instances.RPos ASC'],
|
||||||
'invold'=>array('t'=>_('By users’ involvement (active users / users), descending'),'q'=>'(Instances.ActiveUsersMonth / Instances.UserCount) DESC'),
|
'invold'=>['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'),
|
'invola'=>['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'),
|
'fseend'=>['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'),
|
'fseena'=>['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'),
|
'tusersd'=>['t'=>_('By number of users, descending'), 'q'=>'Instances.UserCount DESC'],
|
||||||
'tusersa'=>array('t'=>_('By number of users, ascending'),'q'=>'Instances.UserCount ASC'),
|
'tusersa'=>['t'=>_('By number of users, ascending'), 'q'=>'Instances.UserCount ASC'],
|
||||||
'ausersd'=>array('t'=>_('By number of active users, descending'),'q'=>'Instances.ActiveUsersMonth DESC'),
|
'ausersd'=>['t'=>_('By number of active users, descending'), 'q'=>'Instances.ActiveUsersMonth DESC'],
|
||||||
'ausersa'=>array('t'=>_('By number of active users, ascending'),'q'=>'Instances.ActiveUsersMonth ASC'),
|
'ausersa'=>['t'=>_('By number of active users, ascending'), 'q'=>'Instances.ActiveUsersMonth ASC'],
|
||||||
'checksd'=>array('t'=>_('By responsiveness to our checks, descending'),'q'=>'(Instances.OkChecks / Instances.TotChecks) DESC, Instances.TotChecks DESC'),
|
'checksd'=>['t'=>_('By responsiveness to our checks, descending'), 'q'=>'(Instances.OkChecks / Instances.TotChecks) DESC, Instances.TotChecks DESC'],
|
||||||
'checksa'=>array('t'=>_('By responsiveness to our checks, ascending'),'q'=>'(Instances.OkChecks / Instances.TotChecks) ASC, Instances.TotChecks ASC'),
|
'checksa'=>['t'=>_('By responsiveness to our checks, ascending'), 'q'=>'(Instances.OkChecks / Instances.TotChecks) ASC, Instances.TotChecks ASC'],
|
||||||
'charsd'=>array('t'=>_('By available characters per post, descending'),'q'=>'Instances.MaxTootChars DESC'),
|
'charsd'=>['t'=>_('By available characters per post, descending'), 'q'=>'Instances.MaxTootChars DESC'],
|
||||||
'charsa'=>array('t'=>_('By available characters per post, ascending'),'q'=>'Instances.MaxTootChars ASC'),
|
'charsa'=>['t'=>_('By available characters per post, ascending'), 'q'=>'Instances.MaxTootChars ASC'],
|
||||||
'noxd'=>array('t'=>_('Noxious first (switches off “Exclude noxious”)'),'q'=>'Instances.Noxious DESC')
|
'noxd'=>['t'=>_('Noxious first (switches off “Exclude noxious”)'), 'q'=>'Instances.Noxious DESC']
|
||||||
);
|
];
|
||||||
if (!array_key_exists('ord',$_GET) || !array_key_exists($_GET['ord'],$order))
|
if (!array_key_exists('ord',$_GET) || !array_key_exists($_GET['ord'],$order))
|
||||||
$_GET['ord']='rand';
|
$_GET['ord']='rand';
|
||||||
// we have recommended instances only for it language, so...
|
// $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__);
|
||||||
$withreclangids=[306];
|
$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__);
|
||||||
if (!in_array($_GET['lang'],$withreclangids)) $order['rand']=array('t'=>_('Random'),'q'=>'Instances.RPos ASC');
|
$langswri=[];// langs with recommended instances
|
||||||
|
while ($row=mysqli_fetch_assoc($res))
|
||||||
|
$langswri[]=$row['OurLangID'];
|
||||||
|
if (count($langswri)>0)
|
||||||
|
array_unshift($langswri,0);
|
||||||
|
if (in_array($_GET['lang'],$langswri))
|
||||||
|
$order['rand']=['t'=>_('Random, recommended first'), 'q'=>'Instances.Priority DESC, Instances.RPos ASC'];
|
||||||
|
|
||||||
$p=1;
|
$p=1;
|
||||||
if (array_key_exists('p',$_GET) && preg_match('#^[0-9]+$#',$_GET['p'])===1) $p=$_GET['p']+0;
|
if (array_key_exists('p',$_GET) && preg_match('#^[0-9]+$#',$_GET['p'])===1) $p=$_GET['p']+0;
|
||||||
|
@ -334,6 +380,7 @@ function presub() {
|
||||||
<input name="exregc" type="hidden" value="'.$_GET['exregc'].'">
|
<input name="exregc" type="hidden" value="'.$_GET['exregc'].'">
|
||||||
<input name="exappr" type="hidden" value="'.$_GET['exappr'].'">
|
<input name="exappr" type="hidden" value="'.$_GET['exappr'].'">
|
||||||
<input name="exlcko" type="hidden" value="'.$_GET['exlcko'].'">
|
<input name="exlcko" type="hidden" value="'.$_GET['exlcko'].'">
|
||||||
|
<input name="exthf" type="hidden" value="'.$_GET['exthf'].'">
|
||||||
<input name="lang" type="hidden" value="'.$_GET['lang'].'">
|
<input name="lang" type="hidden" value="'.$_GET['lang'].'">
|
||||||
<input name="desc" type="hidden" value="'.htmlentities($_GET['desc']).'">
|
<input name="desc" type="hidden" value="'.htmlentities($_GET['desc']).'">
|
||||||
<input name="minu" type="hidden" value="'.$_GET['minu'].'">
|
<input name="minu" type="hidden" value="'.$_GET['minu'].'">
|
||||||
|
@ -345,26 +392,28 @@ function presub() {
|
||||||
</form>'.N);
|
</form>'.N);
|
||||||
|
|
||||||
($_GET['lang']==0) ? $selected=' selected' : $selected='';
|
($_GET['lang']==0) ? $selected=' selected' : $selected='';
|
||||||
|
echo '<form method="get" id="searchf" class="sdbox" onsubmit="presub();">
|
||||||
echo('<form method="get" id="searchf" class="sdbox" onsubmit="presub();">
|
|
||||||
<div class="sdtit">'._('Search criteria').'</div>
|
<div class="sdtit">'._('Search criteria').'</div>
|
||||||
<div class="sddesc">'._('Show instances where...').'</div>
|
<div class="sddesc">'._('Show instances where...').'</div>
|
||||||
<div class="sdrow">
|
<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>
|
<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>
|
||||||
<div class="sdinput">
|
<div class="sdinput">
|
||||||
<select id="lang" name="lang" class="sselect">
|
<select id="lang" name="lang" class="sselect" onchange="updord();">
|
||||||
<option value="0"'.$selected.'>'._('Irrelevant').'</option>'.N);
|
<option value="0"'.$selected.'>'._('Irrelevant').'</option>'.N;
|
||||||
|
|
||||||
$res=mysqli_query($link,'SELECT Languages.ID AS Lid, CONCAT(Name'.$dlanguc.', \' [\', Code, \'] (\', COUNT(Languages.ID), \')\') AS Txt FROM InstOurLangs LEFT JOIN Languages ON Languages.ID=OurLangID LEFT JOIN Instances ON Instances.ID=InstOurLangs.InstID WHERE Instances.IsMastodon=1 AND Instances.LastOkCheckTS>='.$graceline.' AND InstOurLangs.Pos=1 GROUP BY Languages.ID ORDER BY Name'.$dlanguc.' ASC') or muorimeglio(__LINE__.': '.mysqli_error($link),true);
|
$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__);
|
||||||
|
|
||||||
while ($row=mysqli_fetch_assoc($res)) {
|
while ($row=mysqli_fetch_assoc($res)) {
|
||||||
($_GET['lang']==$row['Lid']) ? $selected=' selected' : $selected='';
|
($_GET['lang']==$row['Lid']) ? $selected=' selected' : $selected='';
|
||||||
echo('<option value="'.$row['Lid'].'"'.$selected.'>'.$row['Txt'].'</option>'.N);
|
echo '<option value="'.$row['Lid'].'"'.$selected.'>'.$row['Txt'].'</option>'.N;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo('</select>
|
echo '</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script language="JavaScript">
|
||||||
|
let langswri=["'.implode('","',$langswri).'"];
|
||||||
|
</script>
|
||||||
<div class="sdrow">
|
<div class="sdrow">
|
||||||
<div class="sdlabel"><label for="desc" title="'._('Include only instances whose URI, name or description (short or long) contains the specified expression').'">'._('URI, name or descriptions contain').'</label></div>
|
<div class="sdlabel"><label for="desc" title="'._('Include only instances whose URI, name or description (short or long) contains the specified expression').'">'._('URI, name or descriptions contain').'</label></div>
|
||||||
<div class="sdinput"><input type="text" id="desc" name="desc" class="sinput" maxlength="64" value="'.hspech($_GET['desc']).'" autofocus></div>
|
<div class="sdinput"><input type="text" id="desc" name="desc" class="sinput" maxlength="64" value="'.hspech($_GET['desc']).'" autofocus></div>
|
||||||
|
@ -402,6 +451,13 @@ function presub() {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="sdrow">
|
<div class="sdrow">
|
||||||
|
<div class="sdlabel"><label for="cbexthf" title="'._('Exclude instances which might not be <i>suspending</i> Meta’s Threads').'">'._('Exclude if might not be <i>suspending</i> Threads').'</label></div>
|
||||||
|
<div class="sdinput">
|
||||||
|
<input type="checkbox" class="sckbox" id="cbexthf" value="1"'.$_GET['cbexthf'].' onchange="sethid(\'exthf\');">
|
||||||
|
<input type="hidden" id="exthf" name="exthf" value="'.$_GET['exthf'].'">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="sdrow">
|
||||||
<div class="sdlabel"><label for="cbexappr" title="'._('Exclude instances on which admin approval is required for registration').'">'._('Exclude if registration requires approval').'</label></div>
|
<div class="sdlabel"><label for="cbexappr" title="'._('Exclude instances on which admin approval is required for registration').'">'._('Exclude if registration requires approval').'</label></div>
|
||||||
<div class="sdinput">
|
<div class="sdinput">
|
||||||
<input type="checkbox" class="sckbox" id="cbexappr" value="1"'.$_GET['cbexappr'].' onchange="sethid(\'exappr\');">
|
<input type="checkbox" class="sckbox" id="cbexappr" value="1"'.$_GET['cbexappr'].' onchange="sethid(\'exappr\');">
|
||||||
|
@ -419,10 +475,10 @@ function presub() {
|
||||||
<div class="sdtitb">'._('Order of results').'</div>
|
<div class="sdtitb">'._('Order of results').'</div>
|
||||||
|
|
||||||
<div class="sdcrow">
|
<div class="sdcrow">
|
||||||
<select id="ord" name="ord" class="sselect100">'.N);
|
<select id="ord" name="ord" class="sselect100">'.N;
|
||||||
foreach ($order as $key=>$buf) {
|
foreach ($order as $key=>$buf) {
|
||||||
($key!=$_GET['ord']) ? $selected='' : $selected=' selected';
|
($key!=$_GET['ord']) ? $selected='' : $selected=' selected';
|
||||||
echo('<option value="'.$key.'"'.$selected.'>'.$buf['t'].'</option>'.N);
|
echo '<option value="'.$key.'"'.$selected.'>'.$buf['t'].'</option>'.N;
|
||||||
}
|
}
|
||||||
echo('</select>
|
echo('</select>
|
||||||
</div>
|
</div>
|
||||||
|
@ -431,8 +487,12 @@ function presub() {
|
||||||
<input type="submit" value="'._('Search').'" class="ssubmit">
|
<input type="submit" value="'._('Search').'" class="ssubmit">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="sdcrow">
|
||||||
|
<input type="button" class="litbut" value="'._('Set criteria to include all instances').'" onclick="nocrit();">
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="sdlcrow">
|
<div class="sdlcrow">
|
||||||
<input type="button" class="litbut" value="'._('Reset search').'" onclick="document.location.href=document.location.href.replace(/\\?.*$/,\'\')">
|
<input type="button" class="litbut" value="'._('Reset to default criteria').'" onclick="document.location.href=document.location.href.replace(/\\?.*$/,\'\');">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="hidden" id="p" name="p" value="'.$p.'">
|
<input type="hidden" id="p" name="p" value="'.$p.'">
|
||||||
|
@ -442,8 +502,8 @@ function presub() {
|
||||||
swhelp();
|
swhelp();
|
||||||
</script>'.N);
|
</script>'.N);
|
||||||
|
|
||||||
$joins=array();
|
$joins=[];
|
||||||
$wheres=array();
|
$wheres=[];
|
||||||
$wheres[]='Instances.IsMastodon=1 AND Instances.LastOkCheckTS>='.$graceline;
|
$wheres[]='Instances.IsMastodon=1 AND Instances.LastOkCheckTS>='.$graceline;
|
||||||
if ($_GET['exnox']==1) $wheres[]='Instances.Noxious=0';
|
if ($_GET['exnox']==1) $wheres[]='Instances.Noxious=0';
|
||||||
if ($_GET['exregc']==1) $wheres[]='Instances.RegOpen=1';
|
if ($_GET['exregc']==1) $wheres[]='Instances.RegOpen=1';
|
||||||
|
@ -453,6 +513,7 @@ 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['exthf']==1) $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)';
|
||||||
|
@ -468,10 +529,8 @@ function presub() {
|
||||||
$que='SELECT * FROM Instances '.$joins.' '.$wheres.' ORDER BY '.$order[$_GET['ord']]['q'];
|
$que='SELECT * FROM Instances '.$joins.' '.$wheres.' ORDER BY '.$order[$_GET['ord']]['q'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$debug.='QUERY: «'.$que.'»'.N;
|
$debug.='MAIN QUERY: «'.$que.'»'.N;
|
||||||
$qbt=microtime(true);
|
$res=tquery($que,__LINE__);
|
||||||
$res=mysqli_query($link,$que) or muorimeglio(__LINE__.': '.mysqli_error($link),true);
|
|
||||||
$debug.='MAIN QUERY EXEC TIME: '.(microtime(true)-$qbt).' sec.'.N;
|
|
||||||
$itot=mysqli_num_rows($res);
|
$itot=mysqli_num_rows($res);
|
||||||
$debug.='RESULTS: '.$itot.N;
|
$debug.='RESULTS: '.$itot.N;
|
||||||
/*if ($itot==0) {
|
/*if ($itot==0) {
|
||||||
|
@ -485,15 +544,8 @@ if ($if>=$itot) {
|
||||||
$if=0;
|
$if=0;
|
||||||
$p=1;
|
$p=1;
|
||||||
}
|
}
|
||||||
$il=$if+$ipp;
|
$ptot=ceil($itot/$ipp);
|
||||||
|
($p!=$ptot) ? $il=$if+$ipp : $il=$itot;
|
||||||
function tquery($query,$line) {
|
|
||||||
global $link, $debug;
|
|
||||||
$bt=microtime(true);
|
|
||||||
$res=mysqli_query($link,$query) or muorimeglio($line.': '.mysqli_error($link),true);
|
|
||||||
$debug.=(microtime(true)-$bt).' secs. for query «'.$query.'»'.N;
|
|
||||||
return($res);
|
|
||||||
}
|
|
||||||
|
|
||||||
$dfmt=datefmt_create($blang,IntlDateFormatter::MEDIUM,IntlDateFormatter::NONE,'UTC',IntlDateFormatter::GREGORIAN);
|
$dfmt=datefmt_create($blang,IntlDateFormatter::MEDIUM,IntlDateFormatter::NONE,'UTC',IntlDateFormatter::GREGORIAN);
|
||||||
$defmt=datefmt_create($blang,IntlDateFormatter::SHORT,IntlDateFormatter::MEDIUM,'UTC',IntlDateFormatter::GREGORIAN);
|
$defmt=datefmt_create($blang,IntlDateFormatter::SHORT,IntlDateFormatter::MEDIUM,'UTC',IntlDateFormatter::GREGORIAN);
|
||||||
|
@ -507,9 +559,8 @@ while ($if<$il && $row=mysqli_fetch_assoc($res)) {
|
||||||
if (!$single) $out.=' <a href="'.$conf['instpath'].'/instances?id='.$row['ID'].'" title="'._('Direct link to this instance’s card').'">('.$if.'/'.$itot.')</a>';
|
if (!$single) $out.=' <a href="'.$conf['instpath'].'/instances?id='.$row['ID'].'" title="'._('Direct link to this instance’s 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;
|
||||||
$qbt=microtime(true);
|
|
||||||
$rres=tquery('SELECT CONCAT(Languages.Name'.$dlanguc.'," (",Languages.Code,")") AS Lang FROM InstOurLangs LEFT JOIN Languages ON Languages.ID=InstOurLangs.OurLangID WHERE InstOurLangs.InstID='.$row['ID'].' ORDER BY InstOurLangs.Pos ASC',__LINE__);
|
$rres=tquery('SELECT CONCAT(Languages.Name'.$dlanguc.'," (",Languages.Code,")") AS Lang FROM InstOurLangs LEFT JOIN Languages ON Languages.ID=InstOurLangs.OurLangID WHERE InstOurLangs.InstID='.$row['ID'].' ORDER BY InstOurLangs.Pos ASC',__LINE__);
|
||||||
$buf=array();
|
$buf=[];
|
||||||
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'];
|
||||||
|
@ -576,38 +627,20 @@ while ($if<$il && $row=mysqli_fetch_assoc($res)) {
|
||||||
$out.='</div>'.N;
|
$out.='</div>'.N;
|
||||||
|
|
||||||
$out.='<div><span class="ilab">'._('Meta’s Threads moderation').'</span> ';
|
$out.='<div><span class="ilab">'._('Meta’s Threads moderation').'</span> ';
|
||||||
if ($row['BlockListAvailable']==1) {
|
if (is_null($row['Threads']))
|
||||||
$mmres=tquery('SELECT Domain, Severity, Comment FROM InstBlocks WHERE InstID='.$row['ID'],__LINE__);
|
$out.=_('Threads is neither suspended nor limited');
|
||||||
if (mysqli_num_rows($mmres)>0) {
|
elseif ($row['Threads']=='suspended')
|
||||||
$tm=false;// tmk: threads moderation
|
|
||||||
while ($rrow=mysqli_fetch_assoc($mmres)) {
|
|
||||||
if (preg_match('#^(threads.net|.*\.threads.net)$#i',$rrow['Domain'])==1) {
|
|
||||||
if ($rrow['Severity']=='suspend')
|
|
||||||
$out.=_('Threads is suspended');
|
$out.=_('Threads is suspended');
|
||||||
elseif ($rrow['Severity']=='silence')
|
elseif ($row['Threads']=='limited')
|
||||||
$out.=_('Threads is limited');
|
$out.=_('Threads is limited');
|
||||||
else
|
else
|
||||||
$out.=_('Unknown value').': «'.htmlentities($rrow['Severity']).'»';
|
$out.=_('Unknown').': «'.htmlentities($row['Threads']).'»';
|
||||||
$tm=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!$tm)
|
|
||||||
$out.=_('Threads is neither suspended nor limited');
|
|
||||||
} else {
|
|
||||||
$out.=_('Threads is neither suspended nor limited');
|
|
||||||
$mmres=false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$out.='<span class="null">'._('Unknown (moderated servers list is unaccessible)').'</span>';
|
|
||||||
$mmres=false;
|
|
||||||
}
|
|
||||||
$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> ';
|
||||||
$rres=tquery('SELECT * FROM InstTrends WHERE InstID='.$row['ID'].' ORDER BY Pos ASC',__LINE__);
|
$rres=tquery('SELECT * FROM InstTrends WHERE InstID='.$row['ID'].' ORDER BY Pos ASC',__LINE__);
|
||||||
if (mysqli_num_rows($rres)>0) {
|
if (mysqli_num_rows($rres)>0) {
|
||||||
$buf=array();
|
$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']).'">'.hspech($rrow['Name']).'</a>';
|
||||||
$out.=implode(', ',$buf);
|
$out.=implode(', ',$buf);
|
||||||
|
@ -637,9 +670,10 @@ while ($if<$il && $row=mysqli_fetch_assoc($res)) {
|
||||||
|
|
||||||
$out.='<div><div class="idlab">'._('Moderated servers').'</div><div class="idesc">';
|
$out.='<div><div class="idlab">'._('Moderated servers').'</div><div class="idesc">';
|
||||||
$sevmap=['silence'=>_('limited'), 'suspend'=>_('sospeso')];
|
$sevmap=['silence'=>_('limited'), 'suspend'=>_('sospeso')];
|
||||||
if ($mmres!=false) {
|
$rres=tquery('SELECT Domain, Severity, Comment FROM InstBlocks WHERE InstID='.$row['ID'],__LINE__);
|
||||||
|
if (mysqli_num_rows($rres)>0) {
|
||||||
$out.='<ul class="nobott">'.N;
|
$out.='<ul class="nobott">'.N;
|
||||||
while ($rrow=mysqli_fetch_assoc($mmres)) {
|
while ($rrow=mysqli_fetch_assoc($rres)) {
|
||||||
$out.='<li><strong>'.hspech($rrow['Domain']).'</strong>: '.$sevmap[$rrow['Severity']];
|
$out.='<li><strong>'.hspech($rrow['Domain']).'</strong>: '.$sevmap[$rrow['Severity']];
|
||||||
if (!is_null($rrow['Comment'])) $out.=' - '.hspech($rrow['Comment']);// no strip, do hspech, because moredated server comments don’t support html nor markdown in mastodon
|
if (!is_null($rrow['Comment'])) $out.=' - '.hspech($rrow['Comment']);// no strip, do hspech, because moredated server comments don’t support html nor markdown in mastodon
|
||||||
$out.='</li>'.N;
|
$out.='</li>'.N;
|
||||||
|
@ -686,7 +720,7 @@ while ($if<$il && $row=mysqli_fetch_assoc($res)) {
|
||||||
|
|
||||||
$rres=tquery('SELECT * FROM InstChecks WHERE InstID='.$row['ID'].' ORDER BY Time DESC LIMIT 0,8',__LINE__);
|
$rres=tquery('SELECT * FROM InstChecks WHERE InstID='.$row['ID'].' ORDER BY Time DESC LIMIT 0,8',__LINE__);
|
||||||
$tot=mysqli_num_rows($rres);
|
$tot=mysqli_num_rows($rres);
|
||||||
$buf=array();
|
$buf=[];
|
||||||
while ($rrow=mysqli_fetch_assoc($rres)) $buf[]=$rrow;
|
while ($rrow=mysqli_fetch_assoc($rres)) $buf[]=$rrow;
|
||||||
$out.='<div class="dida">'._('Last checks (green: OK; red: KO)').'</div><table class="cbar"><tr>';
|
$out.='<div class="dida">'._('Last checks (green: OK; red: KO)').'</div><table class="cbar"><tr>';
|
||||||
for ($i=$tot-1; $i>=0; $i--) {
|
for ($i=$tot-1; $i>=0; $i--) {
|
||||||
|
@ -695,7 +729,7 @@ while ($if<$il && $row=mysqli_fetch_assoc($res)) {
|
||||||
$out.='>'.datefmt_format($defmt,$buf[$i]['Time']).' UTC</td>';
|
$out.='>'.datefmt_format($defmt,$buf[$i]['Time']).' UTC</td>';
|
||||||
}
|
}
|
||||||
$out.='</tr></table>'.N;
|
$out.='</tr></table>'.N;
|
||||||
$out.='<div class="dida100">'._('Succesful checks').': '.$row['OkChecks'].'/'.$row['TotChecks'].' ('.round(100 / $row['TotChecks'] * $row['OkChecks'], 2).'%)</div>'.N;
|
$out.='<div class="dida100">'._('Succesful checks').': '.$row['OkChecks'].'/'.$row['TotChecks'].' ('.round($row['OkChecks']*100/$row['TotChecks'], 2).'%)</div>'.N;
|
||||||
|
|
||||||
$out.='</div></div>'.N;
|
$out.='</div></div>'.N;
|
||||||
|
|
||||||
|
@ -706,7 +740,6 @@ mysqli_close($link);
|
||||||
|
|
||||||
echo('</section>'.N);
|
echo('</section>'.N);
|
||||||
|
|
||||||
$ptot=ceil($itot/$ipp);
|
|
||||||
if ($ptot>1) {
|
if ($ptot>1) {
|
||||||
echo('<div id="footmarg"></div>'.N);
|
echo('<div id="footmarg"></div>'.N);
|
||||||
echo('<div id="bmenu">'.N);
|
echo('<div id="bmenu">'.N);
|
||||||
|
@ -737,7 +770,7 @@ if ($ptot>1) {
|
||||||
echo('</div>'.N);
|
echo('</div>'.N);
|
||||||
echo('</div>'.N);
|
echo('</div>'.N);
|
||||||
|
|
||||||
$debug.='TOTAL RENDERING TIME: '.(microtime(true)-$bt).N;
|
$debug.='TOTAL RENDERING TIME: '.hrte($bt).N;
|
||||||
if (array_key_exists('debug',$_GET) && $_GET['debug']=='1') echo('<!--'.N.'--- DEBUG INFO ---'.N.$debug.'//-->'.N);
|
if (array_key_exists('debug',$_GET) && $_GET['debug']=='1') echo('<!--'.N.'--- DEBUG INFO ---'.N.$debug.'//-->'.N);
|
||||||
|
|
||||||
|
|
||||||
|
@ -758,8 +791,8 @@ function ckgnum($key,$def,$max) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function nullemp($inp) {
|
function nullemp($inp) {
|
||||||
if (is_null($inp) || preg_match('/^\s*$/',$inp)===1) return(true);
|
if (is_null($inp) || preg_match('/^\s*$/',$inp)===1) return true;
|
||||||
return(false);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function nulltozero($inp) {
|
function nulltozero($inp) {
|
||||||
|
@ -769,7 +802,7 @@ function nulltozero($inp) {
|
||||||
|
|
||||||
function hspech($str) {
|
function hspech($str) {
|
||||||
if (nullemp($str)) return(null);
|
if (nullemp($str)) return(null);
|
||||||
return(htmlspecialchars($str,ENT_QUOTES|ENT_HTML5,'UTF-8'));
|
return htmlspecialchars($str,ENT_QUOTES|ENT_HTML5,'UTF-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
function muorimeglio($msg,$close) {
|
function muorimeglio($msg,$close) {
|
||||||
|
@ -784,14 +817,14 @@ function nully($str) {
|
||||||
// "Not available" in singular form - translators, please omit "{singular}" from translation,
|
// "Not available" in singular form - translators, please omit "{singular}" from translation,
|
||||||
// it's there just to diversify this "Not available" from the next one
|
// it's there just to diversify this "Not available" from the next one
|
||||||
if (nullemp($str)) return('<span class="null">'._('Not available{singular}').'</span>');
|
if (nullemp($str)) return('<span class="null">'._('Not available{singular}').'</span>');
|
||||||
return($str);
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
function nullyp($str) {
|
function nullyp($str) {
|
||||||
// "Not available" in plural form - translators, please omit "{plural}" from translation,
|
// "Not available" in plural form - translators, please omit "{plural}" from translation,
|
||||||
// it's there just to diversify this "Not available" from the previous one
|
// it's there just to diversify this "Not available" from the previous one
|
||||||
if (nullemp($str)) return('<span class="null">'._('Not available{plural}').'</span>');
|
if (nullemp($str)) return('<span class="null">'._('Not available{plural}').'</span>');
|
||||||
return($str);
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
function strip($str,$uri) {
|
function strip($str,$uri) {
|
||||||
|
@ -810,7 +843,20 @@ function strip($str,$uri) {
|
||||||
$str=preg_replace('#(</p>|</ol>|</ul>|</div>)#i','$1'.N,$str);// now add a newline after every </p> and so on
|
$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=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);
|
$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);
|
return $str;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hrte($bt) {
|
||||||
|
return bcdiv(bcsub(hrtime(true),$bt,9),1000000000,9);
|
||||||
|
}
|
||||||
|
|
||||||
|
function tquery($query,$line) {
|
||||||
|
global $link, $debug;
|
||||||
|
$bt=hrtime(true);
|
||||||
|
//usleep(rand(10000,100000));
|
||||||
|
$res=mysqli_query($link,$query) or muorimeglio('Error on line '.$line.': '.mysqli_error($link),true);
|
||||||
|
$debug.=hrte($bt).' secs. for query «'.$query.'»'.N;
|
||||||
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue