493 lines
23 KiB
PHP
493 lines
23 KiB
PHP
<?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);
|
||
|
||
$nottrans=['ca','es','fr'];
|
||
$locale=$dlang;
|
||
if (in_array($locale,$nottrans)) $locale='en';
|
||
$blocale='en_US.UTF-8';
|
||
//putenv('LC_ALL='.$blocale);
|
||
setlocale(LC_ALL,$blocale);
|
||
bindtextdomain('custard','./locale/'.$locale);
|
||
textdomain('custard');
|
||
|
||
$debug.='LOCALE: '.$locale.N;
|
||
|
||
if (array_key_exists('advc',$_GET)) {
|
||
($_GET['advc']=='1') ? $_GET['advc']=1 : $_GET['advc']=0;
|
||
} else {
|
||
$_GET['advc']=0;
|
||
}
|
||
|
||
//non spostarli sopra sennò gettext non funge (css si può anche, ma tanto vale tenere insieme)
|
||
echo('<link rel="stylesheet" type="text/css" href="'.$prepath.'custard.css?v='.$cjrand.'">'.N);
|
||
echo('<script language="JavaScript">
|
||
var dbgsh=false;
|
||
function shdbg() {
|
||
dbgd=document.getElementById(\'debug\');
|
||
dbgb=document.getElementById(\'dbgb\');
|
||
if (dbgsh) {
|
||
dbgd.style.display=\'none\';
|
||
dbgb.className=\'litbut\';
|
||
dbgsh=false;
|
||
} else {
|
||
dbgd.style.display=\'block\';
|
||
dbgb.className=\'litbuta\';
|
||
dbgsh=true;
|
||
}
|
||
}
|
||
var mctrlsh=false;
|
||
function shmctrl() {
|
||
mctrl=document.getElementById(\'mctrl\');
|
||
mctrlb=document.getElementById(\'mctrlb\');
|
||
advc=document.getElementById(\'advc\');
|
||
if (mctrlsh) {
|
||
mctrl.style.display=\'none\';
|
||
mctrlb.className=\'litbut\';
|
||
mctrlb.value=\''._('Mostra criteri avanzati').'\';
|
||
advc.value=0;
|
||
mctrlsh=false;
|
||
} else {
|
||
mctrl.style.display=\'block\';
|
||
mctrlb.className=\'litbuta\';
|
||
mctrlb.value=\''._('Nascondi criteri avanzati').'\';
|
||
advc.value=1;
|
||
mctrlsh=true;
|
||
}
|
||
}
|
||
</script>'.N);
|
||
|
||
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) {
|
||
if (nullemp($str)) return('<span class="null">'._('Non disponibile').'</span>');
|
||
return($str);
|
||
}
|
||
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);
|
||
$str=strip_tags($str,'<a><br><ol><ul><li><p><div><i><b><strong><em><small><img>');
|
||
return($str);
|
||
}
|
||
|
||
//$blang=preg_replace(array('#,.*#','#-#'),array('','_'),$_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
||
|
||
$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(_('Impossibile connettersi al database: ').mysqli_connect_error().' ['.mysqli_connect_errno().']',false);
|
||
mysqli_set_charset($link,'utf8mb4');
|
||
|
||
$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') || !array_key_exists('appr',$_GET)) {
|
||
$_GET['cbappr']=' checked';
|
||
$_GET['appr']=1;
|
||
} else {
|
||
$_GET['cbappr']='';
|
||
$_GET['appr']=0;
|
||
}
|
||
|
||
if ((array_key_exists('lcok',$_GET) && $_GET['lcok']=='1') || !array_key_exists('lcok',$_GET)) {
|
||
$_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(
|
||
'rand'=>array('t'=>_('Casuale, prima le consigliate'),'q'=>'Instances.Priority DESC, rand()'),
|
||
// 'feat'=>array('t'=>_('Prima le consigliate'),'q'=>'Instances.Priority DESC'),
|
||
// partecipazione: totusers/activeusers
|
||
// 'part'=>array('t'=>_('Partecipazione (decr.)'),'q'=>'(Instances.UserCount / Instances.ActiveUsersMonth) ASC'),
|
||
'tusersa'=>array('t'=>_('Per numero di utenti, crescente'),'q'=>'Instances.UserCount ASC'),
|
||
'tusersd'=>array('t'=>_('Per numero di utenti, decrescente'),'q'=>'Instances.UserCount DESC'),
|
||
'ausersd'=>array('t'=>_('Per numero di utenti attivi, decrescente'),'q'=>'Instances.ActiveUsersMonth DESC'),
|
||
'kinstsd'=>array('t'=>_('Per numero istanze note, decrescente'),'q'=>'Instances.DomainCount DESC'),
|
||
'charsd'=>array('t'=>_('Per numero massimo di caratteri per toot, decrescente'),'q'=>'Instances.MaxTootChars DESC'),
|
||
// 'open'=>array('t'=>_('Prima quelle con iscriz. aperte'),'q'=>'Instances.RegOpen DESC, Instances.RegReqApproval ASC'),
|
||
// 'alph'=>array('t'=>_('Alfabetico'),'q'=>'Instances.URI ASC'),
|
||
// new non ha senso di esistere visto che c'è firstseen
|
||
// 'new'=>array('t'=>_('Prima le nuove'),'q'=>'Instances.New DESC'),
|
||
// 'name'=>array('t'=>_('Nome (crescente)'),'q'=>'Instances.Title ASC'),
|
||
// 'admc'=>array('t'=>_('Data creazione account admin'),'q'=>'IF (Instances.AdmCreatedAt IS NULL, 9999999999, Instances.AdmCreatedAt) ASC'),
|
||
// 'fseena'=>array('t'=>_('Data di “avvistamento” cresc.'),'q'=>'Instances.FirstSeen ASC'),
|
||
// 'fseend'=>array('t'=>_('Data di “avvistamento” decr.'),'q'=>'Instances.FirstSeen DESC'),
|
||
);
|
||
if (!(array_key_exists('ord',$_GET) && array_key_exists($_GET['ord'],$order)))
|
||
$_GET['ord']='rand';
|
||
if ($_GET['lang']==0) $order['rand']=array('t'=>_('Casuale'),'q'=>'rand()');
|
||
|
||
$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='';
|
||
echo('<form method="get" id="searchf" class="sdbox">
|
||
<div class="sdtit">'._('Criteri di ricerca').'</div>
|
||
<div class="sdrow">
|
||
<div class="sdlabel"><label for="lang" title="'._('Includi solo le istanze in cui la lingua più usata è quella selezionata').'">'._('La lingua più usata è').'</label></div>
|
||
<div class="sdinput">
|
||
<select id="lang" name="lang" class="sselect">
|
||
<option value="0"'.$selected.'>'._('Indifferente').'</option>'.N);
|
||
$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">
|
||
<div class="sdlabel"><label for="desc" title="'._('Includi solo le istanze la cui descrizione (breve o lunga) contiene l’espressione specificata').'">'._('La descrizione contiene').'</label></div>
|
||
<div class="sdinput"><input type="text" id="desc" name="desc" class="sinput" maxlength="64" value="'.hspech($_GET['desc']).'" autofocus></div>
|
||
</div>
|
||
|
||
<div id="mctrl">
|
||
<div class="sdrow">
|
||
<div class="sdlabel"><label for="minu" title="'._('Includi solo le istanze che hanno almeno questo numero di utenti (“0” disabilita questo criterio)').'">'._('Il numero minimo di utenti è').'</label></div>
|
||
<div class="sdinput"><input type="number" id="minu" name="minu" min="0" max="'.$maxuinp.'" class="sinput" value="'.$_GET['minu'].'"></div>
|
||
</div>
|
||
<div class="sdrow">
|
||
<div class="sdlabel"><label for="maxu" title="'._('Includi solo le istanze che hanno al massimo questo numero di utenti (“0” disabilita questo criterio)').'">'._('Il numero massimo di utenti è').'</label></div>
|
||
<div class="sdinput"><input type="number" id="maxu" name="maxu" min="0" max="'.$maxuinp.'" class="sinput" value="'.$_GET['maxu'].'"></div>
|
||
</div>
|
||
<div class="sdrow">
|
||
<div class="sdlabel"><label for="minau" title="'._('Includi solo le istanze che negli ultimi 30 giorni hanno avuto almeno questo numero di utenti attivi (“0” disabilita questo criterio)').'">'._('Il numero minimo di utenti attivi è').'</label></div>
|
||
<div class="sdinput"><input type="number" id="minau" name="minau" min="0" max="100000000" class="sinput" value="'.$_GET['minau'].'"></div>
|
||
</div>
|
||
<div class="sdrow">
|
||
<div class="sdlabel"><label for="minki" title="'._('Includi solo le istanze che conoscono almeno questo numero di altre istanze (“0” disabilita questo criterio)').'">'._('Il numero minimo di istanze note è').'</label></div>
|
||
<div class="sdinput"><input type="number" id="minki" name="minki" min="0" max="100000" class="sinput" value="'.$_GET['minki'].'"></div>
|
||
</div>
|
||
<div class="sdrow">
|
||
<div class="sdlabel"><label for="cbblack" title="'._('Escludi le istanze blacklistate da Mastodon Help').'">'._('Escludi blacklistate').'</label></div>
|
||
<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">
|
||
<div class="sdlabel"><label for="cbcreg" title="'._('Escludi le istanze che non permettono nuove iscrizioni').'">'._('Escludi se iscriz. chiuse').'</label></div>
|
||
<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">
|
||
<div class="sdlabel"><label for="cbappr" title="'._('Escludi le istanze su cui l’iscrizione è subordinata all’approvazione di un* admin').'">'._('Escludi se iscriz. richiede approvaz.').'</label></div>
|
||
<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">
|
||
<div class="sdlabel"><label for="cblcok" title="'._('Escludi le istanze che non hanno risposto all’ultimo check').'">'._('Escludi se offline all’ultimo check').'</label></div>
|
||
<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">
|
||
<input type="button" class="litbut" id="mctrlb" value="'._('Criteri avanzati').'" onclick="shmctrl()">
|
||
</div>
|
||
|
||
<div class="sdtitb">'._('Ordinamento dei risultati').'</div>
|
||
|
||
<div class="sdcrow">
|
||
<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>
|
||
</div>
|
||
|
||
<!-- <input type="button" class="litbut" id="dbgb" value="'._('Info di debug').'" onclick="shdbg()" style="margin:0"> //-->
|
||
|
||
<div class="sdlrow">
|
||
<input type="submit" value="'._('Cerca').'" class="ssubmit">
|
||
</div>
|
||
|
||
<div class="sdlcrow">
|
||
<input type="button" class="litbut" value="'._('Resetta la ricerca').'" onclick="document.location.href=document.location.href.replace(/\\?.*$/,\'\')">
|
||
</div>
|
||
|
||
<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();
|
||
</script>'.N);
|
||
$joins=array();
|
||
$wheres=array();
|
||
$wheres[]='Instances.Dead=0 AND Instances.IsMastodon=1 AND Instances.FirstSeen IS NOT NULL';
|
||
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;
|
||
//echo('<div id="debug"><textarea spellcheck="false">'.$debug.'</textarea></div>'.N);
|
||
$ipp=10;// istanze per pagina
|
||
$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);
|
||
} else {
|
||
echo('<script language="JavaScript">document.getElementById(\'bmenu\').style.display=none;</script>'.N);
|
||
}
|
||
mysqli_data_seek($res,$if);
|
||
while ($if<$il && $row=mysqli_fetch_assoc($res)) {
|
||
$if++;
|
||
$out='<div class="ihead"><a href="https://'.hspech($row['URI']).'" title="'._('Vai all’istanza').'">'.hspech($row['URI']).'</a> (<span title="'._('ID istanza').': '.$row['ID'].'">'.$if.'</span>/'.$itot.')</div>'.N;
|
||
$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']);
|
||
$out.='<a href="https://'.hspech($row['URI']).'" title="'._('Vai all’istanza').'"><div class="iimgc"><img class="iimg" src="'.$row['Thumb'].'">';
|
||
if (!is_null($row['Priority'])) $out.='<img src="'.$prepath.'imgs/featured-it.svg" class="ifeat">';
|
||
$out.='</div></a>'.N;
|
||
$out.='<div class="icol">'.N;
|
||
$out.='<div><span class="ilab">'._('Nome').'</span> <a href="https://'.hspech($row['URI']).'" title="'._('Vai all’istanza').'">'.nully(hspech($row['Title'])).'</a></div>'.N;
|
||
/*$out.='<div><span class="ilab">'._('Consigliata').'</span> ';
|
||
(!is_null($row['Priority'])) ? $out.='<span class="ivgood">'._('Si!').'</span>' : $out.=_('No');
|
||
$out.='</div>'.N;*/
|
||
$out.='<div><span class="ilab">'._('Lingue').'</span> '.nully(implode(', ',$buf)).'</div>'.N;
|
||
$out.='<div><span class="ilab">'._('Utenti').'</span> '.nully($row['UserCount']).'</div>'.N;
|
||
$out.='<div><span class="ilab">'._('Utenti attiv* nell’ultimo mese').'</span> '.nully($row['ActiveUsersMonth']).'</div>'.N;
|
||
$out.='<div><span class="ilab">'._('Utenti attiv* negli ultimi sei mesi').'</span> '.nully($row['ActiveUsersHalfYear']).'</div>'.N;
|
||
$out.='<div><span class="ilab">'._('Istanze note a questa istanza').'</span> '.nully($row['DomainCount']).'</div>'.N;
|
||
$out.='</div>'.N;
|
||
|
||
$out.='<div class="icol">'.N;
|
||
$out.='<div><span class="ilab">'._('Caratteri per toot (max)').'</span> ';
|
||
if (nullemp($row['MaxTootChars']))
|
||
$out.='<span class="null">500</span>';
|
||
else
|
||
$out.=$row['MaxTootChars'];
|
||
$out.='</div>'.N;
|
||
$out.='<div><span class="ilab">'._('Nella blacklist').'</span> ';
|
||
($row['Blacklisted']==1) ? $out.='<span class="ibad">'._('Si').'</span>' : $out.='<span class="igood">'._('No').'</span>';
|
||
$out.='</div>'.N;
|
||
$out.='<div><span class="ilab">'._('Nuova').'</span> ';
|
||
($row['New']==1) ? $out.='<span class="ivgood">'._('Si!').'</span>' : $out.=_('No');
|
||
$out.='</div>'.N;
|
||
$out.='<div><span class="ilab">'._('Versione mastodon').'</span> '.nully(hspech($row['Version'])).'</div>'.N;
|
||
|
||
$out.='<div><span class="ilab">'._('Iscrizioni').'</span> ';
|
||
($row['RegReqApproval']==1) ? $buf=' <span class="iwarn">('._('con approvazione admin').')</span>' : $buf='';
|
||
if (nullemp($row['RegOpen']))
|
||
$out.='<span class="null">'._('Non disponibile').'</span>';
|
||
elseif ($row['RegOpen']==1)
|
||
$out.='<span class="igood">'._('Aperte').'</span>'.$buf;
|
||
else
|
||
$out.='<span class="iwarn">'._('Chiuse').'</span>';
|
||
$out.='</div>'.N;
|
||
$out.='<div><span class="ilab">'._('E-mail').'</span> ';
|
||
if (nullemp($row['Email']))
|
||
$out.='<span class="null">'._('Non disponibile').'</span>';
|
||
else
|
||
$out.='<a href="mailto:'.$row['Email'].'">'.$row['Email'].'</a>';
|
||
$out.='</div>'.N;
|
||
$out.='</div>'.N;
|
||
|
||
$out.='<div><span class="ilab">'._('Hashtag più usati nell’ultima settimana').'</span> ';
|
||
$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 {
|
||
$out.='<span class="null">'._('Non disponibili').'</span>';
|
||
}
|
||
$out.='</div>'.N;
|
||
|
||
$out.='<div><div class="idlab">'._('Descrizione breve').'</div><div class="idesc">'.nully(strip(nl2br(trim($row['ShortDesc']),false),$row['URI'])).'</div></div>'.N;
|
||
$out.='<div><div class="idlab">'._('Descrizione lunga').'</div><div class="idesc">'.nully(strip(trim($row['LongDesc']),$row['URI'])).'</div></div>'.N;
|
||
|
||
$out.='<div class="abox"><img class="aimg" src="'.$row['AdmAvatar'].'"><div><span class="ilab">'._('Account admin').'</span> '.nully(hspech($row['AdmAccount'])).'</div><div><span class="ilab">'._('Data di creazione').'</span> '.nully(ldate($row['AdmCreatedAt'],true)).'</div><div><span class="ilab">'._('Nome admin').'</span> '.nully(hspech($row['AdmDisplayName'])).'</div><div><div class="idlab">'._('Note admin').'</div><div class="inote">'.nully(strip(trim($row['AdmNote']),$row['URI'])).'</div>'.N;
|
||
$out.='</div></div>';
|
||
|
||
$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;
|
||
$out.='<div class="ghost"><div class="idlab">'._('Statistiche').'</div><div class="istat"><div class="dida" style="margin:0">'._('Ultimi check (verde: OK; rosso: KO)').'</div><table class="cbar"><tr>';
|
||
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;
|
||
$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);
|
||
$out.='<div class="dida">'._('Attività delle ultime 12 settimane');
|
||
if (mysqli_num_rows($rres)>0) {
|
||
$rrow=mysqli_fetch_assoc($rres);
|
||
if ($rrow['cnt']>0)
|
||
$out.=' ('._('totali:').' '.$rrow['tstatuses'].' '._('stati').', '.$rrow['tlogins'].' '._('accessi').', '.$rrow['tregs'].' '._('iscrizioni').')';
|
||
}
|
||
$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))
|
||
// initials for Statuses, Logins, Registrations
|
||
$out.='<td width="'.(100/$tot).'%">'._('S').': '.$rrow['Statuses'].'<br>'._('A').': '.$rrow['Logins'].'<br>'._('I').': '.$rrow['Registrations'].'</td>';
|
||
} else {
|
||
$out.='<td><span class="null">'._('Non disponibile').'</span></td>';
|
||
}
|
||
$out.='</tr></table>'.N;
|
||
$out.='</div></div>'.N;
|
||
|
||
$out.='</div>'.N;
|
||
echo($out);
|
||
}
|
||
mysqli_close($link);
|
||
?>
|