'));
} 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).'
';
$cols=array(
'New'=>array('name'=>'Nuova','type'=>'bool'),
'Good'=>array('name'=>'Papabile','type'=>'bool'),
'Chosen'=>array('name'=>'Scelta','type'=>'bool'),
'Visible'=>array('name'=>'Visibile','type'=>'bool'),
'Blacklisted'=>array('name'=>'Blacklistata','type'=>'bool'),
'URI'=>array('name'=>'URI','type'=>'text'),
'Title'=>array('name'=>'Titolo','type'=>'text'),
'ShortDesc'=>array('name'=>'Descrizione breve','type'=>'text'),
'LongDesc'=>array('name'=>'Descrizione lunga','type'=>'text'),
'OurDesc'=>array('name'=>'Descrizione nostra','type'=>'text'),
'PlaceID'=>array('name'=>'Località ⮞','type'=>'join','join'=>array(),'ord'=>false),
'Places.Locality'=>array('name'=>'Località','type'=>'joini','join'=>array('Places ON Places.ID=Instances.PlaceID'),'subtype'=>'text'),
'Email'=>array('name'=>'Email di contatto','type'=>'text'),
'Software'=>array('name'=>'Software','type'=>'text'),
'Version'=>array('name'=>'Versione','type'=>'text'),
'UserCount'=>array('name'=>'Utenti','type'=>'int'),
'StatusCount'=>array('name'=>'Stati','type'=>'int'),
'DomainCount'=>array('name'=>'Istanze note','type'=>'int'),
'ActiveUsersMonth'=>array('name'=>'Utenti attivi (mese)','type'=>'int'),
'ActiveUsersHalfYear'=>array('name'=>'Utenti attivi (6 mesi)','type'=>'int'),
'Thumb'=>array('name'=>'Logo','type'=>'text','search'=>false,'ord'=>false),
'RegOpen'=>array('name'=>'Registrazioni aperte','type'=>'bool'),
'RegReqApproval'=>array('name'=>'Approvazione registrazioni','type'=>'bool'),
'MaxTootChars'=>array('name'=>'Limite caratteri','type'=>'int'),
'AdmAccount'=>array('name'=>'Account admin','type'=>'text'),
'AdmDisplayName'=>array('name'=>'Nome account admin','type'=>'text'),
'AdmCreatedAt'=>array('name'=>'Data creazione account admin','type'=>'time'),
'AdmURL'=>array('name'=>'Pagina dell’admin','type'=>'text','ord'=>false),
'AdmAvatar'=>array('name'=>'Avatar admin','type'=>'text','search'=>false,'ord'=>false),
'AdmNote'=>array('name'=>'Note dell’admin','type'=>'text'),
'LangID'=>array('name'=>'Lingue dichiarate ⮞','type'=>'join','join'=>array('InstLangs ON InstLangs.InstID=Instances.ID'),'ord'=>false),
'Languages.Code'=>array('name'=>'Lingue dichiarate','type'=>'joini','join'=>array('InstLangs ON InstLangs.InstID=Instances.ID','Languages ON Languages.ID=InstLangs.LangID'),'subtype'=>'text','ord'=>false),
'InstLangs.LangID'=>array('name'=>'Lingua primaria dichiarata ⮞','type'=>'join','join'=>array('InstLangs ON InstLangs.InstID=Instances.ID'),'wheremore'=>'AND InstLangs.Pos=1','ord'=>false),
'Languages.NameIT'=>array('name'=>'Lingua primaria dichiarata','type'=>'joini','join'=>array('InstLangs ON InstLangs.InstID=Instances.ID','Languages ON Languages.ID=InstLangs.LangID'),'subtype'=>'text','wheremore'=>'AND InstLangs.Pos=1'),
'OurLangID'=>array('name'=>'Lingue impostate da noi ⮞','type'=>'join','join'=>array('InstOurLangs ON InstOurLangs.InstID=Instances.ID'),'ord'=>false),
'OurLanguages.Code'=>array('name'=>'Lingue impostate da noi','type'=>'joini','join'=>array('InstOurLangs ON InstOurLangs.InstID=Instances.ID','Languages AS OurLanguages ON OurLanguages.ID=InstOurLangs.OurLangID'),'subtype'=>'text','ord'=>false),
'InstOurLangs.OurLangID'=>array('name'=>'Lingua primaria impostata da noi ⮞','type'=>'join','join'=>array('InstOurLangs ON InstOurLangs.InstID=Instances.ID'),'wheremore'=>'AND InstOurLangs.Pos=1','ord'=>false),
'OurLanguages.NameIT'=>array('name'=>'Lingua primaria impostata da noi','type'=>'joini','join'=>array('InstOurLangs ON InstOurLangs.InstID=Instances.ID','Languages AS OurLanguages ON OurLanguages.ID=InstOurLangs.OurLangID'),'subtype'=>'text','wheremore'=>'AND InstOurLangs.Pos=1'),
'FinID'=>array('name'=>'Modalità di finanziamento ⮞','type'=>'join','join'=>array('InstFinancing ON InstFinancing.InstID=Instances.ID'),'ord'=>false),
'Financing.Type'=>array('name'=>'Modalità di finanziamento','type'=>'joini','join'=>array('InstFinancing ON InstFinancing.InstID=Instances.ID','Financing ON Financing.ID=InstFinancing.FinID'),'subtype'=>'text'),
'InstFinancing.FinID'=>array('name'=>'Modalità di finanziamento primaria ⮞','type'=>'join','join'=>array('InstFinancing ON InstFinancing.InstID=Instances.ID'),'wheremore'=>'AND InstFinancing.Pos=1','ord'=>false),
'XFinancing.Type'=>array('name'=>'Modalità di finanziamento primaria','type'=>'joini','join'=>array('InstFinancing ON InstFinancing.InstID=Instances.ID','Financing AS XFinancing ON XFinancing.ID=InstFinancing.FinID'),'subtype'=>'text','wheremore'=>'AND InstFinancing.Pos=1'),
'PolID'=>array('name'=>'Restrizioni sui contenuti ⮞','type'=>'join','join'=>array('InstPolicies ON InstPolicies.InstID=Instances.ID'),'ord'=>false),
'Policies.Name'=>array('name'=>'Restrizioni sui contenuti','type'=>'joini','join'=>array('InstPolicies ON InstPolicies.InstID=Instances.ID','Policies ON Policies.ID=InstPolicies.PolID'),'subtype'=>'text'),
'InstPolicies.PolID'=>array('name'=>'Restrizione sui contenuti primaria ⮞','type'=>'join','join'=>array('InstPolicies ON InstPolicies.InstID=Instances.ID'),'wheremore'=>'AND InstPolicies.Pos=1','ord'=>false),
'XPolicies.Name'=>array('name'=>'Restrizione sui contenuti primaria','type'=>'joini','join'=>array('InstPolicies ON InstPolicies.InstID=Instances.ID','Policies AS XPolicies ON XPolicies.ID=InstPolicies.PolID'),'subtype'=>'text','wheremore'=>'AND InstPolicies.Pos=1'),
'TagID'=>array('name'=>'Tags ⮞','type'=>'join','join'=>array('InstTags ON InstTags.InstID=Instances.ID'),'ord'=>false),
'Tags.Name'=>array('name'=>'Tags','type'=>'joini','join'=>array('InstTags ON InstTags.InstID=Instances.ID','Tags ON Tags.ID=InstTags.TagID'),'subtype'=>'text'),
'InstTags.TagID'=>array('name'=>'Tag primaria ⮞','type'=>'join','join'=>array('InstTags ON InstTags.InstID=Instances.ID'),'wheremore'=>'AND InstTags.Pos=1','ord'=>false),
'XTags.Name'=>array('name'=>'Tag primaria','type'=>'joini','join'=>array('InstTags ON InstTags.InstID=Instances.ID','Tags AS XTags ON XTags.ID=InstTags.TagID'),'subtype'=>'text','wheremore'=>'AND InstTags.Pos=1'),
/*'Statuses'=>array('name'=>'Stati ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','selmore'=>'MAX(Week) AS maxweek'),
'Logins'=>array('name'=>'Logins ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','selmore'=>'MAX(Week) AS maxweek'),
'Registrations'=>array('name'=>'Registrazioni ultima settimana','type'=>'joini','join'=>array('InstActivity ON InstActivity.InstID=Instances.ID'),'subtype'=>'int','selmore'=>'MAX(Week) AS maxweek'),*/
);
$types=array('bool','int','time','text','join','joini');
$fieldselopts='';
$ordfieldselopts='';
foreach ($cols as $key=>$val) {
if (!array_key_exists('search',$val)) {
if ($val['type']=='joini') {
$fieldselopts.='';
} else {
$fieldselopts.='';
}
}
if (!array_key_exists('ord',$val)) {
if ($val['type']=='joini') {
$ordfieldselopts.='';
} else {
$ordfieldselopts.='';
}
}
}
$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) {
$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) {
$col=$buf[1];
$type=$buf[2];
$subtype=$buf[3];
if (array_key_exists($col,$cols) && in_array($type,$types)) {
if (array_key_exists('wheremore',$cols[$col]))
$where.='(';
$where.=$col;
if ($type=='join' || $type=='joini') {
foreach ($cols[$col]['join'] as $join) {
if (!in_array($join,$joins))
$joins[]=$join;
}
if (array_key_exists('selmore',$cols[$col]) && !in_array($cols[$col]['selmore'],$sels))
$sels[]=$cols[$col]['selmore'];
}
$jssetrows.=','.json_encode($val);
} else {
muoribene($dbg.'
Dati POST corrotti.
Puoi riprovare 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;
if (array_key_exists('wheremore',$cols[$col]))
$where.=' '.$cols[$col]['wheremore'].')';
$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).'\'';
if (array_key_exists('wheremore',$cols[$col]))
$where.=' '.$cols[$col]['wheremore'].')';
$jssetrows.=',"NOMMITROVIHODETTO!"';
$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 ($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)
$sels=', '.implode(', ',$sels);
else
$sels='';
if ($where!='')
$where='WHERE '.$where;
if (count($joins)>0)
$joins='LEFT JOIN '.implode(' LEFT JOIN ',$joins);
else
$joins='';
$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).'
'.'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.='';
}
mysqli_close($link);
?>
'.N;
$out.=''.N;
$out.='Attributi Info '.N;
$attr=booly($cols['Blacklisted']['name'].': ',$row['Blacklisted'],false,true).N;
$attr.=booly($cols['New']['name'].': ',$row['New'],true).N;
$attr.=booly($cols['Good']['name'].': ',$row['Good']).N;
$attr.=booly($cols['Chosen']['name'].': ',$row['Chosen']).N;
$attr.=booly($cols['Visible']['name'].': ',$row['Visible']).N;
/* $attr.=booly($cols['RegOpen']['name'].': ',$row['RegOpen']).N;
$attr.=booly($cols['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.='