MastodonHelp/web/site/instances.php

556 lines
27 KiB
PHP
Raw Normal View History

2020-10-13 08:21:26 +02:00
<?php
use function mysqli_real_escape_string as myesc;
/*$dlang='fr';
$dtzbl=array('ca'=>'Europe/Madrid','en'=>'Europe/London','es'=>'Europe/Madrid','fr'=>'Europe/Paris','it'=>'Europe/Rome');
date_default_timezone_set($dtzbl[$dlang]);*/
$debug='';
$debug.='REQUEST_URI: '.$_SERVER['REQUEST_URI'].N;
$debug.='_GET: '.print_r($_GET,1);
$debug.='LOCALE: '.$locale.N;
2020-10-15 09:59:36 +02:00
$getc=count($_GET);
2020-10-13 08:21:26 +02:00
if (array_key_exists('advc',$_GET)) {
($_GET['advc']=='1') ? $_GET['advc']=1 : $_GET['advc']=0;
} else {
$_GET['advc']=0;
}
2020-10-27 16:32:23 +01:00
echo('</nav>
<div id="bmenu"></div>
<div class="scrwide">
<div class="scrwidein">
<section class="sectcontm">
<img src="'.$prepath.'imgs/helpbutti.svg" id="helpbutt" class="helpb" onmouseover="swhelpi(true);" onmouseout="swhelpi(false);" onclick="swhelp();">
2020-10-23 19:00:43 +02:00
<h3>'._('Instances').'</h3>
2020-10-22 17:54:05 +02:00
<script language="JavaScript">
2020-10-22 21:12:13 +02:00
let dbgsh=false;
2020-10-13 08:21:26 +02:00
function shdbg() {
2020-10-22 21:12:13 +02:00
let dbgd=document.getElementById(\'debug\');
let dbgb=document.getElementById(\'dbgb\');
2020-10-13 08:21:26 +02:00
if (dbgsh) {
dbgd.style.display=\'none\';
dbgb.className=\'litbut\';
dbgsh=false;
} else {
dbgd.style.display=\'block\';
dbgb.className=\'litbuta\';
dbgsh=true;
}
}
2020-10-22 21:12:13 +02:00
let mctrlsh=false;
2020-10-13 08:21:26 +02:00
function shmctrl() {
2020-10-22 21:12:13 +02:00
let mctrl=document.getElementById(\'mctrl\');
let mctrlb=document.getElementById(\'mctrlb\');
let advc=document.getElementById(\'advc\');
2020-10-13 08:21:26 +02:00
if (mctrlsh) {
mctrl.style.display=\'none\';
mctrlb.className=\'litbut\';
2020-10-23 19:00:43 +02:00
mctrlb.value=\''._('Show advanced criteria').'\';
2020-10-13 08:21:26 +02:00
advc.value=0;
mctrlsh=false;
} else {
mctrl.style.display=\'block\';
mctrlb.className=\'litbuta\';
2020-10-23 19:00:43 +02:00
mctrlb.value=\''._('Hide advanced criteria').'\';
2020-10-13 08:21:26 +02:00
advc.value=1;
mctrlsh=true;
}
}
2020-10-22 21:12:13 +02:00
let helpsh='.(($getc==0) ? 'false' : 'true').';
2020-10-22 17:54:05 +02:00
function swhelp() {
2020-10-22 21:12:13 +02:00
let hdiv=document.getElementById(\'help\');
let himg=document.getElementById(\'helpbutt\');
2020-10-22 17:54:05 +02:00
if (helpsh) {
hdiv.style.display=\'none\';
2020-10-23 19:00:43 +02:00
himg.title=\''._('Show introduction').'\';
2020-10-22 21:12:13 +02:00
himg.src=\''.$prepath.'imgs/helpbutti.svg\';
2020-10-22 17:54:05 +02:00
helpsh=false;
} else {
hdiv.style.display=\'block\';
2020-10-23 19:00:43 +02:00
himg.title=\''._('Hide introduction').'\';
2020-10-22 21:12:13 +02:00
himg.src=\''.$prepath.'imgs/helpbutta.svg\';
2020-10-22 17:54:05 +02:00
helpsh=true;
}
}
2020-10-22 21:12:13 +02:00
function swhelpi(over) {
let himg=document.getElementById(\'helpbutt\'), ia;
if (helpsh)
(over) ? ia=\'i\' : ia=\'a\';
else
(over) ? ia=\'a\' : ia=\'i\';
himg.src=\''.$prepath.'imgs/helpbutt\'+ia+\'.svg\';
}
2020-10-22 17:54:05 +02:00
</script>
'.N);
2020-10-13 08:21:26 +02:00
function nullemp($inp) {
if (is_null($inp) || preg_match('/^\s*$/',$inp)===1) return(true);
return(false);
}
function ldate($ts,$dateonly=false) {
if (nullemp($ts)) return(null);
if (!$dateonly)
return(gmdate('d/m/Y H:i:s e',$ts));
else
return(gmdate('d/m/Y',$ts));
}
function hspech($str) {
if (nullemp($str)) return(null);
return(htmlspecialchars($str,ENT_QUOTES|ENT_HTML5,'UTF-8'));
}
function muorimeglio($msg,$close) {
global $link;
if ($close)
mysqli_close($link);
echo('<p>'.$msg.'</p>'.N.'</section>'.N.'</div>'.N.'</div>'.N.'</body>'.N);
exit(2);
}
function nully($str) {
2020-10-23 19:00:43 +02:00
// "Not available" in singular form - translators, please omit "{singular}" from translation,
// it's there just to diversify this "Not available" from the next one
if (nullemp($str)) return('<span class="null">'._('Not available{singular}').'</span>');
2020-10-13 08:21:26 +02:00
return($str);
}
2020-10-17 21:23:09 +02:00
function nullyp($str) {
2020-10-23 19:00:43 +02:00
// "Not available" in plural form - translators, please omit "{plural}" from translation,
// it's there just to diversify this "Not available" from the previous one
if (nullemp($str)) return('<span class="null">'._('Not available{plural}').'</span>');
2020-10-17 21:23:09 +02:00
return($str);
}
2020-10-13 08:21:26 +02:00
function strip($str,$uri) {
if (nullemp($str)) return(null);
while (preg_match('#^\s*<br\s*[\\\/]?>#',$str)===1) $str=preg_replace('#^\s*<br\s*[\\\/]?>#','',$str);
while (preg_match('#<br\s*[\\\/]?>\s*$#',$str)===1) $str=preg_replace('#<br\s*[\\\/]?>\s*$#','',$str);
while (preg_match('#<br\s*[\\\/]?>\s*<br\s*[\\\/]?>#s',$str)===1)
$str=preg_replace('#<br\s*[\\\/]?>\s*<br\s*[\\\/]?>#s','<br>',$str);
$str=preg_replace('#<style( [^>]*)?>.*</style>#s','',$str);
$str=preg_replace('#<a href="(?![a-zA-Z]+://)([^"]+)#','<a href="https://'.$uri.'$1>',$str);
$str=preg_replace('#<h[1-9][^>]*>#','<p><strong>',$str);
$str=preg_replace('#</h[1-9]>#','</strong></p>',$str);
$str=preg_replace(array('#</p><br>#','#</li><br>#','#</ul><br>#','#<ul><br>#'),array('</p>','</li>','</ul>','<ul>'),$str);
$str=preg_replace('#<b>#','<strong>',$str);
$str=preg_replace('#</b>#','</strong>',$str);
2020-10-16 12:14:12 +02:00
$str=preg_replace('#<p></p>#','',$str);
2020-10-13 08:21:26 +02:00
$str=strip_tags($str,'<a><br><ol><ul><li><p><div><i><b><strong><em><small><img>');
return($str);
}
2020-10-22 17:54:05 +02:00
2020-10-15 09:59:36 +02:00
function pnum($num) {
$num.='';
$pnum='';
$li=strlen($num)-1;
$cc=1;
for ($i=$li; $i>=0; $i--) {
$pnum=$num[$i].$pnum;
if ($cc==3 && $i>0) $pnum='.'.$pnum;
$cc++;
if ($cc==4) $cc=1;
}
return($pnum);
}
2020-10-13 08:21:26 +02:00
2020-10-23 19:00:43 +02:00
$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(_('Couldnt connect to database: ').mysqli_connect_error().' ['.mysqli_connect_errno().']',false);
2020-10-13 08:21:26 +02:00
mysqli_set_charset($link,'utf8mb4');
2020-10-22 17:54:05 +02:00
$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.Dead=0 AND Instances.IsMastodon=1 AND Instances.FirstSeen IS NOT NULL') or muorimeglio(__LINE__.': '.mysqli_error($link),true);
$row=mysqli_fetch_assoc($res);
2020-10-23 19:00:43 +02:00
echo(_('<div id="help"><p class="intro">This is a beta version of our search engine for Mastodon instances. It works this way: data of already indexed instances gets updated every night, and a shuffling occurs for the “random ordering”; also, once a week, during the night between Tuesday and Wednesday, new instances get searched for and added to the database.</p><p class="intro">Advanced search criteria are customizable, but by default they reflect our fondness for a decentralized and egalitarian Fediverse; with our blacklist we try to not give visibility to instances accepting fascist, racist, sexist, ableist, sovereignist contents.</p></div>').N);
printf(_('<p class="introe">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, pnum($row['tinsts']), pnum($row['tusers']), pnum($row['tactusers']), pnum($row['tstatuses']));
2020-10-22 17:54:05 +02:00
// <p class="intro">Nella prima versione stabile daremo a* admin delle istanze compatibili con questa politica la possibilità di descrivere ulteriormente la propria istanza con questi campi, tutti facoltativi: “Descrizione in inglese” (per le istanze la cui descrizione è in altre lingue), “Località” (se listanza è particolarmente legata a un territorio), “Lingue” (se le lingue utilizzate prevalentemente sullistanza non corrispondono a quelle rilevate automaticamente dal nostro crawler), “Modalità di copertura dei costi” (per esempio “Autonoma”, “Sottoscrizioni volontarie degli utenti”, “Iniziative benefit”), “Regole sui contenuti” (per esempio “Tag NSFW per i nudi”, “No link a siti di partiti politici”, “No pubblicità”, “Content Warning prima degli spoiler”), e “Categorie” (per esempio “Generalista”, “Astronomia”, “Politica”, “Musica folk”).</p>
// daremo la possibilità di segnalarci le istanze su cui sono accettati contenuti di questo tipo
// Le istanze che non rispondono da più di due mesi vengono dichiarate “morte” nel database e non vengono più mostrate tra i risultati della ricerca, ma una volta allanno, nella notte di Halloween (31 ottobre), vengono nuovamente controllate e, se rispondono, “resuscitate”
2020-10-15 09:59:36 +02:00
2020-10-13 08:21:26 +02:00
$maxuinp=10000000000;
if ((array_key_exists('black',$_GET) && $_GET['black']=='1') || !array_key_exists('black',$_GET)) {
$_GET['cbblack']=' checked';
$_GET['black']=1;
} else {
$_GET['cbblack']='';
$_GET['black']=0;
}
//echo('<p>black: '.$_GET['black'].'</p>');
if ((array_key_exists('creg',$_GET) && $_GET['creg']=='1') || !array_key_exists('creg',$_GET)) {
$_GET['cbcreg']=' checked';
$_GET['creg']=1;
} else {
$_GET['cbcreg']='';
$_GET['creg']=0;
}
if (array_key_exists('appr',$_GET) && $_GET['appr']=='1') {
2020-10-13 08:21:26 +02:00
$_GET['cbappr']=' checked';
$_GET['appr']=1;
} else {
$_GET['cbappr']='';
$_GET['appr']=0;
}
if (array_key_exists('lcok',$_GET) && $_GET['lcok']=='1') {
2020-10-13 08:21:26 +02:00
$_GET['cblcok']=' checked';
$_GET['lcok']=1;
} else {
$_GET['cblcok']='';
$_GET['lcok']=0;
}
if (array_key_exists('lang',$_GET)) {
if (preg_match('#^[0-9]+$#',$_GET['lang'])===1)
$_GET['lang']=$_GET['lang']+0;
else
$_GET['lang']=0;
} else {
$res=mysqli_query($link,'SELECT ID FROM Languages WHERE Code="'.$dlang.'"') or muorimeglio(__LINE__.': '.mysqli_error($link),true);
if (mysqli_num_rows($res)>0) {
$row=mysqli_fetch_assoc($res);
$_GET['lang']=$row['ID'];
} else {
$_GET['lang']=0;
}
}
if ($_GET['lang']>5000000000) $_GET['lang']=0;
if (array_key_exists('desc',$_GET) && preg_match('#^.+$#',$_GET['lang'])===1)
$_GET['desc']=trim($_GET['desc']);
else
$_GET['desc']='';
if (mb_strlen($_GET['desc'])>64) $_GET['desc']='';
if (array_key_exists('minu',$_GET) && preg_match('#^[0-9]+$#',$_GET['minu'])===1)
$_GET['minu']=$_GET['minu']+0;
else
$_GET['minu']=10;
if ($_GET['minu']>$maxuinp) $_GET['minu']=$maxuinp;
if (array_key_exists('maxu',$_GET) && preg_match('#^[0-9]+$#',$_GET['maxu'])===1)
$_GET['maxu']=$_GET['maxu']+0;
else
$_GET['maxu']=30000;
if ($_GET['maxu']>$maxuinp) $_GET['maxu']=$maxuinp;
if ($_GET['maxu']<$_GET['minu']) $_GET['maxu']=$_GET['minu'];
if (array_key_exists('minau',$_GET) && preg_match('#^[0-9]+$#',$_GET['minau'])===1)
$_GET['minau']=$_GET['minau']+0;
else
$_GET['minau']=10;
if ($_GET['minau']>10000000) $_GET['minau']=10000000;
if (array_key_exists('minki',$_GET) && preg_match('#^[0-9]+$#',$_GET['minki'])===1)
$_GET['minki']=$_GET['minki']+0;
else
$_GET['minki']=500;
if ($_GET['minki']>100000) $_GET['minki']=100000;
$order=array(
2020-10-23 19:00:43 +02:00
'rand'=>array('t'=>_('Random, recommended first'),'q'=>'Instances.Priority DESC, Instances.RPos ASC'),
2020-10-13 08:21:26 +02:00
// 'feat'=>array('t'=>_('Prima le consigliate'),'q'=>'Instances.Priority DESC'),
// partecipazione: totusers/activeusers
// 'part'=>array('t'=>_('Partecipazione (decr.)'),'q'=>'(Instances.UserCount / Instances.ActiveUsersMonth) ASC'),
2020-10-23 19:00:43 +02:00
'tusersa'=>array('t'=>_('By number of users, ascending'),'q'=>'Instances.UserCount ASC'),
'tusersd'=>array('t'=>_('By number of users, descending'),'q'=>'Instances.UserCount DESC'),
'ausersd'=>array('t'=>_('By number of active users, descending'),'q'=>'Instances.ActiveUsersMonth DESC'),
'kinstsd'=>array('t'=>_('By number of known instances, descending'),'q'=>'Instances.DomainCount DESC'),
'charsd'=>array('t'=>_('By maximum number of characters per toot, descending'),'q'=>'Instances.MaxTootChars DESC'),
2020-10-13 08:21:26 +02:00
// 'open'=>array('t'=>_('Prima quelle con iscriz. aperte'),'q'=>'Instances.RegOpen DESC, Instances.RegReqApproval ASC'),
// 'alph'=>array('t'=>_('Alfabetico'),'q'=>'Instances.URI ASC'),
// new non ha senso di esistere visto che c'è firstseen
// 'new'=>array('t'=>_('Prima le nuove'),'q'=>'Instances.New DESC'),
// 'name'=>array('t'=>_('Nome (crescente)'),'q'=>'Instances.Title ASC'),
// 'admc'=>array('t'=>_('Data creazione account admin'),'q'=>'IF (Instances.AdmCreatedAt IS NULL, 9999999999, Instances.AdmCreatedAt) ASC'),
// 'fseena'=>array('t'=>_('Data di “avvistamento” cresc.'),'q'=>'Instances.FirstSeen ASC'),
// 'fseend'=>array('t'=>_('Data di “avvistamento” decr.'),'q'=>'Instances.FirstSeen DESC'),
);
if (!(array_key_exists('ord',$_GET) && array_key_exists($_GET['ord'],$order)))
$_GET['ord']='rand';
2020-10-23 19:00:43 +02:00
if ($_GET['lang']==0) $order['rand']=array('t'=>_('Random'),'q'=>'Instances.RPos ASC');
2020-10-13 08:21:26 +02:00
$p=1;
if (array_key_exists('p',$_GET) && preg_match('#^[0-9]+$#',$_GET['p'])===1) $p=$_GET['p']+0;
($_GET['lang']==0) ? $selected=' selected' : $selected='';
2020-10-22 21:39:45 +02:00
echo('<form method="get" id="searchf" class="sdbox" onsubmit="document.getElementById(\'p\').value=1;">
2020-10-23 19:00:43 +02:00
<div class="sdtit">'._('Search criteria').'</div>
2020-10-13 08:21:26 +02:00
<div class="sdrow">
2020-10-23 19:00:43 +02:00
<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>
2020-10-13 08:21:26 +02:00
<div class="sdinput">
<select id="lang" name="lang" class="sselect">
2020-10-23 19:00:43 +02:00
<option value="0"'.$selected.'>'._('Irrelevant').'</option>'.N);
2020-10-13 08:21:26 +02:00
$res=mysqli_query($link,'SELECT Languages.ID AS Lid, CONCAT(Name'.$dlang.', \' [\', 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.Dead=0 AND Instances.IsMastodon=1 AND InstOurLangs.Pos=1 GROUP BY Languages.ID ORDER BY Name'.$dlang.' ASC') or muorimeglio(__LINE__.': '.mysqli_error($link),true);
//$res=mysqli_query($link,'SELECT Languages.ID AS Lid, CONCAT(Name'.$dlang.', \' (\', Code, \')\') AS Txt FROM InstOurLangs LEFT JOIN Languages ON Languages.ID=OurLangID LEFT JOIN Instances ON Instances.ID=InstOurLangs.InstID WHERE Instances.Dead=0 AND Instances.IsMastodon=1 AND InstOurLangs.Pos=1 GROUP BY Languages.ID ORDER BY Name'.$dlang.' ASC') or muorimeglio(__LINE__.': '.mysqli_error($link),true);
while ($row=mysqli_fetch_assoc($res)) {
($_GET['lang']==$row['Lid']) ? $selected=' selected' : $selected='';
echo('<option value="'.$row['Lid'].'"'.$selected.'>'.$row['Txt'].'</option>'.N);
}
echo('</select>
</div>
</div>
<div class="sdrow">
2020-10-23 19:00:43 +02:00
<div class="sdlabel"><label for="desc" title="'._('Include only instances whose descriptions contain the specified expression').'">'._('Description contains').'</label></div>
2020-10-15 19:24:45 +02:00
<div class="sdinput"><input type="text" id="desc" name="desc" class="sinput" maxlength="64" value="'.hspech($_GET['desc']).'"></div>
2020-10-13 08:21:26 +02:00
</div>
<div id="mctrl">
<div class="sdrow">
2020-10-23 19:00:43 +02:00
<div class="sdlabel"><label for="minu" title="'._('Include only instances which have at least this number of users (“0” disables this criterion)').'">'._('Minimum number of users is').'</label></div>
2020-10-13 08:21:26 +02:00
<div class="sdinput"><input type="number" id="minu" name="minu" min="0" max="'.$maxuinp.'" class="sinput" value="'.$_GET['minu'].'"></div>
</div>
<div class="sdrow">
2020-10-23 19:00:43 +02:00
<div class="sdlabel"><label for="maxu" title="'._('Include only instances which have at most this number of users (“0” disables this criterion)').'">'._('Maximum number of users is').'</label></div>
2020-10-13 08:21:26 +02:00
<div class="sdinput"><input type="number" id="maxu" name="maxu" min="0" max="'.$maxuinp.'" class="sinput" value="'.$_GET['maxu'].'"></div>
</div>
<div class="sdrow">
2020-10-23 19:00:43 +02:00
<div class="sdlabel"><label for="minau" title="'._('Include only instances which had at least this number of active users during the last 30 days (“0” disables this criterion)').'">'._('Minimum number of active users is').'</label></div>
2020-10-13 08:21:26 +02:00
<div class="sdinput"><input type="number" id="minau" name="minau" min="0" max="100000000" class="sinput" value="'.$_GET['minau'].'"></div>
</div>
<div class="sdrow">
2020-10-23 19:00:43 +02:00
<div class="sdlabel"><label for="minki" title="'._('Include only instances which know at least this number of other instances (“0” disables this criterion)').'">'._('Minimum number of known instances is').'</label></div>
2020-10-13 08:21:26 +02:00
<div class="sdinput"><input type="number" id="minki" name="minki" min="0" max="100000" class="sinput" value="'.$_GET['minki'].'"></div>
</div>
<div class="sdrow">
2020-10-23 19:00:43 +02:00
<div class="sdlabel"><label for="cbblack" title="'._('Exclude blacklisted instances').'">'._('Exclude blacklisted').'</label></div>
2020-10-13 08:21:26 +02:00
<div class="sdinput">
<input type="checkbox" class="sckbox" id="cbblack" value="1"'.$_GET['cbblack'].' onchange="if (this.checked) document.getElementById(\'black\').value=1; else document.getElementById(\'black\').value=0;">
<input type="hidden" id="black" name="black" value="'.$_GET['black'].'">
</div>
</div>
<div class="sdrow">
2020-10-23 19:00:43 +02:00
<div class="sdlabel"><label for="cbcreg" title="'._('Exclude instances which dont accept new registrations').'">'._('Exclude if registrations are closed').'</label></div>
2020-10-13 08:21:26 +02:00
<div class="sdinput">
<input type="checkbox" class="sckbox" id="cbcreg" value="1"'.$_GET['cbcreg'].' onchange="if (this.checked) document.getElementById(\'creg\').value=1; else document.getElementById(\'creg\').value=0;">
<input type="hidden" id="creg" name="creg" value="'.$_GET['creg'].'">
</div>
</div>
<div class="sdrow">
2020-10-23 19:00:43 +02:00
<div class="sdlabel"><label for="cbappr" title="'._('Exclude instances on which admin approval is required for registration').'">'._('Exclude if registration requires approval').'</label></div>
2020-10-13 08:21:26 +02:00
<div class="sdinput">
<input type="checkbox" class="sckbox" id="cbappr" value="1"'.$_GET['cbappr'].' onchange="if (this.checked) document.getElementById(\'appr\').value=1; else document.getElementById(\'appr\').value=0;">
<input type="hidden" id="appr" name="appr" value="'.$_GET['appr'].'">
</div>
</div>
<div class="sdrow">
2020-10-23 19:00:43 +02:00
<div class="sdlabel"><label for="cblcok" title="'._('Exclude instances which didnt respond to last check').'">'._('Exclude if offline on last check').'</label></div>
2020-10-13 08:21:26 +02:00
<div class="sdinput">
<input type="checkbox" class="sckbox" id="cblcok" value="1"'.$_GET['cblcok'].' onchange="if (this.checked) document.getElementById(\'lcok\').value=1; else document.getElementById(\'lcok\').value=0;">
<input type="hidden" id="lcok" name="lcok" value="'.$_GET['lcok'].'">
</div>
</div>
</div>
<div class="sdcrow">
2020-10-23 19:00:43 +02:00
<input type="button" class="litbut" id="mctrlb" value="'._('Advanced criteria').'" onclick="shmctrl()">
2020-10-13 08:21:26 +02:00
</div>
2020-10-23 19:00:43 +02:00
<div class="sdtitb">'._('Order of results').'</div>
2020-10-14 17:29:11 +02:00
2020-10-14 08:37:41 +02:00
<div class="sdcrow">
2020-10-14 17:29:11 +02:00
<select id="ord" name="ord" class="sselect100">'.N);
foreach ($order as $key=>$buf) {
($key!=$_GET['ord']) ? $selected='' : $selected=' selected';
echo('<option value="'.$key.'"'.$selected.'>'.$buf['t'].'</option>'.N);
}
echo('</select>
2020-10-14 08:37:41 +02:00
</div>
2020-10-23 19:00:43 +02:00
<!-- <input type="button" class="litbut" id="dbgb" value="'._('Debug info').'" onclick="shdbg()" style="margin:0"> //-->
2020-10-14 08:37:41 +02:00
2020-10-13 08:21:26 +02:00
<div class="sdlrow">
2020-10-23 19:00:43 +02:00
<input type="submit" value="'._('Search').'" class="ssubmit">
2020-10-13 08:21:26 +02:00
</div>
2020-10-14 17:29:11 +02:00
<div class="sdlcrow">
2020-10-23 19:00:43 +02:00
<input type="button" class="litbut" value="'._('Reset search').'" onclick="document.location.href=document.location.href.replace(/\\?.*$/,\'\')">
2020-10-14 17:29:11 +02:00
</div>
2020-10-13 08:21:26 +02:00
<input type="hidden" id="advc" name="advc" value="'.$_GET['advc'].'">
<input type="hidden" id="p" name="p" value="'.$p.'">
</form>
<script language="JavaScript">
mctrlsh='.(($_GET['advc']==1) ? 'false' : 'true').';
shmctrl();
2020-10-22 17:54:05 +02:00
swhelp();
2020-10-13 08:21:26 +02:00
</script>'.N);
$joins=array();
$wheres=array();
2020-10-14 00:03:40 +02:00
$wheres[]='Instances.Dead=0 AND Instances.IsMastodon=1 AND Instances.FirstSeen IS NOT NULL';
2020-10-13 08:21:26 +02:00
if ($_GET['black']==1) $wheres[]='Instances.Blacklisted=0';
if ($_GET['creg']==1) $wheres[]='Instances.RegOpen=1';
if ($_GET['appr']==1) $wheres[]='Instances.RegReqApproval=0';
if ($_GET['lcok']==1) $wheres[]='Instances.LastCheckOk=1';
/*if ($_GET['lcok']==1) {
$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';
}*/
if ($_GET['lang']>0) {
$joins[]='LEFT JOIN InstOurLangs ON InstOurLangs.InstID=Instances.ID';
$wheres[]='(InstOurLangs.OurLangID='.$_GET['lang'].' AND InstOurLangs.Pos=1)';
}
$buf=preg_replace('#%#','\%',myesc($link,$_GET['desc']));
if ($_GET['desc']!='') $wheres[]='(Instances.ShortDesc LIKE "%'.$buf.'%" OR Instances.LongDesc LIKE "%'.$buf.'%")';
if ($_GET['minu']>0) $wheres[]='Instances.UserCount>='.$_GET['minu'];
if ($_GET['maxu']>0) $wheres[]='Instances.UserCount<='.$_GET['maxu'];
if ($_GET['minau']>0) $wheres[]='Instances.ActiveUsersMonth>='.$_GET['minau'];
if ($_GET['minki']>0) $wheres[]='Instances.DomainCount>='.$_GET['minki'];
$joins=implode(' ',$joins);
$wheres='WHERE '.implode(' AND ',$wheres);
$que='SELECT * FROM Instances '.$joins.' '.$wheres.' ORDER BY '.$order[$_GET['ord']]['q'];
$debug.='QUERY: «'.hspech($que).'»'.N;
$qit=microtime(true);
$res=mysqli_query($link,$que) or muorimeglio(__LINE__.': '.mysqli_error($link),true);
$debug.='MAIN QUERY EXEC TIME: '.(microtime(true)-$qit).' sec.'.N;
$itot=mysqli_num_rows($res);
$debug.='RESULTS: '.$itot;
2020-10-14 08:37:41 +02:00
//echo('<div id="debug"><textarea spellcheck="false">'.$debug.'</textarea></div>'.N);
2020-10-14 19:11:40 +02:00
$ipp=10;// istanze per pagina
2020-10-13 08:21:26 +02:00
$if=$ipp*($p-1);
if ($if>=$itot) {
$if=0;
$p=1;
}
$il=$if+$ipp;
$ptot=ceil($itot/$ipp);
//echo('ptot: '.$ptot.'<br>'.N);
if ($ptot>1) {
$out='<div>'.N;
$out.='<select id="pagesel" onchange="document.getElementById(\'p\').value=this.value; document.getElementById(\'searchf\').submit();">'.N;
for ($i=1; $i<=$ptot; $i++) {
($i!=$p) ? $selected='' : $selected=' selected';
$li=$i*$ipp;
if ($li>$itot) $li=$itot;
//page number prefix
$out.='<option value="'.$i.'"'.$selected.'>'._('P.').' '.$i.'/'.$ptot.' ('.(($i-1)*$ipp+1).'-'.$li.'/'.$itot.')</option>'.N;
}
$out.='</select>'.N;
$out.='</div>'.N;
echo($out);
2020-10-14 19:11:40 +02:00
} else {
2020-10-14 19:18:17 +02:00
echo('<script language="JavaScript">document.getElementById(\'bmenu\').style.display=\'none\';</script>'.N);
2020-10-13 08:21:26 +02:00
}
mysqli_data_seek($res,$if);
while ($if<$il && $row=mysqli_fetch_assoc($res)) {
$if++;
2020-10-23 19:00:43 +02:00
$out='<div class="ihead"><a href="https://'.hspech($row['URI']).'" title="'._('Go to instance').'">'.hspech($row['URI']).'</a> (<span title="'._('Instance ID').': '.$row['ID'].'">'.$if.'</span>/'.$itot.')</div>'.N;
2020-10-13 08:21:26 +02:00
$out.='<div class="ibody">'.N;
$rres=mysqli_query($link,'SELECT CONCAT(Languages.Name'.strtoupper($dlang).'," (",Languages.Code,")") AS Lang FROM InstOurLangs LEFT JOIN Languages ON Languages.ID=InstOurLangs.OurLangID WHERE InstOurLangs.InstID='.$row['ID'].' ORDER BY InstOurLangs.Pos ASC') or muorimeglio(__LINE__.': '.mysqli_error($link),true);
$buf=array();
while ($rrow=mysqli_fetch_assoc($rres))
$buf[]=hspech($rrow['Lang']);
2020-10-23 19:00:43 +02:00
$out.='<a href="https://'.hspech($row['URI']).'" title="'._('Go to instance').'"><div class="iimgc"><img class="iimg" src="'.$row['Thumb'].'">';
// if (!is_null($row['Priority'])) $out.='<img src="'.$prepath.'imgs/featured-it.svg" class="ifeat">';
if (!is_null($row['Priority'])) $out.='<div class="dfeat">'._('Recommended').'</div>';
2020-10-13 08:21:26 +02:00
$out.='</div></a>'.N;
$out.='<div class="icol">'.N;
2020-10-23 19:00:43 +02:00
$out.='<div><span class="ilab">'._('Name').'</span> <a href="https://'.hspech($row['URI']).'" title="'._('Go to instance').'">'.nully(hspech($row['Title'])).'</a></div>'.N;
2020-10-13 08:21:26 +02:00
/*$out.='<div><span class="ilab">'._('Consigliata').'</span> ';
(!is_null($row['Priority'])) ? $out.='<span class="ivgood">'._('Si!').'</span>' : $out.=_('No');
$out.='</div>'.N;*/
2020-10-23 19:00:43 +02:00
$out.='<div><span class="ilab">'._('Languages').'</span> '.nully(implode(', ',$buf)).'</div>'.N;
$out.='<div><span class="ilab">'._('Users').'</span> '.nully($row['UserCount']).'</div>'.N;
$out.='<div><span class="ilab">'._('Active users (last month)').'</span> '.nully($row['ActiveUsersMonth']).'</div>'.N;
$out.='<div><span class="ilab">'._('Active users (last six months)').'</span> '.nully($row['ActiveUsersHalfYear']).'</div>'.N;
$out.='<div><span class="ilab">'._('Known instances').'</span> '.nully($row['DomainCount']).'</div>'.N;
2020-10-13 08:21:26 +02:00
$out.='</div>'.N;
$out.='<div class="icol">'.N;
2020-10-23 19:00:43 +02:00
$out.='<div><span class="ilab">'._('Characters per toot (max)').'</span> ';
2020-10-13 08:21:26 +02:00
if (nullemp($row['MaxTootChars']))
$out.='<span class="null">500</span>';
else
$out.=$row['MaxTootChars'];
$out.='</div>'.N;
2020-10-23 19:00:43 +02:00
$out.='<div><span class="ilab">'._('Blacklisted').'</span> ';
($row['Blacklisted']==1) ? $out.='<span class="ibad">'._('Yes').'</span>' : $out.='<span class="igood">'._('No').'</span>';
2020-10-13 08:21:26 +02:00
$out.='</div>'.N;
2020-10-23 19:00:43 +02:00
$out.='<div><span class="ilab">'._('New').'</span> ';
($row['New']==1) ? $out.='<span class="ivgood">'._('Yes!').'</span>' : $out.=_('No');
2020-10-13 08:21:26 +02:00
$out.='</div>'.N;
2020-10-23 19:00:43 +02:00
$out.='<div><span class="ilab">'._('Mastodon version').'</span> '.nully(hspech($row['Version'])).'</div>'.N;
2020-10-13 08:21:26 +02:00
2020-10-23 19:00:43 +02:00
$out.='<div><span class="ilab">'._('Registrations').'</span> ';
($row['RegReqApproval']==1) ? $buf=' <span class="iwarn">('._('by admin approval').')</span>' : $buf='';
2020-10-13 08:21:26 +02:00
if (nullemp($row['RegOpen']))
2020-10-23 19:00:43 +02:00
$out.='<span class="null">'._('Not available{singular}').'</span>';
2020-10-13 08:21:26 +02:00
elseif ($row['RegOpen']==1)
2020-10-23 19:00:43 +02:00
$out.='<span class="igood">'._('Open').'</span>'.$buf;
2020-10-13 08:21:26 +02:00
else
2020-10-23 19:00:43 +02:00
$out.='<span class="iwarn">'._('Closed').'</span>';
2020-10-13 08:21:26 +02:00
$out.='</div>'.N;
$out.='<div><span class="ilab">'._('E-mail').'</span> ';
if (nullemp($row['Email']))
2020-10-23 19:00:43 +02:00
$out.='<span class="null">'._('Not available{singular}').'</span>';
2020-10-13 08:21:26 +02:00
else
$out.='<a href="mailto:'.$row['Email'].'">'.$row['Email'].'</a>';
$out.='</div>'.N;
$out.='</div>'.N;
2020-10-23 19:00:43 +02:00
$out.='<div><span class="ilab">'._('Most used hashtags (last week)').'</span> ';
2020-10-13 08:21:26 +02:00
$rres=mysqli_query($link,'SELECT * FROM InstTrends WHERE InstID='.$row['ID'].' ORDER BY Pos ASC') or muorimeglio(__LINE__.': '.mysqli_error($link),true);
if (mysqli_num_rows($rres)>0) {
$buf=array();
while ($rrow=mysqli_fetch_assoc($rres))
$buf[]='<a href="'.hspech($rrow['URL']).'">'.hspech($rrow['Name']).'</a>';
$out.=implode(', ',$buf);
} else {
2020-10-23 19:00:43 +02:00
$out.='<span class="null">'._('Not available{plural}').'</span>';
2020-10-13 08:21:26 +02:00
}
$out.='</div>'.N;
2020-10-23 19:00:43 +02:00
$out.='<div><div class="idlab">'._('Short description').'</div><div class="idesc">'.nully(strip(nl2br(trim($row['ShortDesc']),false),$row['URI'])).'</div></div>'.N;
$out.='<div><div class="idlab">'._('Long description').'</div><div class="idesc">'.nully(strip(trim($row['LongDesc']),$row['URI'])).'</div></div>'.N;
2020-10-13 08:21:26 +02:00
2020-10-23 19:00:43 +02:00
$out.='<div class="abox"><img class="aimg" src="'.$row['AdmAvatar'].'"><div><span class="ilab">'._('Admin account').'</span> '.nully(hspech($row['AdmAccount'])).'</div><div><span class="ilab">'._('Date of creation').'</span> '.nully(ldate($row['AdmCreatedAt'],true)).'</div><div><span class="ilab">'._('Admin name').'</span> '.nully(hspech($row['AdmDisplayName'])).'</div><div><div class="idlab">'._('Admin notes').'</div><div class="inote">'.nullyp(strip(trim($row['AdmNote']),$row['URI'])).'</div>'.N;
2020-10-13 08:21:26 +02:00
$out.='</div></div>';
2020-10-23 19:00:43 +02:00
$out.='<div class="ghost"><div class="idlab">'._('Stats').'</div><div class="istat">';
2020-10-15 06:27:27 +02:00
2020-10-13 08:21:26 +02:00
$rres=mysqli_query($link,'SELECT COUNT(InstID) AS cnt, SUM(Statuses) AS tstatuses, SUM(Logins) AS tlogins, SUM(Registrations) AS tregs FROM InstActivity WHERE InstID='.$row['ID']) or muorimeglio(__LINE__.': '.mysqli_error($link),true);
2020-10-23 19:00:43 +02:00
$out.='<div class="dida">'._('Last 12 weeks activity');
2020-10-13 08:21:26 +02:00
if (mysqli_num_rows($rres)>0) {
$rrow=mysqli_fetch_assoc($rres);
if ($rrow['cnt']>0)
2020-10-23 19:00:43 +02:00
$out.=' ('._('totals:').' '.$rrow['tstatuses'].' '._('statuses').', '.$rrow['tlogins'].' '._('logins').', '.$rrow['tregs'].' '._('registrations').')';
2020-10-13 08:21:26 +02:00
}
$out.='</div>'.N;
$rres=mysqli_query($link,'SELECT * FROM InstActivity WHERE InstID='.$row['ID'].' ORDER BY Week ASC') or muorimeglio(__LINE__.': '.mysqli_error($link),true);
$out.='<table class="abar"><tr>';
$tot=mysqli_num_rows($rres);
if ($tot>0) {
while ($rrow=mysqli_fetch_assoc($rres))
2020-10-23 19:00:43 +02:00
// initials for Statuses, Logins, Registrations
$out.='<td width="'.(100/$tot).'%">'._('S').': '.$rrow['Statuses'].'<br>'._('L').': '.$rrow['Logins'].'<br>'._('R').': '.$rrow['Registrations'].'</td>';
2020-10-13 08:21:26 +02:00
} else {
2020-10-23 19:00:43 +02:00
$out.='<td><span class="null">'._('Not available{singular}').'</span></td>';
2020-10-13 08:21:26 +02:00
}
$out.='</tr></table>'.N;
2020-10-15 06:27:27 +02:00
$rres=mysqli_query($link,'SELECT * FROM InstChecks WHERE InstID='.$row['ID'].' ORDER BY Time DESC LIMIT 0,8') or muorimeglio(__LINE__.': '.mysqli_error($link),true);
$tot=mysqli_num_rows($rres);
$buf=array();
while ($rrow=mysqli_fetch_assoc($rres)) $buf[]=$rrow;
2020-10-23 19:00:43 +02:00
$out.='<div class="dida">'._('Last checks (green: OK; red: KO)').'</div><table class="cbar"><tr>';
2020-10-15 06:27:27 +02:00
for ($i=$tot-1; $i>=0; $i--) {
$out.='<td width="'.(100/$tot).'%"';
if ($buf[$i]['Status']==1) $out.=' class="cbarok"';
$out.='>'.ldate($buf[$i]['Time']).'</td>';
}
$out.='</tr></table>'.N;
2020-10-13 08:21:26 +02:00
$out.='</div></div>'.N;
$out.='</div>'.N;
echo($out);
}
mysqli_close($link);
2020-10-27 16:32:23 +01:00
echo('</section>
</div>
</div>'.N);
2020-10-13 08:21:26 +02:00
?>