Don’t show search interface when showing a single instance

This commit is contained in:
pezcurrel 2023-01-18 07:56:28 +01:00
parent c1a4a29edc
commit 2b0bfde063

View file

@ -51,6 +51,9 @@ $minaumax=4294967295;
$mincdef='""'; $mincdef='""';
$mincmax=16777215; $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(_('Couldnt connect to database: ').mysqli_connect_error().' ['.mysqli_connect_errno().']',false);
mysqli_set_charset($link,'utf8mb4');
// if and when ... put it soon after </nav> below // if and when ... put it soon after </nav> below
/*<div id="popupback"> /*<div id="popupback">
<div id="fseenhelp" class="dhelp"> <div id="fseenhelp" class="dhelp">
@ -61,8 +64,14 @@ $mincmax=16777215;
echo('</nav> echo('</nav>
<div class="scrwide"> <div class="scrwide">
<div class="scrwidein"> <div class="scrwidein">
<section class="sectcontm"> <section class="sectcontm">'.N);
<img src="'.$prepath.'imgs/helpbutti.svg" id="helpbutt" class="helpb" onmouseover="swhelpi(true);" onmouseout="swhelpi(false);" onclick="swhelp();">
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> <h3>'._('Instances').'</h3>
<script language="JavaScript"> <script language="JavaScript">
@ -117,52 +126,49 @@ function presub() {
</script> </script>
'.N); '.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(_('Couldnt connect to database: ').mysqli_connect_error().' ['.mysqli_connect_errno().']',false); $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);
mysqli_set_charset($link,'utf8mb4'); $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 its no longer considered in statistics and searches and it gets checked only on the first of the month, rather than daily, until it possibly responds again. “Random ordering” of results varies daily.</p><p class="intro">Default search criteria reflect our fondness for a decentralized and egalitarian Fediverse and our attempt to exclude instances accepting fascist, racist, sexist, ableist or sovereignist contents by marking them as noxious.</p></div>').N);
printf(_('<p class="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); if ((array_key_exists('exnox',$_GET) && $_GET['exnox']=='1') || !array_key_exists('exnox',$_GET)) {
$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 its no longer considered in statistics and searches and it gets checked only on the first of the month, rather than daily, until it possibly responds again. “Random ordering” of results varies daily.</p><p class="intro">Default search criteria reflect our fondness for a decentralized and egalitarian Fediverse and our attempt to exclude instances accepting fascist, racist, sexist, ableist or sovereignist contents by marking them as noxious.</p></div>').N);
printf(_('<p class="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['cbexnox']=' checked';
$_GET['exnox']=1; $_GET['exnox']=1;
} else { } else {
$_GET['cbexnox']=''; $_GET['cbexnox']='';
$_GET['exnox']=0; $_GET['exnox']=0;
} }
if ((array_key_exists('exregc',$_GET) && $_GET['exregc']=='1') || !array_key_exists('exregc',$_GET)) { if ((array_key_exists('exregc',$_GET) && $_GET['exregc']=='1') || !array_key_exists('exregc',$_GET)) {
$_GET['cbexregc']=' checked'; $_GET['cbexregc']=' checked';
$_GET['exregc']=1; $_GET['exregc']=1;
} else { } else {
$_GET['cbexregc']=''; $_GET['cbexregc']='';
$_GET['exregc']=0; $_GET['exregc']=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;
} else { } else {
$_GET['cbexappr']=''; $_GET['cbexappr']='';
$_GET['exappr']=0; $_GET['exappr']=0;
} }
if (array_key_exists('exlcko',$_GET) && $_GET['exlcko']=='1') { if (array_key_exists('exlcko',$_GET) && $_GET['exlcko']=='1') {
$_GET['cbexlcko']=' checked'; $_GET['cbexlcko']=' checked';
$_GET['exlcko']=1; $_GET['exlcko']=1;
} else { } else {
$_GET['cbexlcko']=''; $_GET['cbexlcko']='';
$_GET['exlcko']=0; $_GET['exlcko']=0;
} }
if (array_key_exists('lang',$_GET)) { if (array_key_exists('lang',$_GET)) {
if (preg_match('#^[0-9]+$#',$_GET['lang'])===1) if (preg_match('#^[0-9]+$#',$_GET['lang'])===1)
$_GET['lang']=$_GET['lang']+0; $_GET['lang']=$_GET['lang']+0;
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=mysqli_query($link,'SELECT ID FROM Languages WHERE Code="'.$dlang.'"') or muorimeglio(__LINE__.': '.mysqli_error($link),true);
if (mysqli_num_rows($res)>0) { if (mysqli_num_rows($res)>0) {
$row=mysqli_fetch_assoc($res); $row=mysqli_fetch_assoc($res);
@ -170,22 +176,22 @@ if (array_key_exists('lang',$_GET)) {
} else { } else {
$_GET['lang']=0; $_GET['lang']=0;
} }
} }
if ($_GET['lang']>5000000000) $_GET['lang']=0; if ($_GET['lang']>5000000000) $_GET['lang']=0;
if (array_key_exists('desc',$_GET) && preg_match('#^.+$#',$_GET['lang'])===1) if (array_key_exists('desc',$_GET) && preg_match('#^.+$#',$_GET['lang'])===1)
$_GET['desc']=trim(n2es($_GET['desc'])); $_GET['desc']=trim(n2es($_GET['desc']));
else else
$_GET['desc']=''; $_GET['desc']='';
if (mb_strlen($_GET['desc'])>64) $_GET['desc']=''; if (mb_strlen($_GET['desc'])>64) $_GET['desc']='';
ckgnum('minu',$minudef,$minumax); ckgnum('minu',$minudef,$minumax);
ckgnum('maxu',$maxudef,$maxumax); ckgnum('maxu',$maxudef,$maxumax);
if (is_int($_GET['maxu']) && is_int($_GET['minu']) && $_GET['maxu']<$_GET['minu']) $_GET['maxu']=$_GET['minu']; if (is_int($_GET['maxu']) && is_int($_GET['minu']) && $_GET['maxu']<$_GET['minu']) $_GET['maxu']=$_GET['minu'];
ckgnum('minau',$minaudef,$minaumax); ckgnum('minau',$minaudef,$minaumax);
ckgnum('minc',$mincdef,$mincmax); ckgnum('minc',$mincdef,$mincmax);
$order=array( $order=array(
'rand'=>array('t'=>_('Random, recommended first'),'q'=>'Instances.Priority DESC, Instances.RPos ASC'), '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'), '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'), 'invola'=>array('t'=>_('By users involvement (active users / users), ascending'),'q'=>'(Instances.ActiveUsersMonth / Instances.UserCount) ASC'),
@ -200,156 +206,155 @@ $order=array(
'charsd'=>array('t'=>_('By available characters per post, descending'),'q'=>'Instances.MaxTootChars DESC'), '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'), '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') '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)) 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... // we have recommended instances only for it language, so...
$withreclangids=[306]; $withreclangids=[306];
if (!in_array($_GET['lang'],$withreclangids)) $order['rand']=array('t'=>_('Random'),'q'=>'Instances.RPos ASC'); if (!in_array($_GET['lang'],$withreclangids)) $order['rand']=array('t'=>_('Random'),'q'=>'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;
echo('<form method="get" id="curvf" name="curvf"> echo('<form method="get" id="curvf" name="curvf">
<input name="exnox" type="hidden" value="'.$_GET['exnox'].'"> <input name="exnox" type="hidden" value="'.$_GET['exnox'].'">
<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="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'].'">
<input name="maxu" type="hidden" value="'.$_GET['maxu'].'"> <input name="maxu" type="hidden" value="'.$_GET['maxu'].'">
<input name="minau" type="hidden" value="'.$_GET['minau'].'"> <input name="minau" type="hidden" value="'.$_GET['minau'].'">
<input name="minc" type="hidden" value="'.$_GET['minc'].'"> <input name="minc" type="hidden" value="'.$_GET['minc'].'">
<input name="ord" type="hidden" value="'.$_GET['ord'].'"> <input name="ord" type="hidden" value="'.$_GET['ord'].'">
<input name="p" type="hidden" value="'.$p.'"> <input name="p" type="hidden" value="'.$p.'">
</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">
<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=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);
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>
<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>
</div> </div>
<div class="sdrow"> <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="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 class="sdinput"><input type="number" id="minu" name="minu" min="0" max="'.$minumax.'" class="sinput" value="'.$_GET['minu'].'"></div>
</div> </div>
<div class="sdrow"> <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="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 class="sdinput"><input type="number" id="maxu" name="maxu" min="0" max="'.$maxumax.'" class="sinput" value="'.$_GET['maxu'].'"></div>
</div> </div>
<div class="sdrow"> <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="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 class="sdinput"><input type="number" id="minau" name="minau" min="0" max="'.$minaumax.'" class="sinput" value="'.$_GET['minau'].'"></div>
</div> </div>
<div class="sdrow"> <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="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 class="sdinput"><input type="number" id="minc" name="minc" min="0" max="'.$mincmax.'" class="sinput" value="'.$_GET['minc'].'"></div>
</div> </div>
<div class="hrd"></div> <div class="hrd"></div>
<div class="sdrow"> <div class="sdrow">
<div class="sdlabel"><label for="cbexnox" title="'._('Exclude noxious instances').'">'._('Exclude if noxious').'</label></div> <div class="sdlabel"><label for="cbexnox" title="'._('Exclude noxious instances').'">'._('Exclude if noxious').'</label></div>
<div class="sdinput"> <div class="sdinput">
<input type="checkbox" class="sckbox" id="cbexnox" value="1"'.$_GET['cbexnox'].' onchange="sethid(\'exnox\');"> <input type="checkbox" class="sckbox" id="cbexnox" value="1"'.$_GET['cbexnox'].' onchange="sethid(\'exnox\');">
<input type="hidden" id="exnox" name="exnox" value="'.$_GET['exnox'].'"> <input type="hidden" id="exnox" name="exnox" value="'.$_GET['exnox'].'">
</div> </div>
</div> </div>
<div class="sdrow"> <div class="sdrow">
<div class="sdlabel"><label for="cbexregc" title="'._('Exclude instances which dont accept new registrations').'">'._('Exclude if registrations are closed').'</label></div> <div class="sdlabel"><label for="cbexregc" title="'._('Exclude instances which dont accept new registrations').'">'._('Exclude if registrations are closed').'</label></div>
<div class="sdinput"> <div class="sdinput">
<input type="checkbox" class="sckbox" id="cbexregc" value="1"'.$_GET['cbexregc'].' onchange="sethid(\'exregc\');"> <input type="checkbox" class="sckbox" id="cbexregc" value="1"'.$_GET['cbexregc'].' onchange="sethid(\'exregc\');">
<input type="hidden" id="exregc" name="exregc" value="'.$_GET['exregc'].'"> <input type="hidden" id="exregc" name="exregc" value="'.$_GET['exregc'].'">
</div> </div>
</div> </div>
<div class="sdrow"> <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\');">
<input type="hidden" id="exappr" name="exappr" value="'.$_GET['exappr'].'"> <input type="hidden" id="exappr" name="exappr" value="'.$_GET['exappr'].'">
</div> </div>
</div> </div>
<div class="sdrow"> <div class="sdrow">
<div class="sdlabel"><label for="cbexlcko" title="'._('Exclude instances which didnt respond to last check').'">'._('Exclude if offline on last check').'</label></div> <div class="sdlabel"><label for="cbexlcko" title="'._('Exclude instances which didnt respond to last check').'">'._('Exclude if offline on last check').'</label></div>
<div class="sdinput"> <div class="sdinput">
<input type="checkbox" class="sckbox" id="cbexlcko" value="1"'.$_GET['cbexlcko'].' onchange="sethid(\'exlcko\');"> <input type="checkbox" class="sckbox" id="cbexlcko" value="1"'.$_GET['cbexlcko'].' onchange="sethid(\'exlcko\');">
<input type="hidden" id="exlcko" name="exlcko" value="'.$_GET['exlcko'].'"> <input type="hidden" id="exlcko" name="exlcko" value="'.$_GET['exlcko'].'">
</div> </div>
</div> </div>
<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>
<div class="sdlrow"> <div class="sdlrow">
<input type="submit" value="'._('Search').'" class="ssubmit"> <input type="submit" value="'._('Search').'" class="ssubmit">
</div> </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 search').'" 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.'">
</form> </form>
<script language="JavaScript"> <script language="JavaScript">
swhelp(); swhelp();
</script>'.N); </script>'.N);
$joins=array(); $joins=array();
$wheres=array(); $wheres=array();
$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';
if ($_GET['exappr']==1) $wheres[]='Instances.RegReqApproval=0'; if ($_GET['exappr']==1) $wheres[]='Instances.RegReqApproval=0';
if ($_GET['exlcko']==1) $wheres[]='Instances.WasLastCheckOk=1'; if ($_GET['exlcko']==1) $wheres[]='Instances.WasLastCheckOk=1';
/*if ($_GET['exlcko']==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)'; $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['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)';
} }
$buf=preg_replace('#%#','\%',myesc($link,$_GET['desc'])); $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['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['minu']!='') $wheres[]='Instances.UserCount>='.$_GET['minu'];
if ($_GET['maxu']!='') $wheres[]='Instances.UserCount<='.$_GET['maxu']; if ($_GET['maxu']!='') $wheres[]='Instances.UserCount<='.$_GET['maxu'];
if ($_GET['minau']!='') $wheres[]='Instances.ActiveUsersMonth>='.$_GET['minau']; if ($_GET['minau']!='') $wheres[]='Instances.ActiveUsersMonth>='.$_GET['minau'];
if ($_GET['minc']!='' && $_GET['minc']!='""') $wheres[]='Instances.MaxTootChars>='.$_GET['minc']; if ($_GET['minc']!='' && $_GET['minc']!='""') $wheres[]='Instances.MaxTootChars>='.$_GET['minc'];
$joins=implode(' ',$joins); $joins=implode(' ',$joins);
$wheres='WHERE '.implode(' AND ',$wheres); $wheres='WHERE '.implode(' AND ',$wheres);
if (!$single)
$que='SELECT * FROM Instances '.$joins.' '.$wheres.' ORDER BY '.$order[$_GET['ord']]['q']; $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; $debug.='QUERY: «'.$que.'»'.N;
$qbt=microtime(true); $qbt=microtime(true);
$res=mysqli_query($link,$que) or muorimeglio(__LINE__.': '.mysqli_error($link),true); $res=mysqli_query($link,$que) or muorimeglio(__LINE__.': '.mysqli_error($link),true);