diff --git a/web/admin/instances.php b/web/admin/instances.php
index 745ad94..205a8d4 100644
--- a/web/admin/instances.php
+++ b/web/admin/instances.php
@@ -137,9 +137,9 @@ $cols=array(
'TagID'=>array('name'=>'[Tags]','type'=>'join','join'=>array('InstTags ON InstTags.InstID=Instances.ID')),
'Tags.Name'=>array('name'=>'Tags','type'=>'join','joini'=>array('InstTags ON InstTags.InstID=Instances.ID','Tags ON Tags.ID=InstTags.TagID'),'subtype'=>'text'),
- 'Statuses'=>array('name'=>'Stati ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','select'=>'MAX(Week) AS maxweek'),
+ /*'Statuses'=>array('name'=>'Stati ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','select'=>'MAX(Week) AS maxweek'),
'Logins'=>array('name'=>'Logins ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','select'=>'MAX(Week) AS maxweek'),
- 'Registrations'=>array('name'=>'Registrazioni ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','select'=>'MAX(Week) AS maxweek'),
+ 'Registrations'=>array('name'=>'Registrazioni ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','select'=>'MAX(Week) AS maxweek'),*/
);
$types=array('bool','int','time','text','join','joini');
@@ -188,25 +188,39 @@ foreach ($cols as $key=>$val) {
[condsel-6] => =
[valuesel-6] => 20
[closepar-6] => null
+[andor-6] => AND
*/
+$i=0;
+$jsaddrows='';
+$jssetrows='';
+$cp=count($_POST)/6; // /6 perché ogni "blocco" contiene 6 righe
$sels=array();
$joins=array();
$where='';
foreach ($_POST as $key=>$val) {
- if (preg_match('/^openpar-\d+/',$key)===1 && preg_match('/^\(+$/',$val)===1)
- $where.=$val;
+ if (preg_match('/^openpar-\d+/',$key)===1) {
+ $i++;
+ if (preg_match('/^\(+$/',$val)===1)
+ $where.=$val;
+ $jsaddrows.='addrow('.$i.',false);'.N;
+ $jssetrows.='setrow('.$i.','.json_encode($val);
+ }
if (preg_match('/^fieldsel-\d+/',$key)===1 && preg_match('/^(.+)§(.+)§(.+)$/',$val,$buf)===1) {
- if (array_key_exists($buf[1],$cols) && in_array($buf[2],$types)) {
- $where.=$buf[1];
- if ($buf[2]=='join' || $buf[2]=='joini') {
- foreach ($cols[$buf[1]]['join'] as $join) {
+ $col=$buf[1];
+ $type=$buf[2];
+ $subtype=$buf[3];
+ if (array_key_exists($col,$cols) && in_array($type,$types)) {
+ $where.=$col;
+ if ($type=='join' || $type=='joini') {
+ foreach ($cols[$col]['join'] as $join) {
if (!in_array($join,$joins))
$joins[]=$join;
}
- if ($buf[2]=='joini' && array_key_exists('select',$cols[$buf[1]]) && !in_array($cols[$buf[1]]['select'],$sels))
- $sels[]=$cols[$buf[1]]['select'];
+ if ($type=='joini' && array_key_exists('select',$cols[$col]) && !in_array($cols[$col]['select'],$sels))
+ $sels[]=$cols[$col]['select'];
}
+ $jssetrows.=','.json_encode($val);
} else {
muoribene($dbg.'
Dati POST corrotti.
Puoi riprovare o tornare al login.',true);
}
@@ -214,19 +228,35 @@ foreach ($_POST as $key=>$val) {
if (preg_match('/^condsel-\d+/',$key)===1) {
$where.=' '.$val.' ';
$cond=$val;
+ $jssetrows.=','.json_encode($val);
}
- if (preg_match('/^valuesel-\d+/',$key)===1)
+ if (preg_match('/^valuesel-\d+/',$key)===1) {
$where.=$val;
+ $jssetrows.=','.json_encode($val);
+ $jssetrows.=',""';
+ }
if (preg_match('/^valueinp-\d+/',$key)===1) {
if (preg_match('/^(LIKE|NOT LIKE)$/',$cond)===1)
$where.='\'%'.myesc($link,$val).'%\'';
else
$where.='\''.myesc($link,$val).'\'';
+ $jssetrows.=',""';
+ $jssetrows.=','.json_encode($val);
}
- if (preg_match('/^closepar-\d+/',$key)===1 && preg_match('/^\)+$/',$val)===1)
- $where.=$val;
- if (preg_match('/^andor-\d+/',$key)===1 && preg_match('/^(AND|OR)$/',$val)===1)
- $where.=' '.$val.' ';
+ if (preg_match('/^closepar-\d+/',$key)===1) {
+ if (preg_match('/^\)+$/',$val)===1)
+ $where.=$val;
+ $jssetrows.=','.json_encode($val);
+ }
+ if (preg_match('/^andor-\d+/',$key)===1 && preg_match('/^(AND|OR)$/',$val)===1) {
+ if ($i<$cp)
+ $where.=' '.$val.' ';
+ $jssetrows.=','.json_encode($val).');'.N;
+ }
+}
+if ($jsaddrows!='') {
+ $jsaddrows.='document.getElementById("filbut").value="Rimuovi tutti i criteri di ricerca";'.N;
+ $jsaddrows.='synctai();'.N;
}
if (count($sels)>0)
@@ -242,10 +272,10 @@ else
$query='SELECT *, Instances.ID AS IID'.$sels.' FROM Instances '.$joins.' '.$where.' GROUP BY IID ORDER BY Instances.URI ASC LIMIT 50';
$dbg.='QUERONA: '.$query.'
'.N;
+$tini=microtime(true);
$res=mysqli_query($link,$query)
or muoribene($dbg.'
'.$query.': '.mysqli_error($link),true);
-
-
+$dbg.='Durata esecuzione query: '.round(microtime(true)-$tini,4).' sec.
'.N;
if (mysqli_num_rows($res)<1) {
$out='
Nessuna istanza da mostrare.
'.N; @@ -291,7 +321,7 @@ if (mysqli_num_rows($res)<1) { if (mysqli_num_rows($sres)>0) { $attr.='