Don’t show search interface when showing a single instance
This commit is contained in:
parent
c1a4a29edc
commit
2b0bfde063
1 changed files with 218 additions and 213 deletions
|
@ -51,6 +51,9 @@ $minaumax=4294967295;
|
|||
$mincdef='""';
|
||||
$mincmax=16777215;
|
||||
|
||||
$link=mysqli_connect($conf['db_host'],$conf['db_user_name'],$conf['db_user_password'],$conf['db_name'],$conf['db_port'],$conf['db_socket']) or muorimeglio(_('Couldn’t connect to database: ').mysqli_connect_error().' ['.mysqli_connect_errno().']',false);
|
||||
mysqli_set_charset($link,'utf8mb4');
|
||||
|
||||
// if and when ... put it soon after </nav> below
|
||||
/*<div id="popupback">
|
||||
<div id="fseenhelp" class="dhelp">
|
||||
|
@ -61,8 +64,14 @@ $mincmax=16777215;
|
|||
echo('</nav>
|
||||
<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();">
|
||||
<section class="sectcontm">'.N);
|
||||
|
||||
if ($single) {
|
||||
echo('<p><a href="instances/'.$dlang.'">← '._('Back to search').'</a></p>'.N);
|
||||
$p=1;
|
||||
$que='SELECT * FROM Instances WHERE ID='.$_GET['id'];
|
||||
} else {
|
||||
echo('<img src="'.$prepath.'imgs/helpbutti.svg" id="helpbutt" class="helpb" onmouseover="swhelpi(true);" onmouseout="swhelpi(false);" onclick="swhelp();">
|
||||
<h3>'._('Instances').'</h3>
|
||||
<script language="JavaScript">
|
||||
|
||||
|
@ -117,239 +126,235 @@ function presub() {
|
|||
</script>
|
||||
'.N);
|
||||
|
||||
$link=mysqli_connect($conf['db_host'],$conf['db_user_name'],$conf['db_user_password'],$conf['db_name'],$conf['db_port'],$conf['db_socket']) or muorimeglio(_('Couldn’t connect to database: ').mysqli_connect_error().' ['.mysqli_connect_errno().']',false);
|
||||
mysqli_set_charset($link,'utf8mb4');
|
||||
$res=mysqli_query($link,'SELECT COUNT(ID) AS tinsts, SUM(UserCount) AS tusers, SUM(StatusCount) AS tstatuses, SUM(ActiveUsersMonth) AS tactusers FROM Instances WHERE Instances.IsMastodon=1 AND Instances.LastOkCheckTS>='.$graceline) or muorimeglio(__LINE__.': '.mysqli_error($link),true);
|
||||
$row=mysqli_fetch_assoc($res);
|
||||
echo(_('<div id="help" class="helpd"><p class="intro">This search engine for Mastodon instances is based on a database that gets updated by our crawler every night (CET). Instances are considered new for 30 days after they are discovered. When an instance has not responded to our daily checks for more than 30 days it’s no longer considered in statistics and searches and it gets checked only on the first of the month, rather than daily, until it possibly responds again. “Random ordering” of results varies daily.</p><p class="intro">Default search criteria reflect our fondness for a decentralized and egalitarian Fediverse and our attempt to exclude instances accepting fascist, racist, sexist, ableist or sovereignist contents by marking them as noxious.</p></div>').N);
|
||||
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, fnum($row['tinsts'],0,$dlang), fnum($row['tusers'],0,$dlang), fnum($row['tactusers'],0,$dlang), fnum($row['tstatuses'],0,$dlang));
|
||||
|
||||
$res=mysqli_query($link,'SELECT COUNT(ID) AS tinsts, SUM(UserCount) AS tusers, SUM(StatusCount) AS tstatuses, SUM(ActiveUsersMonth) AS tactusers FROM Instances WHERE Instances.IsMastodon=1 AND Instances.LastOkCheckTS>='.$graceline) or muorimeglio(__LINE__.': '.mysqli_error($link),true);
|
||||
$row=mysqli_fetch_assoc($res);
|
||||
echo(_('<div id="help" class="helpd"><p class="intro">This search engine for Mastodon instances is based on a database that gets updated by our crawler every night (CET). Instances are considered new for 30 days after they are discovered. When an instance has not responded to our daily checks for more than 30 days it’s no longer considered in statistics and searches and it gets checked only on the first of the month, rather than daily, until it possibly responds again. “Random ordering” of results varies daily.</p><p class="intro">Default search criteria reflect our fondness for a decentralized and egalitarian Fediverse and our attempt to exclude instances accepting fascist, racist, sexist, ableist or sovereignist contents by marking them as noxious.</p></div>').N);
|
||||
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, fnum($row['tinsts'],0,$dlang), fnum($row['tusers'],0,$dlang), fnum($row['tactusers'],0,$dlang), fnum($row['tstatuses'],0,$dlang));
|
||||
|
||||
if ((array_key_exists('exnox',$_GET) && $_GET['exnox']=='1') || !array_key_exists('exnox',$_GET)) {
|
||||
$_GET['cbexnox']=' checked';
|
||||
$_GET['exnox']=1;
|
||||
} else {
|
||||
$_GET['cbexnox']='';
|
||||
$_GET['exnox']=0;
|
||||
}
|
||||
|
||||
if ((array_key_exists('exregc',$_GET) && $_GET['exregc']=='1') || !array_key_exists('exregc',$_GET)) {
|
||||
$_GET['cbexregc']=' checked';
|
||||
$_GET['exregc']=1;
|
||||
} else {
|
||||
$_GET['cbexregc']='';
|
||||
$_GET['exregc']=0;
|
||||
}
|
||||
|
||||
if (array_key_exists('exappr',$_GET) && $_GET['exappr']=='1') {
|
||||
$_GET['cbexappr']=' checked';
|
||||
$_GET['exappr']=1;
|
||||
} else {
|
||||
$_GET['cbexappr']='';
|
||||
$_GET['exappr']=0;
|
||||
}
|
||||
|
||||
if (array_key_exists('exlcko',$_GET) && $_GET['exlcko']=='1') {
|
||||
$_GET['cbexlcko']=' checked';
|
||||
$_GET['exlcko']=1;
|
||||
} else {
|
||||
$_GET['cbexlcko']='';
|
||||
$_GET['exlcko']=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'];
|
||||
if ((array_key_exists('exnox',$_GET) && $_GET['exnox']=='1') || !array_key_exists('exnox',$_GET)) {
|
||||
$_GET['cbexnox']=' checked';
|
||||
$_GET['exnox']=1;
|
||||
} else {
|
||||
$_GET['lang']=0;
|
||||
$_GET['cbexnox']='';
|
||||
$_GET['exnox']=0;
|
||||
}
|
||||
}
|
||||
if ($_GET['lang']>5000000000) $_GET['lang']=0;
|
||||
|
||||
if (array_key_exists('desc',$_GET) && preg_match('#^.+$#',$_GET['lang'])===1)
|
||||
$_GET['desc']=trim(n2es($_GET['desc']));
|
||||
else
|
||||
$_GET['desc']='';
|
||||
if (mb_strlen($_GET['desc'])>64) $_GET['desc']='';
|
||||
if ((array_key_exists('exregc',$_GET) && $_GET['exregc']=='1') || !array_key_exists('exregc',$_GET)) {
|
||||
$_GET['cbexregc']=' checked';
|
||||
$_GET['exregc']=1;
|
||||
} else {
|
||||
$_GET['cbexregc']='';
|
||||
$_GET['exregc']=0;
|
||||
}
|
||||
|
||||
ckgnum('minu',$minudef,$minumax);
|
||||
ckgnum('maxu',$maxudef,$maxumax);
|
||||
if (is_int($_GET['maxu']) && is_int($_GET['minu']) && $_GET['maxu']<$_GET['minu']) $_GET['maxu']=$_GET['minu'];
|
||||
ckgnum('minau',$minaudef,$minaumax);
|
||||
ckgnum('minc',$mincdef,$mincmax);
|
||||
if (array_key_exists('exappr',$_GET) && $_GET['exappr']=='1') {
|
||||
$_GET['cbexappr']=' checked';
|
||||
$_GET['exappr']=1;
|
||||
} else {
|
||||
$_GET['cbexappr']='';
|
||||
$_GET['exappr']=0;
|
||||
}
|
||||
|
||||
$order=array(
|
||||
'rand'=>array('t'=>_('Random, recommended first'),'q'=>'Instances.Priority DESC, Instances.RPos ASC'),
|
||||
'invold'=>array('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'),
|
||||
'fseend'=>array('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'),
|
||||
'tusersd'=>array('t'=>_('By number of users, descending'),'q'=>'Instances.UserCount DESC'),
|
||||
'tusersa'=>array('t'=>_('By number of users, ascending'),'q'=>'Instances.UserCount ASC'),
|
||||
'ausersd'=>array('t'=>_('By number of active users, descending'),'q'=>'Instances.ActiveUsersMonth DESC'),
|
||||
'ausersa'=>array('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'),
|
||||
'checksa'=>array('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'),
|
||||
'charsa'=>array('t'=>_('By available characters per post, ascending'),'q'=>'Instances.MaxTootChars ASC'),
|
||||
'noxd'=>array('t'=>_('Noxious first (switches off “Exclude noxious”)'),'q'=>'Instances.Noxious DESC')
|
||||
);
|
||||
if (!array_key_exists('ord',$_GET) || !array_key_exists($_GET['ord'],$order))
|
||||
$_GET['ord']='rand';
|
||||
// we have recommended instances only for it language, so...
|
||||
$withreclangids=[306];
|
||||
if (!in_array($_GET['lang'],$withreclangids)) $order['rand']=array('t'=>_('Random'),'q'=>'Instances.RPos ASC');
|
||||
if (array_key_exists('exlcko',$_GET) && $_GET['exlcko']=='1') {
|
||||
$_GET['cbexlcko']=' checked';
|
||||
$_GET['exlcko']=1;
|
||||
} else {
|
||||
$_GET['cbexlcko']='';
|
||||
$_GET['exlcko']=0;
|
||||
}
|
||||
|
||||
$p=1;
|
||||
if (array_key_exists('p',$_GET) && preg_match('#^[0-9]+$#',$_GET['p'])===1) $p=$_GET['p']+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;
|
||||
|
||||
echo('<form method="get" id="curvf" name="curvf">
|
||||
<input name="exnox" type="hidden" value="'.$_GET['exnox'].'">
|
||||
<input name="exregc" type="hidden" value="'.$_GET['exregc'].'">
|
||||
<input name="exappr" type="hidden" value="'.$_GET['exappr'].'">
|
||||
<input name="exlcko" type="hidden" value="'.$_GET['exlcko'].'">
|
||||
<input name="lang" type="hidden" value="'.$_GET['lang'].'">
|
||||
<input name="desc" type="hidden" value="'.htmlentities($_GET['desc']).'">
|
||||
<input name="minu" type="hidden" value="'.$_GET['minu'].'">
|
||||
<input name="maxu" type="hidden" value="'.$_GET['maxu'].'">
|
||||
<input name="minau" type="hidden" value="'.$_GET['minau'].'">
|
||||
<input name="minc" type="hidden" value="'.$_GET['minc'].'">
|
||||
<input name="ord" type="hidden" value="'.$_GET['ord'].'">
|
||||
<input name="p" type="hidden" value="'.$p.'">
|
||||
</form>'.N);
|
||||
if (array_key_exists('desc',$_GET) && preg_match('#^.+$#',$_GET['lang'])===1)
|
||||
$_GET['desc']=trim(n2es($_GET['desc']));
|
||||
else
|
||||
$_GET['desc']='';
|
||||
if (mb_strlen($_GET['desc'])>64) $_GET['desc']='';
|
||||
|
||||
($_GET['lang']==0) ? $selected=' selected' : $selected='';
|
||||
ckgnum('minu',$minudef,$minumax);
|
||||
ckgnum('maxu',$maxudef,$maxumax);
|
||||
if (is_int($_GET['maxu']) && is_int($_GET['minu']) && $_GET['maxu']<$_GET['minu']) $_GET['maxu']=$_GET['minu'];
|
||||
ckgnum('minau',$minaudef,$minaumax);
|
||||
ckgnum('minc',$mincdef,$mincmax);
|
||||
|
||||
echo('<form method="get" id="searchf" class="sdbox" onsubmit="presub();">
|
||||
<div class="sdtit">'._('Search criteria').'</div>
|
||||
<div class="sddesc">'._('Show instances where...').'</div>
|
||||
<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="sdinput">
|
||||
<select id="lang" name="lang" class="sselect">
|
||||
<option value="0"'.$selected.'>'._('Irrelevant').'</option>'.N);
|
||||
$order=array(
|
||||
'rand'=>array('t'=>_('Random, recommended first'),'q'=>'Instances.Priority DESC, Instances.RPos ASC'),
|
||||
'invold'=>array('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'),
|
||||
'fseend'=>array('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'),
|
||||
'tusersd'=>array('t'=>_('By number of users, descending'),'q'=>'Instances.UserCount DESC'),
|
||||
'tusersa'=>array('t'=>_('By number of users, ascending'),'q'=>'Instances.UserCount ASC'),
|
||||
'ausersd'=>array('t'=>_('By number of active users, descending'),'q'=>'Instances.ActiveUsersMonth DESC'),
|
||||
'ausersa'=>array('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'),
|
||||
'checksa'=>array('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'),
|
||||
'charsa'=>array('t'=>_('By available characters per post, ascending'),'q'=>'Instances.MaxTootChars ASC'),
|
||||
'noxd'=>array('t'=>_('Noxious first (switches off “Exclude noxious”)'),'q'=>'Instances.Noxious DESC')
|
||||
);
|
||||
if (!array_key_exists('ord',$_GET) || !array_key_exists($_GET['ord'],$order))
|
||||
$_GET['ord']='rand';
|
||||
// we have recommended instances only for it language, so...
|
||||
$withreclangids=[306];
|
||||
if (!in_array($_GET['lang'],$withreclangids)) $order['rand']=array('t'=>_('Random'),'q'=>'Instances.RPos ASC');
|
||||
|
||||
$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);
|
||||
$p=1;
|
||||
if (array_key_exists('p',$_GET) && preg_match('#^[0-9]+$#',$_GET['p'])===1) $p=$_GET['p']+0;
|
||||
|
||||
while ($row=mysqli_fetch_assoc($res)) {
|
||||
($_GET['lang']==$row['Lid']) ? $selected=' selected' : $selected='';
|
||||
echo('<option value="'.$row['Lid'].'"'.$selected.'>'.$row['Txt'].'</option>'.N);
|
||||
}
|
||||
echo('<form method="get" id="curvf" name="curvf">
|
||||
<input name="exnox" type="hidden" value="'.$_GET['exnox'].'">
|
||||
<input name="exregc" type="hidden" value="'.$_GET['exregc'].'">
|
||||
<input name="exappr" type="hidden" value="'.$_GET['exappr'].'">
|
||||
<input name="exlcko" type="hidden" value="'.$_GET['exlcko'].'">
|
||||
<input name="lang" type="hidden" value="'.$_GET['lang'].'">
|
||||
<input name="desc" type="hidden" value="'.htmlentities($_GET['desc']).'">
|
||||
<input name="minu" type="hidden" value="'.$_GET['minu'].'">
|
||||
<input name="maxu" type="hidden" value="'.$_GET['maxu'].'">
|
||||
<input name="minau" type="hidden" value="'.$_GET['minau'].'">
|
||||
<input name="minc" type="hidden" value="'.$_GET['minc'].'">
|
||||
<input name="ord" type="hidden" value="'.$_GET['ord'].'">
|
||||
<input name="p" type="hidden" value="'.$p.'">
|
||||
</form>'.N);
|
||||
|
||||
echo('</select>
|
||||
</div>
|
||||
</div>
|
||||
<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="sdinput"><input type="text" id="desc" name="desc" class="sinput" maxlength="64" value="'.hspech($_GET['desc']).'" autofocus></div>
|
||||
</div>
|
||||
($_GET['lang']==0) ? $selected=' selected' : $selected='';
|
||||
|
||||
<div class="sdrow">
|
||||
<div class="sdlabel"><label for="minu" title="'._('Include only instances which have at least this number of users [set to empty to disable this criterion]').'">'._('Users are at least').'</label></div>
|
||||
<div class="sdinput"><input type="number" id="minu" name="minu" min="0" max="'.$minumax.'" class="sinput" value="'.$_GET['minu'].'"></div>
|
||||
</div>
|
||||
<div class="sdrow">
|
||||
<div class="sdlabel"><label for="maxu" title="'._('Include only instances which have at most this number of users [set to empty to disable this criterion]').'">'._('Users are at most').'</label></div>
|
||||
<div class="sdinput"><input type="number" id="maxu" name="maxu" min="0" max="'.$maxumax.'" class="sinput" value="'.$_GET['maxu'].'"></div>
|
||||
</div>
|
||||
<div class="sdrow">
|
||||
<div class="sdlabel"><label for="minau" title="'._('Include only instances which had at least this number of active users during the last 30 days [set to empty to disable this criterion]').'">'._('Active users are at least').'</label></div>
|
||||
<div class="sdinput"><input type="number" id="minau" name="minau" min="0" max="'.$minaumax.'" class="sinput" value="'.$_GET['minau'].'"></div>
|
||||
</div>
|
||||
<div class="sdrow">
|
||||
<div class="sdlabel"><label for="minc" title="'._('Include only instances on which the number of available characters per post is at least this [set to empty to disable this criterion]').'">'._('Max. chars per post are at least').'</label></div>
|
||||
<div class="sdinput"><input type="number" id="minc" name="minc" min="0" max="'.$mincmax.'" class="sinput" value="'.$_GET['minc'].'"></div>
|
||||
</div>
|
||||
<div class="hrd"></div>
|
||||
<div class="sdrow">
|
||||
<div class="sdlabel"><label for="cbexnox" title="'._('Exclude noxious instances').'">'._('Exclude if noxious').'</label></div>
|
||||
<div class="sdinput">
|
||||
<input type="checkbox" class="sckbox" id="cbexnox" value="1"'.$_GET['cbexnox'].' onchange="sethid(\'exnox\');">
|
||||
<input type="hidden" id="exnox" name="exnox" value="'.$_GET['exnox'].'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="sdrow">
|
||||
<div class="sdlabel"><label for="cbexregc" title="'._('Exclude instances which don’t accept new registrations').'">'._('Exclude if registrations are closed').'</label></div>
|
||||
<div class="sdinput">
|
||||
<input type="checkbox" class="sckbox" id="cbexregc" value="1"'.$_GET['cbexregc'].' onchange="sethid(\'exregc\');">
|
||||
<input type="hidden" id="exregc" name="exregc" value="'.$_GET['exregc'].'">
|
||||
</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="sdinput">
|
||||
<input type="checkbox" class="sckbox" id="cbexappr" value="1"'.$_GET['cbexappr'].' onchange="sethid(\'exappr\');">
|
||||
<input type="hidden" id="exappr" name="exappr" value="'.$_GET['exappr'].'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="sdrow">
|
||||
<div class="sdlabel"><label for="cbexlcko" title="'._('Exclude instances which didn’t respond to last check').'">'._('Exclude if offline on last check').'</label></div>
|
||||
<div class="sdinput">
|
||||
<input type="checkbox" class="sckbox" id="cbexlcko" value="1"'.$_GET['cbexlcko'].' onchange="sethid(\'exlcko\');">
|
||||
<input type="hidden" id="exlcko" name="exlcko" value="'.$_GET['exlcko'].'">
|
||||
</div>
|
||||
</div>
|
||||
echo('<form method="get" id="searchf" class="sdbox" onsubmit="presub();">
|
||||
<div class="sdtit">'._('Search criteria').'</div>
|
||||
<div class="sddesc">'._('Show instances where...').'</div>
|
||||
<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="sdinput">
|
||||
<select id="lang" name="lang" class="sselect">
|
||||
<option value="0"'.$selected.'>'._('Irrelevant').'</option>'.N);
|
||||
|
||||
<div class="sdtitb">'._('Order of results').'</div>
|
||||
$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);
|
||||
|
||||
<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>
|
||||
while ($row=mysqli_fetch_assoc($res)) {
|
||||
($_GET['lang']==$row['Lid']) ? $selected=' selected' : $selected='';
|
||||
echo('<option value="'.$row['Lid'].'"'.$selected.'>'.$row['Txt'].'</option>'.N);
|
||||
}
|
||||
|
||||
<div class="sdlrow">
|
||||
<input type="submit" value="'._('Search').'" class="ssubmit">
|
||||
</div>
|
||||
echo('</select>
|
||||
</div>
|
||||
</div>
|
||||
<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="sdinput"><input type="text" id="desc" name="desc" class="sinput" maxlength="64" value="'.hspech($_GET['desc']).'" autofocus></div>
|
||||
</div>
|
||||
|
||||
<div class="sdlcrow">
|
||||
<input type="button" class="litbut" value="'._('Reset search').'" onclick="document.location.href=document.location.href.replace(/\\?.*$/,\'\')">
|
||||
</div>
|
||||
<div class="sdrow">
|
||||
<div class="sdlabel"><label for="minu" title="'._('Include only instances which have at least this number of users [set to empty to disable this criterion]').'">'._('Users are at least').'</label></div>
|
||||
<div class="sdinput"><input type="number" id="minu" name="minu" min="0" max="'.$minumax.'" class="sinput" value="'.$_GET['minu'].'"></div>
|
||||
</div>
|
||||
<div class="sdrow">
|
||||
<div class="sdlabel"><label for="maxu" title="'._('Include only instances which have at most this number of users [set to empty to disable this criterion]').'">'._('Users are at most').'</label></div>
|
||||
<div class="sdinput"><input type="number" id="maxu" name="maxu" min="0" max="'.$maxumax.'" class="sinput" value="'.$_GET['maxu'].'"></div>
|
||||
</div>
|
||||
<div class="sdrow">
|
||||
<div class="sdlabel"><label for="minau" title="'._('Include only instances which had at least this number of active users during the last 30 days [set to empty to disable this criterion]').'">'._('Active users are at least').'</label></div>
|
||||
<div class="sdinput"><input type="number" id="minau" name="minau" min="0" max="'.$minaumax.'" class="sinput" value="'.$_GET['minau'].'"></div>
|
||||
</div>
|
||||
<div class="sdrow">
|
||||
<div class="sdlabel"><label for="minc" title="'._('Include only instances on which the number of available characters per post is at least this [set to empty to disable this criterion]').'">'._('Max. chars per post are at least').'</label></div>
|
||||
<div class="sdinput"><input type="number" id="minc" name="minc" min="0" max="'.$mincmax.'" class="sinput" value="'.$_GET['minc'].'"></div>
|
||||
</div>
|
||||
<div class="hrd"></div>
|
||||
<div class="sdrow">
|
||||
<div class="sdlabel"><label for="cbexnox" title="'._('Exclude noxious instances').'">'._('Exclude if noxious').'</label></div>
|
||||
<div class="sdinput">
|
||||
<input type="checkbox" class="sckbox" id="cbexnox" value="1"'.$_GET['cbexnox'].' onchange="sethid(\'exnox\');">
|
||||
<input type="hidden" id="exnox" name="exnox" value="'.$_GET['exnox'].'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="sdrow">
|
||||
<div class="sdlabel"><label for="cbexregc" title="'._('Exclude instances which don’t accept new registrations').'">'._('Exclude if registrations are closed').'</label></div>
|
||||
<div class="sdinput">
|
||||
<input type="checkbox" class="sckbox" id="cbexregc" value="1"'.$_GET['cbexregc'].' onchange="sethid(\'exregc\');">
|
||||
<input type="hidden" id="exregc" name="exregc" value="'.$_GET['exregc'].'">
|
||||
</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="sdinput">
|
||||
<input type="checkbox" class="sckbox" id="cbexappr" value="1"'.$_GET['cbexappr'].' onchange="sethid(\'exappr\');">
|
||||
<input type="hidden" id="exappr" name="exappr" value="'.$_GET['exappr'].'">
|
||||
</div>
|
||||
</div>
|
||||
<div class="sdrow">
|
||||
<div class="sdlabel"><label for="cbexlcko" title="'._('Exclude instances which didn’t respond to last check').'">'._('Exclude if offline on last check').'</label></div>
|
||||
<div class="sdinput">
|
||||
<input type="checkbox" class="sckbox" id="cbexlcko" value="1"'.$_GET['cbexlcko'].' onchange="sethid(\'exlcko\');">
|
||||
<input type="hidden" id="exlcko" name="exlcko" value="'.$_GET['exlcko'].'">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" id="p" name="p" value="'.$p.'">
|
||||
</form>
|
||||
<div class="sdtitb">'._('Order of results').'</div>
|
||||
|
||||
<script language="JavaScript">
|
||||
swhelp();
|
||||
</script>'.N);
|
||||
<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>
|
||||
|
||||
$joins=array();
|
||||
$wheres=array();
|
||||
$wheres[]='Instances.IsMastodon=1 AND Instances.LastOkCheckTS>='.$graceline;
|
||||
if ($_GET['exnox']==1) $wheres[]='Instances.Noxious=0';
|
||||
if ($_GET['exregc']==1) $wheres[]='Instances.RegOpen=1';
|
||||
if ($_GET['exappr']==1) $wheres[]='Instances.RegReqApproval=0';
|
||||
if ($_GET['exlcko']==1) $wheres[]='Instances.WasLastCheckOk=1';
|
||||
/*if ($_GET['exlcko']==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.URI LIKE "%'.$buf.'%" OR Instances.Title LIKE "%'.$buf.'%" OR Instances.ShortDesc LIKE "%'.$buf.'%" OR Instances.LongDesc LIKE "%'.$buf.'%")';
|
||||
if ($_GET['minu']!='') $wheres[]='Instances.UserCount>='.$_GET['minu'];
|
||||
if ($_GET['maxu']!='') $wheres[]='Instances.UserCount<='.$_GET['maxu'];
|
||||
if ($_GET['minau']!='') $wheres[]='Instances.ActiveUsersMonth>='.$_GET['minau'];
|
||||
if ($_GET['minc']!='' && $_GET['minc']!='""') $wheres[]='Instances.MaxTootChars>='.$_GET['minc'];
|
||||
$joins=implode(' ',$joins);
|
||||
$wheres='WHERE '.implode(' AND ',$wheres);
|
||||
if (!$single)
|
||||
<div class="sdlrow">
|
||||
<input type="submit" value="'._('Search').'" class="ssubmit">
|
||||
</div>
|
||||
|
||||
<div class="sdlcrow">
|
||||
<input type="button" class="litbut" value="'._('Reset search').'" onclick="document.location.href=document.location.href.replace(/\\?.*$/,\'\')">
|
||||
</div>
|
||||
|
||||
<input type="hidden" id="p" name="p" value="'.$p.'">
|
||||
</form>
|
||||
|
||||
<script language="JavaScript">
|
||||
swhelp();
|
||||
</script>'.N);
|
||||
|
||||
$joins=array();
|
||||
$wheres=array();
|
||||
$wheres[]='Instances.IsMastodon=1 AND Instances.LastOkCheckTS>='.$graceline;
|
||||
if ($_GET['exnox']==1) $wheres[]='Instances.Noxious=0';
|
||||
if ($_GET['exregc']==1) $wheres[]='Instances.RegOpen=1';
|
||||
if ($_GET['exappr']==1) $wheres[]='Instances.RegReqApproval=0';
|
||||
if ($_GET['exlcko']==1) $wheres[]='Instances.WasLastCheckOk=1';
|
||||
/*if ($_GET['exlcko']==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.URI LIKE "%'.$buf.'%" OR Instances.Title LIKE "%'.$buf.'%" OR Instances.ShortDesc LIKE "%'.$buf.'%" OR Instances.LongDesc LIKE "%'.$buf.'%")';
|
||||
if ($_GET['minu']!='') $wheres[]='Instances.UserCount>='.$_GET['minu'];
|
||||
if ($_GET['maxu']!='') $wheres[]='Instances.UserCount<='.$_GET['maxu'];
|
||||
if ($_GET['minau']!='') $wheres[]='Instances.ActiveUsersMonth>='.$_GET['minau'];
|
||||
if ($_GET['minc']!='' && $_GET['minc']!='""') $wheres[]='Instances.MaxTootChars>='.$_GET['minc'];
|
||||
$joins=implode(' ',$joins);
|
||||
$wheres='WHERE '.implode(' AND ',$wheres);
|
||||
$que='SELECT * FROM Instances '.$joins.' '.$wheres.' ORDER BY '.$order[$_GET['ord']]['q'];
|
||||
else
|
||||
$que='SELECT * FROM Instances WHERE ID='.$_GET['id'];
|
||||
}
|
||||
|
||||
$debug.='QUERY: «'.$que.'»'.N;
|
||||
$qbt=microtime(true);
|
||||
$res=mysqli_query($link,$que) or muorimeglio(__LINE__.': '.mysqli_error($link),true);
|
||||
|
|
Loading…
Reference in a new issue