diff --git a/web/admin/dafa.txt b/web/admin/dafa.txt new file mode 100644 index 0000000..94d3af4 --- /dev/null +++ b/web/admin/dafa.txt @@ -0,0 +1,2 @@ +- ripristinare le colonne descrittive in Languages: una per la locale impostata (it), una per en, una per fr, una per sp... +* instancesh.php: ritornare di tutte solo quelle che effettivamente sono usate, magari con un count tra () diff --git a/web/admin/imgs/minus.svg b/web/admin/imgs/minus.svg new file mode 100644 index 0000000..0336f55 --- /dev/null +++ b/web/admin/imgs/minus.svg @@ -0,0 +1,83 @@ + + + + diff --git a/web/admin/imgs/plus.svg b/web/admin/imgs/plus.svg new file mode 100644 index 0000000..0e73bd5 --- /dev/null +++ b/web/admin/imgs/plus.svg @@ -0,0 +1,91 @@ + + + + diff --git a/web/admin/include/menu.php b/web/admin/include/menu.php index c6927a5..9871388 100644 --- a/web/admin/include/menu.php +++ b/web/admin/include/menu.php @@ -3,12 +3,11 @@ $menu=array( 'istanze'=>array('liadd'=>null, 'href'=>'istanze.php', 'title'=>'Istanze', 'selected'=>false, 'submenu'=> array( - 'aggiungi'=>array('liadd'=>'onclick="golang(\'en\')" onmouseover="this.style.cursor=\'pointer\'"', 'href'=>null, 'title'=>'English', 'selected'=>false, 'submenu'=>null), - 'italiano'=>array('liadd'=>'onclick="golang(\'it\')" onmouseover="this.style.cursor=\'pointer\'"', 'href'=>null, 'title'=>'Italiano', 'selected'=>false, 'submenu'=>null) + 'aggiungi'=>array('liadd'=>null, 'href'=>'editinst?m=new', 'title'=>'Aggiungi', 'selected'=>false, 'submenu'=>null), ) ), - 'boh'=>array('liadd'=>null, 'href'=>'#', 'title'=>'Non saprei', 'selected'=>false, 'submenu'=>null), - 'vedremo'=>array('liadd'=>null, 'href'=>'#', 'title'=>'Vedremo', 'selected'=>false, 'submenu'=>null), + 'blacklist'=>array('liadd'=>null, 'href'=>'#', 'title'=>'Blacklist', 'selected'=>false, 'submenu'=>null), + 'magari'=>array('liadd'=>null, 'href'=>'#', 'title'=>'Chissà', 'selected'=>false, 'submenu'=>null), 'forse'=>array('liadd'=>null, 'href'=>'#', 'title'=>'Forse', 'selected'=>false, 'submenu'=>null) ); diff --git a/web/admin/include/muoribene.php b/web/admin/include/muoribene.php index 20927a8..9c547e7 100644 --- a/web/admin/include/muoribene.php +++ b/web/admin/include/muoribene.php @@ -1,8 +1,8 @@
diff --git a/web/admin/instances.php b/web/admin/instances.php index 15241ad..5d8ce54 100644 --- a/web/admin/instances.php +++ b/web/admin/instances.php @@ -3,11 +3,18 @@ require('include/glob.php'); require('include/muoribene.php'); require('include/sessionstart.php'); + require('include/menu.php'); +$menu['istanze']['href']=null; +$menu['istanze']['selected']=true; buildmenu($menu); require('include/myconn.php'); +$dbg=''; + +use function mysqli_real_escape_string as myesc; + // praticamente una macro function hspech($str) { return(htmlspecialchars($str,ENT_QUOTES|ENT_HTML5,'UTF-8')); @@ -79,6 +86,8 @@ function booly($pre,$val,$nottoobad=false,$invcol=false) { } } +$dbg.=''.print_r($_POST,1).''; + $cols=array( 'New'=>array('name'=>'Nuova','type'=>'bool'), 'Good'=>array('name'=>'Papabile','type'=>'bool'), @@ -90,7 +99,10 @@ $cols=array( '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'=>'select'), + + 'PlaceID'=>array('name'=>'[Località]','type'=>'join','join'=>array()), + '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'), @@ -109,20 +121,124 @@ $cols=array( 'AdmURL'=>array('name'=>'Pagina dell’admin','type'=>'text'), 'AdmAvatar'=>array('name'=>'Avatar admin','type'=>'text'), 'AdmNote'=>array('name'=>'Note dell’admin','type'=>'text'), - 'InstLangs'=>array('name'=>'Lingue dichiarate','type'=>'select'), - 'InstOurLangs'=>array('name'=>'Lingue impostate da noi','type'=>'select'), - 'InstFinancing'=>array('name'=>'Modalità di finanziamento','type'=>'select'), - 'InstPolicies'=>array('name'=>'Restrizioni sui contenuti','type'=>'select'), - 'InstTags'=>array('name'=>'Tags','type'=>'select'), + + 'LangID'=>array('name'=>'[Lingue dichiarate]','type'=>'join','join'=>array('InstLangs ON InstLangs.InstID=Instances.ID')), + 'Languages.Code'=>array('name'=>'Lingue dichiarate','type'=>'joini','join'=>array('InstLangs ON InstLangs.InstID=Instances.ID','Languages ON Languages.ID=InstLangs.LangID'),'subtype'=>'text'), + + 'OurLangID'=>array('name'=>'[Lingue impostate da noi]','type'=>'join','join'=>array('InstOurLangs ON InstOurLangs.InstID=Instances.ID')), + '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'), + + 'FinID'=>array('name'=>'[Modalità di finanziamento]','type'=>'join','join'=>array('InstFinancing ON InstFinancing.InstID=Instnces.ID')), + 'Financing.Type'=>array('name'=>'Modalità di finanziamento','type'=>'joini','join'=>array('InstFinancing ON InstFinancing.InstID=Instnces.ID','Financing ON Financing.ID=InstFinancing.FinID'),'subtype'=>'text'), + + 'PolID'=>array('name'=>'[Restrizioni sui contenuti]','type'=>'join','join'=>array('InstPolicies ON InstPolicies.InstID=Instances.ID')), + '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'), + + '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'=>'int','join'=>'LEFT JOIN InstActivity ON InstActivity.InstID=Instances.ID','select'=>'MAX(Week) AS maxweek'), + 'Logins'=>array('name'=>'Logins ultima settimana','type'=>'int','join'=>'LEFT JOIN InstActivity ON InstActivity.InstID=Instances.ID','select'=>'MAX(Week) AS maxweek'), + 'Registrations'=>array('name'=>'Registrazioni ultima settimana','type'=>'int','join'=>'LEFT JOIN InstActivity ON InstActivity.InstID=Instances.ID','select'=>'MAX(Week) AS maxweek'), ); +$types=array('bool','int','time','text','join','joini'); + $fieldselopts=''; foreach ($cols as $key=>$val) { - $fieldselopts.=''; + if ($val['type']=='joini') { + $fieldselopts.=''; + } else { + $fieldselopts.=''; + } } -$res=mysqli_query($link,'SELECT *, Instances.ID AS IID FROM Instances LEFT JOIN Places ON Places.ID=PlaceID ORDER BY URI ASC LIMIT 50') - or muoribene(mysqli_error($link),false); +/* +[openpar-1] => null +[fieldsel-1] => New§bool +[condsel-1] => IS +[valuesel-1] => TRUE +[closepar-1] => null +[andor-1] => AND +[openpar-2] => ( +[fieldsel-2] => URI§text +[condsel-2] => LIKE +[valueinp-2] => bida +[closepar-2] => null +[andor-2] => OR +[openpar-3] => null +[fieldsel-3] => URI§text +[condsel-3] => IS NULL +[closepar-3] => ) +[andor-3] => AND +[openpar-4] => null +[fieldsel-4] => PlaceID§join +[condsel-4] => = +[valuesel-4] => 1 +[closepar-4] => null +[andor-4] => AND +[openpar-5] => null +[fieldsel-5] => UserCount§int +[condsel-5] => >= +[valueinp-5] => 123 +[closepar-5] => null +[andor-5] => AND +[openpar-6] => null +[fieldsel-6] => LangID§join +[condsel-6] => = +[valuesel-6] => 20 +[closepar-6] => null +*/ + +$joins=array(); +$where=''; +foreach ($_POST as $key=>$val) { + if (preg_match('/^openpar-\d+/',$key)===1 && preg_match('/^\(+$/',$val)===1) + $where.=$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) { + if (!in_array($join,$joins)) + $joins[]=$join; + } + } + } else { + muoribene($dbg.'
Nessuna istanza da mostrare.
'.N; } else { @@ -131,7 +247,7 @@ if (mysqli_num_rows($res)<1) { $out.='Attributi | Info |
---|---|
'.$row['URI'].' | |
'.$row['URI'].' {'.$row['IID'].'} |