'));
} elseif ($filter=='htmlchars') {
return(hspech($val));
} elseif ($filter=='timestamp') {
return(strftime('%a %d %b %Y, %T',$val));
} elseif ($filter=='email') {
return(''.strip_tags($val).'');
} elseif ($filter=='url') {
return(''.strip_tags($val).'');
} elseif ($filter=='image') {
return('');
} elseif ($filter=='boolt') {
if ($val)
return('Si');
else
return('No');
} elseif ($filter=='boolf') {
if ($val)
return('Si');
else
return('No');
} else {
return($val);
}
} else {
if (is_null($ntext)) {
if ($fem)
return('Non definita');
else
return('Non definito');
}
else {
return(''.$ntext.'');
}
}
}
function booly($pre,$val,$nottoobad=false,$invcol=false) {
if ($val) {
if (!$invcol) {
$p=' ';
} else {
if (!$nottoobad) {
$p=' ';
} else {
$p=' ';
}
}
return($p.$pre.'SI ';
} else {
$p=' ';
}
} else {
$p=' ';
}
return($p.$pre.'NO Nessuna istanza da mostrare.'.print_r($_POST,1).'
';
/*SELECT *, Instances.ID AS IID, GROUP_CONCAT(OrdOurLanguages.NameIt ORDER BY OrdInstOurLangs.Pos ASC SEPARATOR '; ') AS OrdOurLangs FROM Instances LEFT JOIN InstOurLangs ON InstOurLangs.InstID=Instances.ID LEFT JOIN Languages AS OurLanguages ON OurLanguages.ID=InstOurLangs.OurLangID LEFT JOIN InstOurLangs AS OrdInstOurLangs ON OrdInstOurLangs.InstID=Instances.ID LEFT JOIN Languages AS OrdOurLanguages ON OrdOurLanguages.ID=OrdInstOurLangs.OurLangID WHERE OurLanguages.NameIT LIKE '%italiano%' GROUP BY IID LIMIT 50*/
$cols=array(
'Instances.New'=>array('field'=>'Instances.New','name'=>'Nuova','type'=>'bool'),
'Instances.Good'=>array('field'=>'Instances.Good','name'=>'Papabile','type'=>'bool'),
'Instances.Chosen'=>array('field'=>'Instances.Chosen','name'=>'Scelta','type'=>'bool'),
'Instances.Visible'=>array('field'=>'Instances.Visible','name'=>'Visibile','type'=>'bool'),
'Instances.Blacklisted'=>array('field'=>'Instances.Blacklisted','name'=>'Blacklistata','type'=>'bool'),
'Instances.URI'=>array('field'=>'Instances.URI','name'=>'URI','type'=>'text'),
'Instances.Title'=>array('field'=>'Instances.Title','name'=>'Titolo','type'=>'text'),
'Instances.ShortDesc'=>array('field'=>'Instances.ShortDesc','name'=>'Descrizione breve','type'=>'text'),
'Instances.LongDesc'=>array('field'=>'Instances.LongDesc','name'=>'Descrizione lunga','type'=>'text'),
'Instances.OurDesc'=>array('field'=>'Instances.OurDesc','name'=>'Descrizione nostra','type'=>'text'),
//--------------------------------
'Instances.LocalityID'=>array('field'=>'Instances.LocalityID','name'=>'Località ⮞','type'=>'join','join'=>array(),'ord'=>false),
'Localities.Locality'=>array('field'=>'Localities.Locality','name'=>'Località','type'=>'joini','join'=>array('Localities ON Localities.ID=Instances.LocalityID'),'subtype'=>'text'),
'Provinces.ID'=>array('field'=>'Provinces.ID','name'=>'Provincia ⮞','type'=>'join','join'=>array('Localities ON Localities.ID=Instances.LocalityID','Provinces ON Provinces.ID=Localities.ProvinceID'),'ord'=>false),
'Provinces.Province'=>array('field'=>'Provinces.Province','name'=>'Provincia','type'=>'joini','join'=>array('Localities ON Localities.ID=Instances.LocalityID','Provinces ON Provinces.ID=Localities.ProvinceID'),'subtype'=>'text'),
'Regions.ID'=>array('field'=>'Regions.ID','name'=>'Regione ⮞','type'=>'join','join'=>array('Localities ON Localities.ID=Instances.LocalityID','Provinces ON Provinces.ID=Localities.ProvinceID','Regions ON Regions.ID=Provinces.RegionID'),'ord'=>false),
'Regions.Region'=>array('field'=>'Regions.Region','name'=>'Regione','type'=>'joini','join'=>array('Localities ON Localities.ID=Instances.LocalityID','Provinces ON Provinces.ID=Localities.ProvinceID','Regions ON Regions.ID=Provinces.RegionID'),'subtype'=>'text'),
'States.ID'=>array('field'=>'States.ID','name'=>'Stato ⮞','type'=>'join','join'=>array('Localities ON Localities.ID=Instances.LocalityID','Provinces ON Provinces.ID=Localities.ProvinceID','Regions ON Regions.ID=Provinces.RegionID','States ON States.ID=Regions.StateID'),'ord'=>false),
'States.State'=>array('field'=>'States.State','name'=>'Stato','type'=>'joini','join'=>array('Localities ON Localities.ID=Instances.LocalityID','Provinces ON Provinces.ID=Localities.ProvinceID','Regions ON Regions.ID=Provinces.RegionID','States ON States.ID=Regions.StateID'),'subtype'=>'text'),
//--------------------------------
'Instances.Email'=>array('field'=>'Instances.Email','name'=>'Email di contatto','type'=>'text'),
'Instances.Software'=>array('field'=>'Instances.Software','name'=>'Software','type'=>'text'),
'Instances.Version'=>array('field'=>'Instances.Version','name'=>'Versione','type'=>'text'),
'Instances.UserCount'=>array('field'=>'Instances.UserCount','name'=>'Utenti','type'=>'int'),
'Instances.StatusCount'=>array('field'=>'Instances.StatusCount','name'=>'Stati','type'=>'int'),
'Instances.DomainCount'=>array('field'=>'Instances.DomainCount','name'=>'Istanze note','type'=>'int'),
'Instances.ActiveUsersMonth'=>array('field'=>'Instances.ActiveUsersMonth','name'=>'Utenti attivi (mese)','type'=>'int'),
'Instances.ActiveUsersHalfYear'=>array('field'=>'Instances.ActiveUsersHalfYear','name'=>'Utenti attivi (6 mesi)','type'=>'int'),
'Instances.Thumb'=>array('field'=>'Instances.Thumb','name'=>'Logo','type'=>'text','search'=>false,'ord'=>false),
'Instances.RegOpen'=>array('field'=>'Instances.RegOpen','name'=>'Registrazioni aperte','type'=>'bool'),
'Instances.RegReqApproval'=>array('field'=>'Instances.RegReqApproval','name'=>'Approvazione registrazioni','type'=>'bool'),
'Instances.MaxTootChars'=>array('field'=>'Instances.MaxTootChars','name'=>'Limite caratteri','type'=>'int'),
'Instances.AdmAccount'=>array('field'=>'Instances.AdmAccount','name'=>'Account admin','type'=>'text'),
'Instances.AdmDisplayName'=>array('field'=>'Instances.AdmDisplayName','name'=>'Nome account admin','type'=>'text'),
'Instances.AdmCreatedAt'=>array('field'=>'Instances.AdmCreatedAt','name'=>'Data creazione account admin','type'=>'time'),
'Instances.AdmURL'=>array('field'=>'Instances.AdmURL','name'=>'Pagina dell’admin','type'=>'text','search'=>false,'ord'=>false),
'Instances.AdmAvatar'=>array('field'=>'Instances.AdmAvatar','name'=>'Avatar admin','type'=>'text','search'=>false,'ord'=>false),
'Instances.AdmNote'=>array('field'=>'Instances.AdmNote','name'=>'Note dell’admin','type'=>'text'),
//--------------------------------
'InstLangs'=>array('name'=>'Lingue dichiarate','search'=>false,'ord'=>false),
'InstLangs.LangID'=>array('field'=>'InstLangs%.LangID','name'=>'Una lingua dichiarata ⮞','type'=>'join','join'=>array('InstLangs AS InstLangs% ON InstLangs%.InstID=Instances.ID'),'ord'=>false),
'Languages.NameIT'=>array('field'=>'Languages%.NameIT','name'=>'Una lingua dichiarata','type'=>'joini','join'=>array('InstLangs AS InstLangs% ON InstLangs%.InstID=Instances.ID','Languages AS Languages% ON Languages%.ID=InstLangs%.LangID'),'subtype'=>'text','ord'=>true,'ordname'=>'Lingue dichiarate','ordjoin'=>array('InstLangs AS OrdInstLangs ON OrdInstLangs.InstID=Instances.ID','Languages AS OrdLanguages ON OrdLanguages.ID=OrdInstLangs.LangID'),'ordselmore'=>'GROUP_CONCAT(OrdLanguages.NameIT ORDER BY OrdInstLangs.Pos ASC SEPARATOR \'\') AS xOrdLangs','ordby'=>'xOrdLangs'),
'InstLangs.LangID.First'=>array('field'=>'InstLangs.LangID','name'=>'Lingua primaria dichiarata ⮞','type'=>'join','join'=>array('InstLangs AS InstLangs ON InstLangs.InstID=Instances.ID AND InstLangs.Pos=1'),'ord'=>false),
'Languages.NameIT.First'=>array('field'=>'Languages.NameIT','name'=>'Lingua primaria dichiarata','type'=>'joini','join'=>array('InstLangs AS InstLangs ON InstLangs.InstID=Instances.ID AND InstLangs.Pos=1','Languages AS Languages ON Languages.ID=InstLangs.LangID'),'subtype'=>'text','ord'=>false),
//--------------------------------
'InstOurLangs'=>array('name'=>'Lingue impostate da noi','search'=>false,'ord'=>false),
'InstOurLangs.OurLangID'=>array('field'=>'InstOurLangs%.OurLangID','name'=>'Una lingua impostata da noi ⮞','type'=>'join','join'=>array('InstOurLangs AS InstOurLangs% ON InstOurLangs%.InstID=Instances.ID'),'ord'=>false),
'OurLanguages.NameIT'=>array('field'=>'OurLanguages%.NameIT','name'=>'Una lingua impostata da noi','type'=>'joini','join'=>array('InstOurLangs AS InstOurLangs% ON InstOurLangs%.InstID=Instances.ID','Languages AS OurLanguages% ON OurLanguages%.ID=InstOurLangs%.OurLangID'),'subtype'=>'text','ord'=>true,'ordname'=>'Lingue impostate da noi','ordjoin'=>array('InstOurLangs AS OrdInstOurLangs ON OrdInstOurLangs.InstID=Instances.ID','Languages AS OrdOurLanguages ON OrdOurLanguages.ID=OrdInstOurLangs.OurLangID'),'ordselmore'=>'GROUP_CONCAT(OrdOurLanguages.NameIT ORDER BY OrdInstOurLangs.Pos ASC SEPARATOR \'\') AS xOrdOurLangs','ordby'=>'xOrdOurLangs'),
'InstOurLangs.OurLangID.First'=>array('field'=>'InstOurLangs.OurLangID','name'=>'Lingua primaria impostata da noi ⮞','type'=>'join','join'=>array('InstOurLangs AS InstOurLangs ON InstOurLangs.InstID=Instances.ID AND InstOurLangs.Pos=1'),'ord'=>false),
'OurLanguages.NameIT.First'=>array('field'=>'OurLanguages.NameIT','name'=>'Lingua primaria impostata da noi','type'=>'joini','join'=>array('InstOurLangs AS InstOurLangs ON InstOurLangs.InstID=Instances.ID AND InstOurLangs.Pos=1','Languages AS OurLanguages ON OurLanguages.ID=InstOurLangs.OurLangID'),'subtype'=>'text','ord'=>false),
//--------------------------------
'InstFinancing'=>array('name'=>'Modalità di finanziamento','search'=>false,'ord'=>false),
'InstFinancing.FinID'=>array('field'=>'InstFinancing%.FinID','name'=>'Una modalità di finanziamento ⮞','type'=>'join','join'=>array('InstFinancing AS InstFinancing% ON InstFinancing%.InstID=Instances.ID'),'ord'=>false),
'Financing.Type'=>array('field'=>'Financing%.Type','name'=>'Una modalità di finanziamento','type'=>'joini','join'=>array('InstFinancing AS InstFinancing% ON InstFinancing%.InstID=Instances.ID','Financing AS Financing% ON Financing%.ID=InstFinancing%.FinID'),'subtype'=>'text','ord'=>true,'ordname'=>'Modalità di finanziamento','ordjoin'=>array('InstFinancing AS OrdInstFinancing ON OrdInstFinancing.InstID=Instances.ID','Financing AS OrdFinancing ON OrdFinancing.ID=OrdInstFinancing.FinID'),'ordselmore'=>'GROUP_CONCAT(OrdFinancing.Type ORDER BY OrdInstFinancing.Pos ASC SEPARATOR \'\') AS xOrdFinancing','ordby'=>'xOrdFinancing'),
'InstFinancing.FinID.First'=>array('field'=>'InstFinancing.FinID','name'=>'Modalità di finanziamento primaria ⮞','type'=>'join','join'=>array('InstFinancing AS InstFinancing ON InstFinancing.InstID=Instances.ID AND InstFinancing.Pos=1'),'ord'=>false),
'Financing.Type.First'=>array('field'=>'Financing.Type','name'=>'Modalità di finanziamento primaria','type'=>'joini','join'=>array('InstFinancing AS InstFinancing ON InstFinancing.InstID=Instances.ID AND InstFinancing.Pos=1','Financing AS Financing ON Financing.ID=InstFinancing.FinID'),'subtype'=>'text','ord'=>false),
//--------------------------------
'InstPolicies'=>array('name'=>'Restrizioni sui contenuti','search'=>false,'ord'=>false),
'InstPolicies.PolID'=>array('field'=>'InstPolicies%.PolID','name'=>'Una restrizione sui contenuti ⮞','type'=>'join','join'=>array('InstPolicies AS InstPolicies% ON InstPolicies%.InstID=Instances.ID'),'ord'=>false),
'Policies.Name'=>array('field'=>'Policies%.Name','name'=>'Una restrizione sui contenuti','type'=>'joini','join'=>array('InstPolicies AS InstPolicies% ON InstPolicies%.InstID=Instances.ID','Policies AS Policies% ON Policies%.ID=InstPolicies%.PolID'),'subtype'=>'text','ord'=>true,'ordname'=>'Restrizioni sui contenuti','ordjoin'=>array('InstPolicies AS OrdInstPolicies ON OrdInstPolicies.InstID=Instances.ID','Policies AS OrdPolicies ON OrdPolicies.ID=OrdInstPolicies.PolID'),'ordselmore'=>'GROUP_CONCAT(OrdPolicies.Name ORDER BY OrdInstPolicies.Pos ASC SEPARATOR \'\') AS xOrdPolicies','ordby'=>'xOrdPolicies'),
'InstPolicies.PolID.First'=>array('field'=>'InstPolicies.PolID','name'=>'Restrizione sui contenuti primaria ⮞','type'=>'join','join'=>array('InstPolicies AS InstPolicies ON InstPolicies.InstID=Instances.ID AND InstPolicies.Pos=1'),'ord'=>false),
'Policies.Name.First'=>array('field'=>'Policies.Name','name'=>'Restrizione sui contenuti primaria','type'=>'joini','join'=>array('InstPolicies AS InstPolicies ON InstPolicies.InstID=Instances.ID AND InstPolicies.Pos=1','Policies AS Policies ON Policies.ID=InstPolicies.PolID'),'subtype'=>'text','ord'=>false),
//--------------------------------
'InstTags'=>array('name'=>'Tags','search'=>false,'ord'=>false),
'InstTags.TagID'=>array('field'=>'InstTags%.TagID','name'=>'Una tag ⮞','type'=>'join','join'=>array('InstTags% ON InstTags%.InstID=Instances.ID'),'ord'=>false),
'Tags.Name'=>array('field'=>'Tags%.Name','name'=>'Una tag','type'=>'joini','join'=>array('InstTags AS InstTags% ON InstTags%.InstID=Instances.ID','Tags AS Tags% ON Tags%.ID=InstTags%.TagID'),'subtype'=>'text','ord'=>true,'ordname'=>'Tags','ordjoin'=>array('InstTags AS OrdInstTags ON OrdInstTags.InstID=Instances.ID','Tags AS OrdTags ON OrdTags.ID=OrdInstTags.TagID'),'ordselmore'=>'GROUP_CONCAT(OrdTags.Name ORDER BY OrdInstTags.Pos ASC SEPARATOR \'\') AS xOrdTags','ordby'=>'xOrdTags'),
'InstTags.TagID.First'=>array('field'=>'InstTags.TagID','name'=>'Tag primaria ⮞','type'=>'join','join'=>array('InstTags AS InstTags ON InstTags.InstID=Instances.ID AND InstTags.Pos=1'),'ord'=>false),
'Tags.Name.First'=>array('field'=>'Tags.Name','name'=>'Tag primaria','type'=>'joini','join'=>array('InstTags AS InstTags ON InstTags.InstID=Instances.ID AND InstTags.Pos=1','Tags AS Tags ON Tags.ID=InstTags.TagID'),'subtype'=>'text','ord'=>false),
//--------------------------------
'InstActivity.Statuses.First'=>array('field'=>'InstActivity.Statuses','name'=>'Stati ultima settimana','type'=>'joini','join'=>array('InstActivity AS InstActivity ON InstActivity.InstID=Instances.ID AND InstActivity.Pos=1'),'subtype'=>'int','ord'=>true,'ordjoin'=>array('InstActivity AS OrdInstActivity ON OrdInstActivity.InstID=Instances.ID AND OrdInstActivity.Pos=1'),'ordselmore'=>1,'ordby'=>'OrdInstActivity.Statuses'),
'InstActivity.Logins.First'=>array('field'=>'InstActivity.Logins','name'=>'Logins ultima settimana','type'=>'joini','join'=>array('InstActivity AS InstActivity ON InstActivity.InstID=Instances.ID AND InstActivity.Pos=1'),'subtype'=>'int','ord'=>true,'ordjoin'=>array('InstActivity AS OrdInstActivity ON OrdInstActivity.InstID=Instances.ID AND OrdInstActivity.Pos=1'),'ordselmore'=>1,'ordby'=>'OrdInstActivity.Logins'),
'IntstActivity.Registrations.First'=>array('field'=>'InstActivity.Registrations','name'=>'Registrazioni ultima settimana','type'=>'joini','join'=>array('InstActivity AS InstActivity ON InstActivity.InstID=Instances.ID AND InstActivity.Pos=1'),'subtype'=>'int','ord'=>true,'ordjoin'=>array('InstActivity AS OrdInstActivity ON OrdInstActivity.InstID=Instances.ID AND OrdInstActivity.Pos=1'),'ordselmore'=>1,'ordby'=>'OrdInstActivity.Registrations'),
//--------------------------------
/*'InstActivity.Statuses.AVG'=>array('field'=>'InstActivity.Statuses','name'=>'Media stati ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','ord'=>true,'ordjoin'=>array('InstActivity AS OrdInstActivity ON OrdInstActivity.InstID=Instances.ID'),'ordselmore'=>'AVG(InstActivity.Statuses) AS avgstatuses'),
'InstActivity.Logins.AVG'=>array('field'=>'InstActivity.Logins','name'=>'Logins ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','wheremore'=>'InstActivity.Pos=1','ord'=>false),
'IntstActivity.Registrations.AVG'=>array('field'=>'InstActivity.Registrations','name'=>'Registrazioni ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','wheremore'=>'InstActivity.Pos=1','ord'=>false),*/
);
$types=array('bool','int','time','text','join','joini');
$fieldselopts='';
$ordfieldselopts='';
foreach ($cols as $key=>$arr) {
if (!array_key_exists('search',$arr) || $arr['search']==true) {
if ($arr['type']=='joini') {
$fieldselopts.='';
} else {
$fieldselopts.='';
}
}
if (!array_key_exists('ord',$arr) || $arr['ord']==true) {
if (!array_key_exists('ordname',$arr))
$name=$arr['name'];
else
$name=$arr['ordname'];
if ($arr['type']=='joini') {
$ordfieldselopts.='';
} else {
$ordfieldselopts.='';
}
}
}
$pblocks=0;
foreach ($_POST as $key=>$val)
if (preg_match('/^openpar-\d+$/',$key)===1)
$pblocks++;
$fi=0;
$ji=0;
$oi=0;
$jsaddrows='';
$jssetrows='';
$jsordaddrows='';
$jsordsetrows='';
$sels=array();
$joins=array();
$havings=array();
$where='';
$order='';
foreach ($_POST as $key=>$val) {
if (preg_match('/^openpar-\d+$/',$key)===1) {
$fi++;
if (preg_match('/^\(+$/',$val)===1)
$where.=$val;
$jsaddrows.='addrow('.$fi.',false);'.N;
$jssetrows.='setrow('.$fi.','.json_encode($val);
}
if (preg_match('/^fieldsel-\d+$/',$key)===1 && preg_match('/^(.+):(.+):(.+)$/',$val,$buf)===1) {
$tagk=$buf[1];
$type=$buf[2];
$subtype=$buf[3];
if (array_key_exists($tagk,$cols) && in_array($type,$types)) {
if (strpos($cols[$tagk]['field'],'%')!==false)
$ji++;
$where.=str_replace('%',$ji,$cols[$tagk]['field']);
if ($type=='join' || $type=='joini') {
foreach ($cols[$tagk]['join'] as $join) {
$join=str_replace('%',$ji,$join);
if (!in_array($join,$joins))
$joins[]=$join;
}
}
if (array_key_exists('havings',$cols[$tagk]) && !in_array($cols[$tagk]['havings'],$havings))
$havings[]=$cols[$tagk]['havings'];
if (array_key_exists('selmore',$cols[$tagk]) && !in_array($cols[$tagk]['selmore'],$sels))
$sels[]=$cols[$tagk]['selmore'];
$jssetrows.=','.json_encode($val);
} else {
muoribene($dbg.'
Dati POST corrotti.
Puoi riprovare resettando i parametri o tornare al login.',true);
}
}
if (preg_match('/^condsel-\d+$/',$key)===1) {
$where.=' '.$val.' ';
$cond=$val;
$jssetrows.=','.json_encode($val);
// nel caso qui sotto, valuesel e valueinp sono entrambi disabilitati (non ci sono in $_POST), quindi li riempio di introvabile e nulla
if (preg_match('/^IS NULL|IS NOT NULL$/',$val)===1)
$jssetrows.=',"NOMMITROVI!",""';
}
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.=',"NOMMITROVI!"';
$jssetrows.=','.json_encode($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 ($fi<$pblocks)
$where.=' '.$val.' ';
$jssetrows.=','.json_encode($val).');'.N;
}
if (preg_match('/^ordfieldsel-\d+$/',$key)===1 && preg_match('/^(.+):(.+):(.+)$/',$val,$buf)===1) {
$oi++;
$tagk=$buf[1];
$type=$buf[2];
$subtype=$buf[3];
if (array_key_exists($tagk,$cols) && in_array($type,$types)) {
if ($type=='join' || $type=='joini') {
if (!array_key_exists('ordjoin',$cols[$tagk])) {
foreach ($cols[$tagk]['join'] as $join)
if (!in_array($join,$joins))
$joins[]=$join;
} else {
foreach ($cols[$tagk]['ordjoin'] as $join)
if (!in_array($join,$joins))
$joins[]=$join;
}
}
if (!array_key_exists('ordby',$cols[$tagk])) {
$order.=$cols[$tagk]['field'];
} else {
if (!in_array($cols[$tagk]['ordselmore'],$sels))
$sels[]=$cols[$tagk]['ordselmore'];
$order.=$cols[$tagk]['ordby'];
}
if (array_key_exists('havings',$cols[$tagk]) && !in_array($cols[$tagk]['havings'],$havings))
$havings[]=$cols[$tagk]['havings'];
if (array_key_exists('selmore',$cols[$tagk]) && !in_array($cols[$tagk]['selmore'],$sels))
$sels[]=$cols[$tagk]['selmore'];
$jsordaddrows.='ordaddrow('.$oi.',false);'.N;
$jsordsetrows.='ordsetrow('.$oi.','.json_encode($val);
} else {
muoribene($dbg.'
Dati POST corrotti.
Puoi riprovare resettando i parametri o tornare al login.',true);
}
}
if (preg_match('/^ascdesc-\d+$/',$key)===1 && preg_match('/^ASC|DESC$/',$val)===1) {
$order.=' '.$val.', ';
$jsordsetrows.=','.json_encode($val).');'.N;
}
}
if ($jsaddrows!='') {
$jsaddrows.='document.getElementById("filbut").value="Rimuovi tutti i criteri di ricerca";'.N;
$jsaddrows.='synctai();'.N;
}
if ($jsordaddrows!='') {
$jsordaddrows.='document.getElementById("ordbut").value="Rimuovi tutti i criteri di ordinamento";'.N;
$jsordaddrows.='synctoi();'.N;
}
if (count($sels)>0)
$sels=', '.implode(', ',$sels);
else
$sels='';
if ($where!='')
$where='WHERE '.$where;
if ($order!='')
$order='ORDER BY '.substr($order,0,-2);
$dbg.='ORDER: '.$order.'
';
if (count($joins)>0)
$joins='LEFT JOIN '.implode(' LEFT JOIN ',$joins);
else
$joins='';
if (count($havings)>0)
$havings='HAVING '.implode(' AND ',$havings);
else
$havings='';
$query='SELECT *, Instances.ID AS IID'.$sels.' FROM Instances '.$joins.' '.$where.' GROUP BY IID '.$havings.' '.$order.' LIMIT 50';
$dbg.='QUERONA: '.$query.'
'.N;
$tini=microtime(true);
$res=mysqli_query($link,$query)
or muoribene($dbg.'
'.$query.': '.mysqli_error($link).'
'.'La query è fallita. Resetta.',true);
$dbg.='Durata esecuzione query: '.round(microtime(true)-$tini,4).' sec.
'.N;
if (mysqli_num_rows($res)<1) {
$out=''.N;
// $out.='
'.N;
}
$out.='';
}
$presid=0;
if (array_key_exists('presets',$_POST) && preg_match('/^[0-9]+$/',$_POST['presets'])===1)
$presid=$_POST['presets'];
$presopts=''.N;
$res=mysqli_query($link,'SELECT * FROM Presets ORDER BY LENGTH(Name) ASC, Name ASC')
or muoribene(mysqli_error($link),true);
while ($row=mysqli_fetch_assoc($res)) {
if ($row['ID']!=$presid)
$presopts.=''.N;
else
$presopts.=''.N;
}
mysqli_close($link);
?>
'.N;
$out.=''.N;
$out.='Attributi Info '.N;
$attr=booly($cols['Instances.Blacklisted']['name'].': ',$row['Blacklisted'],false,true).N;
$attr.=booly($cols['Instances.New']['name'].': ',$row['New'],true).N;
$attr.=booly($cols['Instances.Good']['name'].': ',$row['Good']).N;
$attr.=booly($cols['Instances.Chosen']['name'].': ',$row['Chosen']).N;
$attr.=booly($cols['Instances.Visible']['name'].': ',$row['Visible']).N;
/* $attr.=booly($cols['Instances.RegOpen']['name'].': ',$row['RegOpen']).N;
$attr.=booly($cols['Instances.RegReqApproval']['name'].': ',$row['RegReqApproval'],true,true).N;*/
$sres=mysqli_query($link,'SELECT * FROM InstChecks WHERE InstID='.$row['IID'].' ORDER BY Time DESC')
or muoribene(mysqli_error($link),true);
$csres=mysqli_num_rows($sres);
if ($csres>0) {
$bene=0;
while ($srow=mysqli_fetch_assoc($sres)) {
if ($srow['Status']==1)
$bene++;
}
$width=str_replace(',','.',100/$csres*$bene);
$attr.=''.$row['URI'].' {'.$row['IID'].'}
Accessi: '.$tot['tlogins'].'
Registrazioni: '.$tot['tregs'].''.N;
while ($srow=mysqli_fetch_assoc($sres)) {
$attr.='
'.N;
$out.=''.N;
$out.=''.$attr.' '.N;
$out.='