To disable numeric “Advanced criteria” it’s now enough to set them empty; debug can be enabled with query param. “debug” set to “1”; other little changes

This commit is contained in:
pezcurrel 2022-12-03 17:16:34 +01:00
parent d64b0697a8
commit c50358df98

View file

@ -14,7 +14,7 @@ date_default_timezone_set($dtzbl[$dlang]);*/
$debug='';
$debug.='REQUEST_URI: '.$_SERVER['REQUEST_URI'].N;
$debug.='_GET: '.print_r($_GET,1);
$debug.='$_GET: '.print_r($_GET,1);
$debug.='LOCALE: '.$locale.N;
//$getc=count($_GET);
@ -34,20 +34,6 @@ echo('</nav>
<img src="'.$prepath.'imgs/helpbutti.svg" id="helpbutt" class="helpb" onmouseover="swhelpi(true);" onmouseout="swhelpi(false);" onclick="swhelp();">
<h3>'._('Instances').'</h3>
<script language="JavaScript">
let dbgsh=false;
function shdbg() {
let dbgd=document.getElementById(\'debug\');
let 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;
}
}
let mctrlsh=false;
function shmctrl() {
let mctrl=document.getElementById(\'mctrl\');
@ -168,8 +154,6 @@ printf(_('<p class="introe">We currently count <span class="statd">%s</span> Mas
// 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”
$maxuinp=10000000000;
if ((array_key_exists('noxious',$_GET) && $_GET['noxious']=='1') || !array_key_exists('noxious',$_GET)) {
$_GET['cbnoxious']=' checked';
$_GET['noxious']=1;
@ -225,31 +209,25 @@ 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;
function ckgnum($key,$def,$max) {
if (array_key_exists($key,$_GET)) {
$_GET[$key]=trim($_GET[$key]);
if (preg_match('#^[0-9]+$#',$_GET[$key])===1) {
$_GET[$key]=$_GET[$key]+0;
if ($_GET[$key]>$max) $_GET[$key]=$max;
} elseif ($_GET[$key]!='') {
$_GET[$key]=$def;
}
} else {
$_GET[$key]=$def;
}
}
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;
ckgnum('minu',10,10000000000);
ckgnum('maxu',30000,10000000000);
if (is_int($_GET['maxu']) && is_int($_GET['minu']) && $_GET['maxu']<$_GET['minu']) $_GET['maxu']=$_GET['minu'];
ckgnum('minau',10,10000000);
ckgnum('minki',500,100000);
$order=array(
'rand'=>array('t'=>_('Random, recommended first'),'q'=>'Instances.Priority DESC, Instances.RPos ASC'),
@ -316,19 +294,19 @@ echo('</select>
<div id="mctrl">
<div class="sdrow">
<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>
<div class="sdinput"><input type="number" id="minu" name="minu" min="0" max="'.$maxuinp.'" class="sinput" value="'.$_GET['minu'].'"></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)').'">'._('Minimum number of users is').'</label></div>
<div class="sdinput"><input type="number" id="minu" name="minu" min="0" max="10000000000" 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 (“0” disables this criterion)').'">'._('Maximum number of users is').'</label></div>
<div class="sdinput"><input type="number" id="maxu" name="maxu" min="0" max="'.$maxuinp.'" class="sinput" value="'.$_GET['maxu'].'"></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)').'">'._('Maximum number of users is').'</label></div>
<div class="sdinput"><input type="number" id="maxu" name="maxu" min="0" max="10000000000" 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 (“0” disables this criterion)').'">'._('Minimum number of active users is').'</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)').'">'._('Minimum number of active users is').'</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="'._('Include only instances which know at least this number of other instances (“0” disables this criterion)').'">'._('Minimum number of known instances is').'</label></div>
<div class="sdlabel"><label for="minki" title="'._('Include only instances which know at least this number of other instances (set to empty to disable this criterion)').'">'._('Minimum number of known instances is').'</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">
@ -376,8 +354,6 @@ foreach ($order as $key=>$buf) {
echo('</select>
</div>
<!-- <input type="button" class="litbut" id="dbgb" value="'._('Debug info').'" onclick="shdbg()" style="margin:0"> //-->
<div class="sdlrow">
<input type="submit" value="'._('Search').'" class="ssubmit">
</div>
@ -412,10 +388,10 @@ if ($_GET['lang']>0) {
}
$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']>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'];
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['minki']!='') $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'];
@ -425,7 +401,6 @@ $res=mysqli_query($link,$que) or muorimeglio(__LINE__.': '.mysqli_error($link),t
$debug.='MAIN QUERY EXEC TIME: '.(microtime(true)-$qbt).' sec.'.N;
$itot=mysqli_num_rows($res);
$debug.='RESULTS: '.$itot.N;
//echo('<div id="debug"><textarea spellcheck="false">'.$debug.'</textarea></div>'.N);
$ipp=10;// istanze per pagina
$if=$ipp*($p-1);
if ($if>=$itot) {
@ -597,6 +572,6 @@ echo('</div>'.N);
echo('</div>'.N);
$debug.='TOTAL RENDERING TIME: '.(microtime(true)-$bt).N;
//echo('<!--'.N.'--- DEBUG INFO ---'.N.$debug.'//-->'.N);
if (array_key_exists('debug',$_GET) && $_GET['debug']=='1') echo('<!--'.N.'--- DEBUG INFO ---'.N.$debug.'//-->'.N);
?>