This commit is contained in:
pezcurrel 2020-03-09 22:16:54 +01:00
parent 104d860a8d
commit 29f77dcdc7
14 changed files with 860 additions and 158 deletions

View file

@ -1 +1 @@
Progetto per un sito di introduzione a mastodon ([vedi il pad su cisti](https://pad.cisti.org/p/uhXFbSxe5EaMPE4syEKI)) che dia inoltre la possibilità di scegliere un'istanza in base a vari criteri, da una base di istanze sufficientemente occhei.
Progetto per un sito di introduzione a mastodon ([al momento pubblicato qui](https://rame.altervista.org/mastostart/)) che dia inoltre la possibilità di scegliere unistanza in base a vari criteri, da una base di istanze sufficientemente occhei.

2
web/admin/.htaccess Normal file
View file

@ -0,0 +1,2 @@
RewriteEngine Off
RewriteEngine On

View file

@ -600,7 +600,7 @@ while ($i<$cinsts) {
$res=mysqli_query($link,'SELECT * FROM Instances WHERE URI=\''.myesc($link,mb_substr($dom,0,$tables['Instances']['URI'],'UTF-8')).'\'')
or mexit(mysqli_error($link).N,3);
if (mysqli_num_rows($res)>0) {
lecho('«'.$dom.'» non risponde, ma è presente nel database; aggiorno InstChecks.');
lecho('«'.$dom.'» non risponde, ma è presente nel database; aggiorno InstChecks.'.N);
$row=mysqli_fetch_assoc($res);
mysqli_query($link,'INSERT INTO InstChecks (InstID, Time, Status) VALUES ('.$row['ID'].', '.time().', 0)')
or mexit(mysqli_error($link).N,3);
@ -613,7 +613,7 @@ while ($i<$cinsts) {
}
if ($ok && !is_null($info) && akeavinn('uri',$info) && !is_null(nempty($info['uri'])) && !willtrunc($info['uri'],'Instances','URI') && akeavinn('version',$info) && preg_match('/pleroma|pixelfed/i',$info['version'])===0) {
$qok++;
$instrow=array('ID'=>null, 'New'=>0, 'Good'=>0, 'Chosen'=>0, 'Visible'=>0, 'Blacklisted'=>0, 'URI'=>null, 'Title'=>null, 'ShortDesc'=>null, 'LongDesc'=>null, 'OurDesc'=>null, 'PlaceID'=>null, 'Email'=>null, 'Software'=>null, 'Version'=>null, 'UserCount'=>null, 'StatusCount'=>null, 'DomainCount'=>null, 'ActiveUsersMonth'=>null, 'ActiveUsersHalfYear'=>null, 'Thumb'=>null, 'RegOpen'=>null, 'RegReqApproval'=>null, 'MaxTootChars'=>null, 'AdmAccount'=>null, 'AdmDisplayName'=>null, 'AdmCreatedAt'=>null, 'AdmNote'=>null, 'AdmURL'=>null, 'AdmAvatar'=>null, 'AdmHeader'=>null);
$instrow=array('ID'=>null, 'New'=>0, 'Good'=>0, 'Chosen'=>0, 'Visible'=>0, 'Blacklisted'=>0, 'URI'=>null, 'Title'=>null, 'ShortDesc'=>null, 'LongDesc'=>null, 'OurDesc'=>null, 'LocalityID'=>null, 'Email'=>null, 'Software'=>null, 'Version'=>null, 'UserCount'=>null, 'StatusCount'=>null, 'DomainCount'=>null, 'ActiveUsersMonth'=>null, 'ActiveUsersHalfYear'=>null, 'Thumb'=>null, 'RegOpen'=>null, 'RegReqApproval'=>null, 'MaxTootChars'=>null, 'AdmAccount'=>null, 'AdmDisplayName'=>null, 'AdmCreatedAt'=>null, 'AdmNote'=>null, 'AdmURL'=>null, 'AdmAvatar'=>null, 'AdmHeader'=>null);
if (array_key_exists($info['uri'],$blacklist))
$instrow['Blacklisted']=1;
$instrow['URI']=$info['uri'];
@ -724,7 +724,7 @@ while ($i<$cinsts) {
if ($instrow['LongDesc']!=$oldinstrow['LongDesc'])
notify('<p>La «Descrizione lunga» dellistanza «<a href="editinst.php?id='.$instrow['ID'].'">'.$instrow['URI'].'</a>» è cambiata. La vecchia era...</p><div class="valdesc">'.$oldinstrow['LongDesc'].'</div><p>La nuove è...</p><div class="valdesc">'.$instrow['LongDesc'].'</div>',1);
$instrow['OurDesc']=$oldinstrow['OurDesc'];
$instrow['PlaceID']=$oldinstrow['PlaceID'];
$instrow['LocalityID']=$oldinstrow['LocalityID'];
$query='UPDATE Instances SET ';
foreach ($instrow as $field=>$value) {
if (!is_null($value))
@ -786,8 +786,8 @@ while ($i<$cinsts) {
if (array_key_exists('x-activity',$info) && is_array($info['x-activity'])) {
mysqli_query($link,'DELETE FROM InstActivity WHERE InstID='.$instid);
$pos=0;
foreach ($info['x-activity'] as $buf) {
$pos=0;
if (akeavinn('week',$buf) && akeavinn('statuses',$buf) && akeavinn('logins',$buf) && akeavinn('registrations',$buf)) {
$pos++;
$query='INSERT INTO InstActivity (InstID, Week, Statuses, Logins, Registrations, Pos) VALUES (\''.$instid.'\', \''.myesc($link,$buf['week']).'\', \''.myesc($link,$buf['statuses']).'\', \''.myesc($link,$buf['logins']).'\', \''.myesc($link,$buf['registrations']).'\', '.$pos.')';

View file

@ -1,4 +0,0 @@
<?php
ucfirst(locale_get_display_name($lang,'it'))
ucfirst(locale_get_display_name($lang,$lang))
?>

View file

@ -3,9 +3,14 @@
* fatto
~ più o meno
? instances.php: bottoni per pagina precedente-successiva
- instances.php: disabilitare la possibilità di cambiare pagina quando vengono modificati i criteri di ricerca/ordinamento
- instances.php: possibilità di vedere solo le istanze che non rispondono da tot giorni (o forse farla a parte?)
- instances.php: notifiche
- instances.php: scomparsa-comparsa div di debug
- instances.php: ckf: controllare che non venga eseguito ordinamento su una stessa colonna più volte (non rompe query ma è ridondante)
* instances.php: quando ordinamento è su una "1 a molti", eseguirlo su "GROUP_CONCAT" di questi molti ordinati per "Pos" della joinosa tabella
* ripristinare le colonne descrittive in Languages: una per la locale impostata (it), una per en, una per fr, una per sp...
* ripristinare le colonne descrittive in Languages: una per la locale impostata (it), una per en, una per fr, una per es...
* instancesh.php: ritornare di tutte solo quelle che effettivamente sono usate, magari con un count tra ()
* instances.php: definito/non definito non vengono riprodotte bene dalla plancia dopo post
* instances.php: quando si seleziona definito/non definito, oltre a disabilitare il campo valsel/valinp, farlo sparire proprio? assegnargli un css che da disabilitato lo fa diventare tuttonero? tipo

506
web/admin/edinst.php Normal file
View file

@ -0,0 +1,506 @@
<?php
require('include/glob.php');
require('include/muoribene.php');
require('include/sessionstart.php');
require('include/menu.php');
$menu['istanze']['href']=null;
$menu['istanze']['selected']=true;
$menu['istanze']['submenu']['modifica']['href']=null;
$menu['istanze']['submenu']['modifica']['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'));
}
$dbg.='<pre>'.print_r($_POST,1).'</pre>';
mysqli_close($link);
?>
<!DOCTYPE HTML>
<html lang="it">
<head>
<title>Mastodon Startpage Admin - Modifica di «<?php echo($data['URI']); ?>»</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Admin pages for Mastodon Startpage">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="icon" type="image/png" href="imgs/icona-32.png" sizes="32x32">
<link rel="icon" type="image/png" href="imgs/icona-192.png" sizes="192x192">
<link rel="icon" type="image/png" href="imgs/icona-512.png" sizes="512x512">
<link rel="apple-touch-icon-precomposed" href="imgs/icona-180.png">
<script language="JavaScript" src="js/confirma.js?v=<?php echo($cjrand); ?>"></script>
<script language="JavaScript" src="js/alerta.js?v=<?php echo($cjrand); ?>"></script>
<link rel="stylesheet" type="text/css" href="theme.css?v=<?php echo($cjrand); ?>">
<script language="JavaScript">
<!--
function chulsh(el,sh) {
if (sh)
el.querySelector('ul').style.display='block';
else
el.querySelector('ul').style.display='none';
}
function ulsh(el,sh) {
if (sh)
el.style.display='block';
else
el.style.display='none';
}
function golang(lang) {
var loc=document.location.href;
loc=loc.replace(/#.*$/,'');
loc=loc.replace(/\/$/,'');
if (document.documentElement.lang=='en') {
if (lang!='en')
document.location.href=loc+'/'+lang;
} else {
if (lang!='en')
document.location.href=loc.substr(0,loc.length-3)+'/'+lang;
else
document.location.href=loc.substr(0,loc.length-3);
}
}
function shideplancia() {
var plancia=document.getElementById('plancia');
var plctrl=document.getElementById('plctrl');
if (plancia.style.display=='block') {
plancia.style.display='none';
plctrl.innerHTML='Mostra plancia';
} else {
plancia.style.display='block';
plctrl.innerHTML='Nascondi plancia';
}
}
function truncsel(el) {
var sel=document.getElementById(el), len=sel.length, i=0;
for (i=len-1; i>=0; i--)
sel.remove(i);
}
function addselopt(el,val,txt) {
option=new Option(txt,val);
el.add(option);
}
function inpdisif(index) {
console.log('inpdisif index: '+index);
var source=document.getElementById('condsel-'+index);
var inp=document.getElementById('valueinp-'+index);
var sel=document.getElementById('valuesel-'+index);
var conds=['IS NULL','IS NOT NULL'];
if (conds.includes(source.value)) {
inp.disabled=true;
sel.disabled=true;
} else {
if (inp.style.display!='none') inp.disabled=false;
if (sel.style.display!='none') sel.disabled=false;
}
}
function popusels(index,valselval) {
console.log('popusels index: '+index);
var key=document.getElementById('fieldsel-'+index).value;
var type=key.replace(/^.*:(.*):.*$/,'$1');
var subtype=key.replace(/^.*:.*:(.*)$/,'$1');
key=key.replace(/^(.*):.*:.*$/,'$1');
var condsel=document.getElementById('condsel-'+index);
var valsel=document.getElementById('valuesel-'+index);
var valinp=document.getElementById('valueinp-'+index);
condsel.setAttribute('onchange','inpdisif('+index+');');
if (type=='joini')
type=subtype;
if (type=='bool') {
truncsel('condsel-'+index);
addselopt(condsel,'IS','è');
truncsel('valuesel-'+index);
addselopt(valsel,'TRUE','vero');
addselopt(valsel,'FALSE','falso');
addselopt(valsel,'NOT NULL','definit@');
addselopt(valsel,'NULL','non definit@');
if (valselval!==false)
selind('valuesel-'+index,valselval);
valinp.style.display='none';
valinp.disabled=true;
valsel.style.display='block';
valsel.disabled=false;
} else if (type=='text') {
truncsel('condsel-'+index);
addselopt(condsel,'LIKE','contiene');
addselopt(condsel,'NOT LIKE','non contiene');
addselopt(condsel,'=','è uguale a');
addselopt(condsel,'!=','è divers@ da');
addselopt(condsel,'>=','è maggiore o uguale a');
addselopt(condsel,'<=','è minore o uguale a');
addselopt(condsel,'>','è maggiore di');
addselopt(condsel,'<','è minore di');
addselopt(condsel,'IS NOT NULL','è definit@');
addselopt(condsel,'IS NULL','non è definit@');
valsel.style.display='none';
valsel.disabled=true;
valinp.style.display='block';
valinp.disabled=false;
} else if (type=='int' || type=='time') {
truncsel('condsel-'+index);
addselopt(condsel,'>=','è maggiore o uguale a');
addselopt(condsel,'<=','è minore o uguale a');
addselopt(condsel,'>','è maggiore di');
addselopt(condsel,'<','è minore di');
addselopt(condsel,'=','è uguale a');
addselopt(condsel,'!=','è divers@ da');
addselopt(condsel,'IS NOT NULL','è definit@');
addselopt(condsel,'IS NULL','non è definit@');
valsel.style.display='none';
valsel.disabled=true;
valinp.style.display='block';
valinp.disabled=false;
} else if (type=='join') {
truncsel('condsel-'+index);
addselopt(condsel,'=','è uguale a');
addselopt(condsel,'!=','è divers@ da');
addselopt(condsel,'IS NOT NULL','è definit@');
addselopt(condsel,'IS NULL','non è definit@');
valsel.style.display='block';
valsel.disabled=false;
valinp.style.display='none';
valinp.disabled=true;
truncsel('valuesel-'+index);
pupwait(true);
let xhr=new XMLHttpRequest();
xhr.open('GET','instancesh.php?key='+key);
xhr.responseType='json';
xhr.send();
xhr.onload=function() {
let jarr=xhr.response;
for (i=0; i<jarr.length; i++)
addselopt(valsel,jarr[i][0],jarr[i][1]);
console.log('valsel pronto!');
if (valselval!==false)
selind('valuesel-'+index,valselval);
pupwait(false);
};
xhr.onerror=function() {
alert('Request failed');
};
} else {
alert('Attenziò: non so che farmene del tipo "'+type+'": diglielo, al programmatore.');
}
}
function addrow(index,refresh) {
var table=document.getElementById('planciafil');
var newrow=table.insertRow(index);
var newcell0=newrow.insertCell(0);
var newcell1=newrow.insertCell(1);
var newcell2=newrow.insertCell(2);
var newcell3=newrow.insertCell(3);
var newcell4=newrow.insertCell(4);
var newcell5=newrow.insertCell(5);
var newcell6=newrow.insertCell(6);
var newcell7=newrow.insertCell(7);
newcell0.innerHTML='<select class="openpar"><option value="null"></option><option value="(">(</option><option value="((">((</option><option value="(((">(((</option></select>';
newcell1.innerHTML='<select class="fieldsel"></select>';
newcell2.innerHTML='<select class="condsel"></select>';
newcell3.innerHTML='<select class="valuesel" style="display:none;"></select><input type="text" class="valueinp" maxlength="256" style="display:none;">';
newcell4.innerHTML='<select class="closepar"><option value="null"></option><option value=")">)</option><option value="))">))</option><option value=")))">)))</option></select>';
newcell5.innerHTML='<select class="andor"><option value="AND">E</option><option value="OR">O</option></select>';
newcell6.innerHTML='<img class="plus" src="imgs/plus.svg">';
newcell7.innerHTML='<img class="minus" src="imgs/minus.svg">';
if (refresh) {
synctai();
popusels(index,false);
}
}
function ordaddrow(index,refresh) {
var table=document.getElementById('planciaord');
var newrow=table.insertRow(index);
var newcell0=newrow.insertCell(0);
var newcell1=newrow.insertCell(1);
var newcell2=newrow.insertCell(2);
var newcell3=newrow.insertCell(3);
newcell0.style.width='97%';
newcell1.style.width='1%';
newcell2.style.width='1%';
newcell3.style.width='1%';
newcell0.innerHTML='<select class="ordfieldsel"></select>';
newcell1.innerHTML='<select class="ascdesc"><option value="ASC">Crescente</option><option value="DESC">Decrescente</option></select>';
newcell2.innerHTML='<img class="plus" src="imgs/plus.svg">';
newcell3.innerHTML='<img class="minus" src="imgs/minus.svg">';
if (refresh)
synctoi();
}
function synctai() {
var i=0;
var table=document.getElementById('planciafil');
var nodes=table.querySelectorAll('.minus');
var cnodes=nodes.length;
for (i=0; i<cnodes; i++)
// +1 sempre per via della row iniziale
nodes[i].setAttribute('onclick','remrow('+(i+1)+');');
nodes=table.querySelectorAll('.plus');
for (i=0; i<cnodes; i++)
// +2 perché la devi aggiungere dopo la corrente
nodes[i].setAttribute('onclick','addrow('+(i+2)+',true);');
// da qui in poi faccio a scendere per non avere mai id e nomi duplicati
cnodes--;
nodes=table.querySelectorAll('.openpar');
for (i=cnodes; i>-1; i--) {
nodes[i].setAttribute('id','openpar-'+(i+1));
nodes[i].setAttribute('name','openpar-'+(i+1));
}
nodes=table.querySelectorAll('.fieldsel');
for (i=cnodes; i>-1; i--) {
nodes[i].setAttribute('id','fieldsel-'+(i+1));
nodes[i].setAttribute('name','fieldsel-'+(i+1));
nodes[i].setAttribute('onchange','popusels('+(i+1)+',false);');
}
nodes=table.querySelectorAll('.condsel');
for (i=cnodes; i>-1; i--) {
nodes[i].setAttribute('id','condsel-'+(i+1));
nodes[i].setAttribute('name','condsel-'+(i+1));
nodes[i].setAttribute('onchange','inpdisif('+(i+1)+');');
}
nodes=table.querySelectorAll('.valuesel');
for (i=cnodes; i>-1; i--) {
nodes[i].setAttribute('id','valuesel-'+(i+1));
nodes[i].setAttribute('name','valuesel-'+(i+1));
}
nodes=table.querySelectorAll('.valueinp');
for (i=cnodes; i>-1; i--) {
nodes[i].setAttribute('id','valueinp-'+(i+1));
nodes[i].setAttribute('name','valueinp-'+(i+1));
}
nodes=table.querySelectorAll('.closepar');
for (i=cnodes; i>-1; i--) {
nodes[i].setAttribute('id','closepar-'+(i+1));
nodes[i].setAttribute('name','closepar-'+(i+1));
}
nodes=table.querySelectorAll('.andor');
for (i=cnodes; i>-1; i--) {
nodes[i].setAttribute('id','andor-'+(i+1));
nodes[i].setAttribute('name','andor-'+(i+1));
nodes[i].disabled=false;
}
if (cnodes>=0)
nodes[cnodes].disabled=true;
}
function synctoi() {
var i=0;
var table=document.getElementById('planciaord');
var nodes=table.querySelectorAll('.minus');
var cnodes=nodes.length;
for (i=0; i<cnodes; i++)
// +1 sempre per via della row iniziale
nodes[i].setAttribute('onclick','ordremrow('+(i+1)+');');
nodes=table.querySelectorAll('.plus');
for (i=0; i<cnodes; i++)
// +2 perché la devi aggiungere dopo la corrente
nodes[i].setAttribute('onclick','ordaddrow('+(i+2)+',true);');
// da qui in poi faccio a scendere per non avere mai id e nomi duplicati
cnodes--;
nodes=table.querySelectorAll('.ordfieldsel');
for (i=cnodes; i>-1; i--) {
nodes[i].setAttribute('id','ordfieldsel-'+(i+1));
nodes[i].setAttribute('name','ordfieldsel-'+(i+1));
}
nodes=table.querySelectorAll('.ascdesc');
for (i=cnodes; i>-1; i--) {
nodes[i].setAttribute('id','ascdesc-'+(i+1));
nodes[i].setAttribute('name','ascdesc-'+(i+1));
}
}
function selind(id,val) {
var el=document.getElementById(id), i=0, found=false;
while (!found && i<el.length) {
if (el[i].value==val) {
el.selectedIndex=i;
found=true;
}
i++;
}
if (!found)
console.log('"'+val+'" non è stato trovato in "'+id+'"');
}
function setrow(index,openparv,fieldselv,condselv,valueselv,valueinpv,closeparv,andorv) {
selind('openpar-'+index,openparv);
selind('fieldsel-'+index,fieldselv);
popusels(index,valueselv);
selind('condsel-'+index,condselv);
// selind('valuesel-'+index,valueselv);
document.getElementById('valueinp-'+index).value=valueinpv;
if (condselv=='IS NULL' || condselv=='IS NOT NULL') {
document.getElementById('valueinp-'+index).disabled=true;
document.getElementById('valuesel-'+index).disabled=true;
}
selind('closepar-'+index,closeparv);
selind('andor-'+index,andorv);
}
function ordsetrow(index,ordfieldselv,ascdescv) {
selind('ordfieldsel-'+index,ordfieldselv);
selind('ascdesc-'+index,ascdescv);
}
function remrow(index) {
var table=document.getElementById('planciafil');
table.deleteRow(index);
synctai();
if (table.rows.length<2)
document.getElementById('filbut').value='Aggiungi criteri di ricerca';
}
function ordremrow(index) {
var table=document.getElementById('planciaord');
table.deleteRow(index);
synctoi();
if (table.rows.length<2)
document.getElementById('ordbut').value='Aggiungi criteri di ordinamento';
}
function truncfil() {
var table=document.getElementById('planciafil');
while (table.rows.length>1)
remrow(1);
}
function truncord() {
var table=document.getElementById('planciaord');
while (table.rows.length>1)
ordremrow(1);
}
function manfil() {
var filbut=document.getElementById('filbut');
var table=document.getElementById('planciafil');
var crows=table.rows.length;
if (crows<2) {
addrow(1,true);
filbut.value='Rimuovi tutti i criteri di ricerca';
} else {
confirma('<p>Confermi di voler rimuovere tutti i criteri di ricerca?</p>','truncfil();filbut.value=\'Aggiungi criteri di ricerca\'');
}
}
function manord() {
var ordbut=document.getElementById('ordbut');
var table=document.getElementById('planciaord');
var crows=table.rows.length;
if (crows<2) {
ordaddrow(1,true);
ordbut.value='Rimuovi tutti i criteri di ordinamento';
} else {
confirma('<p>Confermi di voler rimuovere tutti i criteri di ordinamento?</p>','truncord();ordbut.value=\'Aggiungi criteri di ordinamento\'');
}
}
function ckpar() {
var i=0;
var table=document.getElementById('planciafil');
var nodes=table.querySelectorAll('.openpar');
var cnodes=nodes.length;
var opars=[];
var cpars=[];
for (i=0; i<cnodes; i++)
opars.push(nodes[i].value);
nodes=table.querySelectorAll('.closepar');
for (i=0; i<cnodes; i++)
cpars.push(nodes[i].value);
var spars='';
for (i=0; i<cnodes; i++) {
if (opars[i]!='null') spars+=opars[i];
if (cpars[i]!='null') spars+=cpars[i];
}
var opq=0, cpq=0, ok=true;
for (i=0; i<spars.length; i++) {
if (spars[i]=='(') {
opq++;
} else if (spars[i]==')') {
cpq++;
}
if (cpq>opq)
break;
}
if (opq!=cpq)
ok=false;
console.log(i+'/'+spars.length+': '+ok);
return ok;
}
function ckf() {
var emsg='';
if (!ckpar()) emsg+='Qualcosa non va con le parentesi!<br>\n';
// emsg+='Comunque NO!<br>\n';
if (emsg=='') {
var table=document.getElementById('planciafil');
var crows=table.rows.length;
if (crows>1)
document.getElementById('andor-'+(crows-1)).disabled=false;
document.getElementById('f').submit();
} else {
alerta('<p>'+emsg+'</p>');
}
}
function pupwait(on) {
var pup=document.getElementById('popup'), inpup=document.getElementById('inpopup');
if (on) {
if (pup.style.display!='table') {
inpup.innerHTML='<div class="waitbub"><img src="imgs/loading.gif"><br>&nbsp;<br>Caricamento in corso...</div>';
pup.style.display='table';
} else {
console.log('Sto già aspettando...');
}
} else {
inpup.innerHTML='<div id="popupcont">...</div>';
pup.style.display='none';
}
}
//-->
</script>
</head>
<body>
<nav>
<div id="hmenu">
<ul>
<?php echo($menuout); ?>
</ul>
<div id="rightdiv">
<div id="logout" class="rlinks"><a href="logout.php">Esci</a></div>
</div>
</div>
</nav>
<div id="popup">
<div id="inpopup">
<div id="popupcont">
...
</div>
</div>
</div>
<!-- <div id="footer">
</div> -->
<div id="debug">
<?php //echo($dbg); ?>
</div>
<div id="fullscreen">
<div id="middlerow">
<table class="edtab">
<tr><td class="insthead">Ciao sono una istanza</td></tr>
<tr><td>
<table class="cbtab">
<tr><td><label for="Blacklisted">Blacklistata:</label></td><td>&nbsp;<input type="checkbox" name="Blacklisted" id="Blacklisted"></td></tr>
<tr><td><label for="New">Nuova:</label></td><td>&nbsp;<input type="checkbox" name="New" id="New"></td></tr>
<tr><td><label for="Good">Papabile:</label></td><td>&nbsp;<input type="checkbox" name="Good" id="Good"></td></tr>
<tr><td><label for="Chosen">Scelta:</label></td><td>&nbsp;<input type="checkbox" name="Chosen" id="Chosen"></td></tr>
<tr><td><label for="Visible">Visibile:</label></td><td>&nbsp;<input type="checkbox" name="Visible" id="Visible"></td></tr>
</table>
<label for="OurDesc">Descrizione nostra:</label><textarea name="OurDesc" id="OurDesc" rows="10" class="tarea"></textarea><br>
<label for="LocalityID">Località:</label> Orpo
</td></tr>
</table>
</div>
</div>
</body>
</html>

View file

@ -1,10 +0,0 @@
<?php
$iniarr=parse_ini_file('sec/marcovaldo.ini') or muoribene(_('Impossibile aprire il file di configurazione.'),false);
$link=mysqli_connect($iniarr['myhost'],$iniarr['myuser'],$iniarr['mypassword'],$iniarr['mydb']) or muoribene(_('Impossibile connettersi al database').': '.mysqli_connect_error().' ['.mysqli_connect_errno().']',false);
mysqli_set_charset($link,'utf8mb4');
$res=mysqli_query($link,'SELECT * FROM Users WHERE ID='.$_SESSION['uid']) or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($res)!=1) muoribene(_('Utente non esistente.').'<br><a href="index.php">Login</a>.',true);
$user=mysqli_fetch_assoc($res);
?>

View file

@ -1,14 +1,15 @@
<?php
$menu=array(
'istanze'=>array('liadd'=>null, 'href'=>'istanze.php', 'title'=>'Istanze', 'selected'=>false, 'submenu'=>
array(
'aggiungi'=>array('liadd'=>null, 'href'=>'editinst?m=new', 'title'=>'Aggiungi', 'selected'=>false, 'submenu'=>null),
)
'istanze'=>array('liadd'=>null, 'href'=>null, 'title'=>'Istanze', 'selected'=>false, 'submenu'=>
array(
'elenco'=>array('liadd'=>null, 'href'=>'instances.php', 'title'=>'Elenco', 'selected'=>false, 'submenu'=>null),
'modifica'=>array('liadd'=>null, 'href'=>null, 'title'=>'Modifica', '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)
),
/* 'blacklist'=>array('liadd'=>null, 'href'=>'#', 'title'=>'Blacklist', 'selected'=>false, 'submenu'=>null),
'accounts'=>array('liadd'=>null, 'href'=>'#', 'title'=>'Accounts', 'selected'=>false, 'submenu'=>null),
'forse'=>array('liadd'=>null, 'href'=>'#', 'title'=>'Forse', 'selected'=>false, 'submenu'=>null)*/
);

24
web/admin/index.html Normal file
View file

@ -0,0 +1,24 @@
<!DOCTYPE HTML>
<html lang="it">
<head>
<title>Mastodon Startpage Admin Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Mastodon Startpage Admin Login">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="icon" type="image/png" href="imgs/icona-32.png" sizes="32x32">
<link rel="icon" type="image/png" href="imgs/icona-192.png" sizes="192x192">
<link rel="icon" type="image/png" href="imgs/icona-512.png" sizes="512x512">
<link rel="apple-touch-icon-precomposed" href="imgs/icona-180.png">
<link rel="stylesheet" type="text/css" href="theme.css?v=<?php echo($cjrand); ?>">
</head>
<body>
<div id="intro">
<p>Ciao,<br>
<a href="instances.php">qui</a> puoi usare un accrocchio che ho fatto per la sezione di admin della <a href="https://rame.altervista.org/mastostart">Mastodon Startpage</a>; chiamiamolo “browser di istanze lato admin”; è uno strumento che permette di “sfogliare” e cercare-ordinare secondo tanti criteri un database di metadati relativi a tante istanze mastodon (poi spiego meglio). Non è il browser di istanze che dovrebbe poi essere mostrato “lato utente” sulla Mastodon Startpage, quello ancora non cè; è invece quello destinato “a uso interno”, “lato admin”, quindi è un po più complicato alluso, ma anche più duttile, rispetto a come pensavo di fare quello “lato utente”.<br>
Ho deciso di renderlo pubblicamente utilizzabile soprattutto perché così magari può essere testato più a fondo.<br>
Rispetto alla versione su cui sto lavorando ha solo tre limitazioni: la possibilità di salvare-modificare-cancellare dei preset di ricerca e ordinamento è disabilitata, i criteri di ricerca impostabili sono al massimo otto, i criteri di ordinamento impostabili sono al massimo sei.<br>
Qualche parola in più sul progetto nel suo insieme, per come lavevamo pensato io che son <a href="https://mastodon.bida.im/@pongrebio">pongrebio</a> e <a href="https://mastodon.bida.im/@Ca_Gi">Ca_Gi</a>. In pratica si dovrebbe comporre di vari accrocchi, alcuni dei quali ci sono già, altri invece no: un crawler (cè) che periodicamente recupera e salva-aggiorna in un database tutti i metadati disponibili relativi alle istanze note a cinque istanze italiane amiche, che al momento sono <a href="https://mastodon.bida.im">bida</a>, <a href="https://mastodon.cisti.org">cisti</a>, <a href="https://nebbia.fail">nebbia</a> (da un po di tempo è rotta), <a href="https://snapj.saja.freemyip.com">snapj</a> e <a href="https://stereodon.social">stereodon</a>, tenendo conto delle rispettive “blacklist” (liste di istanze bloccate), ovvero marcando come tali le istanze blacklistate da una qualsiasi delle cinque istanze amiche, e marcando inoltre come “papabili” le istanze che corrispondono a certi criteri (listanza non è blacklistata, la registrazione di nuovi account è aperta, il numero di utenti è compreso tra 10 e 30.000, il numero di istanze note allistanza è maggiore di 500, il numero di utenti attivi negli ultimi 30 giorni è maggiore di 10); una sezione di admin con un accrocchio (cè, è quello linkato allinizio ma poi anche <a href="instances.php">qui</a>) per “sfogliare” questi dati e un altro accrocchio (non cè) che dia la possibilità di editarli, ovvero per ogni istanza nota poter per esempio scegliere se renderla visibile tramite il “browser di istanze lato utente” e poterne editare alcuni metadati aggiuntivi/alternativi rispetto a quelli “standard” recuperati dal crawler: una descrizione alternativa (perché quella impostata dagli admin e disponibile tra i metadati “standard” recuperabili dal crawler è spesso troppo vaga o troppo scarna o troppo lunga), una localizzazione geografica (relativa al collettivo o al singolo che gestisce listanza, non alla collocazione del server; metadato non presente tra quelli “standard”), le lingue più impiegate sullistanza (quella dichiarata nei metadati “standard” recuperabili dal crawler spesso non corrisponde a quella maggiormente impiegata realmente sullistanza, e ci sono istanze spiccatamente multilingue), modalità di finanziamento (metadato non presente tra quelli “standard”), restrizioni (policy) sui contenuti postabili (metadato non presente tra quelli “standard”), tag descrittive riassuntive del tipo di istanza (metadato non presente tra quelli “standard”). Questi metadati aggiuntivi/alternativi rispetto a quelli “standard” hanno già le proprie strutture nel database e sono visibili dal “browser di istanze lato admin”, quello che manca è appunto la possibilità di editarli; manca inoltre una pagina di gestione degli account admin e, come già detto, il browser di istanze “lato utente”.<br>
Se qualcuno volesse dare una mano il codice si trova <a href="https://git.lattuga.net/pongrebio/MastodonStartpage">qui</a>, nella cartella web/admin.</p>
</div>
</body>
</html>

View file

@ -42,7 +42,7 @@ Mastodon Startpage Admin Login
<tr><td>Nome:</td><td class="rtd"><input type="text" name="username" maxlength="64" autofocus></td></tr>
<tr><td>Password:</td><td class="rtd"><input type="password" name="password" maxlength="64"></td></tr>
<tr><td></td><td class="rtd"><input type="button" value="Entra" class="button" onClick="ckfl();"></td></tr>
<tr><td colspan="2" class="tiptd"><a href="passreset.php">Password dimenticata?</a></td></tr>
<!-- <tr><td colspan="2" class="tiptd"><a href="passreset.php">Password dimenticata?</a></td></tr> -->
</table>
</form>
</div>

View file

@ -7,6 +7,8 @@ require('include/sessionstart.php');
require('include/menu.php');
$menu['istanze']['href']=null;
$menu['istanze']['selected']=true;
$menu['istanze']['submenu']['elenco']['href']=null;
$menu['istanze']['submenu']['elenco']['selected']=true;
buildmenu($menu);
require('include/myconn.php');
@ -86,47 +88,55 @@ function booly($pre,$val,$nottoobad=false,$invcol=false) {
}
}
function trimname($str) {
return(substr($str,1,strlen($str)-2));
}
$dbg.='<pre>'.print_r($_POST,1).'</pre>';
$page=0;
if (array_key_exists('p',$_POST) && preg_match('/^[0-9]*$/',$_POST['p'])==1)
$page=$_POST['p']+0;
/*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.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.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'),
'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'),
'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'),
'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'),
'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.UserCount'=>array('field'=>'Instances.UserCount','name'=>'Numero utenti','type'=>'int'),
'Instances.StatusCount'=>array('field'=>'Instances.StatusCount','name'=>'Numero stati','type'=>'int'),
'Instances.DomainCount'=>array('field'=>'Instances.DomainCount','name'=>'Numero istanze note','type'=>'int'),
'Instances.ActiveUsersMonth'=>array('field'=>'Instances.ActiveUsersMonth','name'=>'Numero utenti attivi (mese)','type'=>'int'),
'Instances.ActiveUsersHalfYear'=>array('field'=>'Instances.ActiveUsersHalfYear','name'=>'Numero 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'),
@ -152,51 +162,51 @@ $cols=array(
//--------------------------------
'InstOurLangs'=>array('name'=>'Lingue impostate da noi','search'=>false,'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),
'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'),
'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),
'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),
'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'=>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),
'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'),
'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),
'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),
'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'=>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),
'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'),
'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),
'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),
'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'=>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),
'InstTags.TagID'=>array('field'=>'InstTags%.TagID','name'=>'[Una tag] ⮞','type'=>'join','join'=>array('InstTags AS 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'),
'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),
'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),
'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),
//--------------------------------
@ -268,6 +278,7 @@ foreach ($_POST as $key=>$val) {
$type=$buf[2];
$subtype=$buf[3];
if (array_key_exists($tagk,$cols) && in_array($type,$types)) {
($tagk=='Instances.AdmCreatedAt') ? $inpisdate=true : $inpisdate=false;
if (strpos($cols[$tagk]['field'],'%')!==false)
$ji++;
$where.=str_replace('%',$ji,$cols[$tagk]['field']);
@ -301,10 +312,13 @@ foreach ($_POST as $key=>$val) {
$jssetrows.=',""';
}
if (preg_match('/^valueinp-\d+$/',$key)===1) {
if (preg_match('/^LIKE|NOT LIKE$/',$cond)===1)
if ($inpisdate && preg_match('/^([0-9]{1,2}) ([0-9]{1,2}) ([0-9]{4,5})$/',$val,$buf)===1) {
$where.=mktime(0,0,0,$buf[2]+0,$buf[1]+0,$buf[3]+0);
} elseif (preg_match('/^LIKE|NOT LIKE$/',$cond)===1) {
$where.='\'%'.myesc($link,$val).'%\'';
else
} else {
$where.='\''.myesc($link,$val).'\'';
}
$jssetrows.=',"NOMMITROVI!"';
$jssetrows.=','.json_encode($val);
}
@ -386,29 +400,53 @@ if (count($havings)>0)
else
$havings='';
$query='SELECT *, Instances.ID AS IID'.$sels.' FROM Instances '.$joins.' '.$where.' GROUP BY IID '.$havings.' '.$order.' LIMIT 50';
$query='SELECT Instances.ID AS IID '.$sels.' FROM Instances '.$joins.' '.$where.' GROUP BY IID '.$havings;
$res=mysqli_query($link,$query)
or muoribene($dbg.'<br>'.$query.': '.mysqli_error($link).'<br>'.'La query è fallita. <a href="instances.php">Resetta</a>.',true);
$cinsts=mysqli_num_rows($res);
$iperp=25;
if ($page*$iperp>$cinsts)
$page=0;
$finst=$page*$iperp;
$query='SELECT *, Instances.ID AS IID '.$sels.' FROM Instances '.$joins.' '.$where.' GROUP BY IID '.$havings.' '.$order.' LIMIT '.$finst.','.$iperp;
$dbg.='QUERONA: '.$query.'<br>'.N;
$tini=microtime(true);
$res=mysqli_query($link,$query)
or muoribene($dbg.'<br>'.$query.': '.mysqli_error($link).'<br>'.'La query è fallita. <a href="instances.php">Resetta</a>.',true);
$dbg.='Durata esecuzione query: '.round(microtime(true)-$tini,4).' sec.<br>'.N;
$cinstsp=mysqli_num_rows($res);
if (mysqli_num_rows($res)<1) {
if ($cinstsp<1) {
$pgout='';
$out='<p>Nessuna istanza da mostrare.</p>'.N;
} else {
// $pgout='Pag. '.($page+1).'/'.(ceil($cinsts/$iperp)-1);
$pgout='<select id="pageselect" onchange="gotopage(this.value)">';
$totp=ceil($cinsts/$iperp);
for ($i=0; $i<$totp; $i++) {
$lastpi=$i*$iperp+$iperp;
if ($lastpi>$cinsts) $lastpi=$cinsts;
($i!=$page) ? $selected='' : $selected=' selected';
$pgout.='<option value="'.$i.'"'.$selected.'>Pagina '.($i+1).'/'.$totp.' (Istanze '.($i*$iperp+1).'-'.$lastpi.'/'.$cinsts.')</option>'.N;
}
$pgout.='</select>';
// ---
$ci=0;
$out='';
while ($row=mysqli_fetch_assoc($res)) {
$ci++;
$out.='<table class="bigtab">'.N;
// $out.='<thead><tr><th class="tdattr">Attributi</th><th>Info</th></thead>'.N;
$out.='<tbody>'.N;
$out.='<tr><td colspan="2" class="insthead">'.$row['URI'].' {'.$row['IID'].'}</td></tr>'.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;*/
$out.='<tr><td colspan="2" class="insthead">'.$row['URI'].' ('.($finst+$ci).'/'.$cinsts.') - <a href="edinst.php?id='.$row['IID'].'">Modifica</a></td></tr>'.N;
$attr=booly(trimname($cols['Instances.Blacklisted']['name']).': ',$row['Blacklisted'],false,true).N;
$attr.=booly(trimname($cols['Instances.New']['name']).': ',$row['New'],true).N;
$attr.=booly(trimname($cols['Instances.Good']['name']).': ',$row['Good']).N;
$attr.=booly(trimname($cols['Instances.Chosen']['name']).': ',$row['Chosen']).N;
$attr.=booly(trimname($cols['Instances.Visible']['name']).': ',$row['Visible']).N;
/* $attr.=booly(trimname($cols['Instances.RegOpen']['name']).': ',$row['RegOpen']).N;
$attr.=booly(trimname($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);
@ -419,7 +457,7 @@ if (mysqli_num_rows($res)<1) {
$bene++;
}
$width=str_replace(',','.',100/$csres*$bene);
$attr.='<div class="colsectheader">Percentuale di risposta ai nostri check: '.round($width,1).'%</div>';
$attr.='<div class="colsectheader">Percentuale di risposta ai nostri check ('.$csres.'): '.round($width,1).'%</div>';
$attr.='<div class="percbg"><div class="percfg" style="width:'.$width.'%;"></div></div>'.N;
mysqli_data_seek($sres,0);
$srow=mysqli_fetch_assoc($sres);
@ -461,14 +499,28 @@ if (mysqli_num_rows($res)<1) {
$attr.='<div class="colsectcont nully">Non disponibili</div>'.N;
}
$out.='<tr><td class="tdattr">'.$attr.'</td><td>'.N;
if ($row['Blacklisted']>0) {
$sres=mysqli_query($link,'SELECT * FROM Blacklist WHERE Domain=\''.myesc($link,$row['URI']).'\'')
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($sres)>0) {
$srow=mysqli_fetch_assoc($sres);
if (!is_null($srow['PublicComment']) && preg_match('/^\s*$/',$srow['PublicComment'])!==1) {
$out.='<div class="baloo">Questa istanza è blacklistata per questo motivo: '.hspech($srow['PublicComment']).'</div>'.N;
} else {
$out.='<div class="baloo">Questa istanza è blacklistata, ma nella blacklist non è specificato il motivo.</div>'.N;
}
} else {
$out.='<div class="baloo">Questa istanza risulta blacklistata nella tabella delle istanze, ma nella tabella “Blacklist” non è presente: probabilmente è stata rimossa dalla tabella “Blacklist” e il crawler non lha ancora aggiornata.</div>'.N;
}
}
$out.='<div class="baloo"><span class="field">'.$cols['Instances.URI']['name'].':</span> <a href="https://'.$row['URI'].'" target="_blank">'.$row['URI'].'</a></div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.Title']['name'].':</span> '.nully($row['Title'],false,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.Thumb']['name'].':</span> '.nully($row['Thumb'],true,'image').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.ShortDesc']['name'].':</span> '.nully($row['ShortDesc'],true,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.LongDesc']['name'].':</span> '.nully($row['LongDesc'],true,'strip').'</div>'.N;
// 'strip' o 'htmlent' per la descrizione nostra?
$out.='<div class="baloo"><span class="ourfield">'.$cols['Instances.OurDesc']['name'].':</span> '.nully($row['OurDesc'],true,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="ourfield">'.$cols['Localities.Locality']['name'].':</span> ';
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['Instances.OurDesc']['name']).':</span> '.nully($row['OurDesc'],true,'strip').'</div>'.N;
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['Localities.Locality']['name']).':</span> ';
if (!is_null($row['LocalityID'])) {
$sres=mysqli_query($link,'SELECT * FROM Localities LEFT JOIN Provinces ON Provinces.ID=Localities.ProvinceID LEFT JOIN Regions ON Regions.ID=Provinces.RegionID LEFT JOIN States ON States.ID=Regions.StateID WHERE Localities.ID='.$row['LocalityID'])
or muoribene(mysqli_error($link),true);
@ -499,9 +551,9 @@ if (mysqli_num_rows($res)<1) {
$i++;
$buf[]=$i.': '.hspech($srow['Code'].' ['.$srow['NameIT'].']');
}
$out.='<div class="baloo"><span class="ourfield">'.$cols['InstOurLangs']['name'].':</span> '.implode('; ',$buf).'</div>'.N;
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstOurLangs']['name']).':</span> '.implode('; ',$buf).'</div>'.N;
} else {
$out.='<div class="baloo"><span class="ourfield">'.$cols['InstOurLangs']['name'].':</span> <span class="nully">Non definite</span></div>'.N;
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstOurLangs']['name']).':</span> <span class="nully">Non definite</span></div>'.N;
}
$sres=mysqli_query($link,'SELECT * FROM InstFinancing LEFT JOIN Financing ON Financing.ID=FinID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),true);
@ -512,9 +564,9 @@ if (mysqli_num_rows($res)<1) {
$i++;
$buf[]=$i.': '.hspech($srow['Type']);
}
$out.='<div class="baloo"><span class="ourfield">'.$cols['InstFinancing']['name'].':</span> '.implode('; ',$buf).'</div>'.N;
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstFinancing']['name']).':</span> '.implode('; ',$buf).'</div>'.N;
} else {
$out.='<div class="baloo"><span class="ourfield">'.$cols['InstFinancing']['name'].':</span> <span class="nully">Non definite</span></div>'.N;
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstFinancing']['name']).':</span> <span class="nully">Non definite</span></div>'.N;
}
$sres=mysqli_query($link,'SELECT * FROM InstPolicies LEFT JOIN Policies ON Policies.ID=PolID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),true);
@ -525,9 +577,9 @@ if (mysqli_num_rows($res)<1) {
$i++;
$buf[]=$i.': '.hspech($srow['Name']);
}
$out.='<div class="baloo"><span class="ourfield">'.$cols['InstPolicies']['name'].':</span> '.implode('; ',$buf).'</div>'.N;
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstPolicies']['name']).':</span> '.implode('; ',$buf).'</div>'.N;
} else {
$out.='<div class="baloo"><span class="ourfield">'.$cols['InstPolicies']['name'].':</span> <span class="nully">Non definite</span></div>'.N;
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstPolicies']['name']).':</span> <span class="nully">Non definite</span></div>'.N;
}
$sres=mysqli_query($link,'SELECT * FROM InstTags LEFT JOIN Tags ON Tags.ID=TagID WHERE InstID='.$row['IID'].' ORDER BY Pos ASC')
or muoribene(mysqli_error($link),true);
@ -538,9 +590,9 @@ if (mysqli_num_rows($res)<1) {
$i++;
$buf[]=$i.': '.hspech($srow['Name']);
}
$out.='<div class="baloo"><span class="ourfield">'.$cols['InstTags']['name'].':</span> '.implode('; ',$buf).'</div>'.N;
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstTags']['name']).':</span> '.implode('; ',$buf).'</div>'.N;
} else {
$out.='<div class="baloo"><span class="ourfield">'.$cols['InstTags']['name'].':</span> <span class="nully">Non definite</span></div>'.N;
$out.='<div class="baloo"><span class="ourfield">'.trimname($cols['InstTags']['name']).':</span> <span class="nully">Non definite</span></div>'.N;
}
$out.='<div class="baloo"><span class="field">'.$cols['Instances.Email']['name'].':</span> '.nully($row['Email'],true,'email').'</div>'.N;
$out.='<div class="baloo"><span class="field">'.$cols['Instances.Software']['name'].':</span> '.nully($row['Software'],false,'strip').'</div>'.N;
@ -566,7 +618,6 @@ if (mysqli_num_rows($res)<1) {
$out.='<div class="bigtabfoot"></div>';
}
$presid=0;
if (array_key_exists('presets',$_POST) && preg_match('/^[0-9]+$/',$_POST['presets'])===1)
$presid=$_POST['presets'];
@ -586,7 +637,7 @@ mysqli_close($link);
<!DOCTYPE HTML>
<html lang="it">
<head>
<title>Mastodon Startpage Admin - Istanze</title>
<title>Mastodon Startpage Admin - Elenco istanze</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="Admin pages for Mastodon Startpage">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
@ -611,21 +662,6 @@ function ulsh(el,sh) {
else
el.style.display='none';
}
function golang(lang) {
var loc=document.location.href;
loc=loc.replace(/#.*$/,'');
loc=loc.replace(/\/$/,'');
if (document.documentElement.lang=='en') {
if (lang!='en')
document.location.href=loc+'/'+lang;
} else {
if (lang!='en')
document.location.href=loc.substr(0,loc.length-3)+'/'+lang;
else
document.location.href=loc.substr(0,loc.length-3);
}
}
function shideplancia() {
var plancia=document.getElementById('plancia');
var plctrl=document.getElementById('plctrl');
@ -637,7 +673,9 @@ function shideplancia() {
plctrl.innerHTML='Nascondi plancia';
}
}
function hent(str) {
return str.replace(/&/g,'&amp;').replace(/>/g,'&gt;').replace(/</g,'&lt;').replace(/"/g,'&quot;');
}
function truncsel(el) {
var sel=document.getElementById(el), len=sel.length, i=0;
for (i=len-1; i>=0; i--)
@ -752,47 +790,55 @@ function popusels(index,valselval) {
}
function addrow(index,refresh) {
var table=document.getElementById('planciafil');
var newrow=table.insertRow(index);
var newcell0=newrow.insertCell(0);
var newcell1=newrow.insertCell(1);
var newcell2=newrow.insertCell(2);
var newcell3=newrow.insertCell(3);
var newcell4=newrow.insertCell(4);
var newcell5=newrow.insertCell(5);
var newcell6=newrow.insertCell(6);
var newcell7=newrow.insertCell(7);
newcell0.innerHTML='<select class="openpar"><option value="null"></option><option value="(">(</option><option value="((">((</option><option value="(((">(((</option></select>';
newcell1.innerHTML='<select class="fieldsel"><?php echo($fieldselopts); ?></select>';
newcell2.innerHTML='<select class="condsel"></select>';
newcell3.innerHTML='<select class="valuesel" style="display:none;"></select><input type="text" class="valueinp" maxlength="256" style="display:none;">';
newcell4.innerHTML='<select class="closepar"><option value="null"></option><option value=")">)</option><option value="))">))</option><option value=")))">)))</option></select>';
newcell5.innerHTML='<select class="andor"><option value="AND">E</option><option value="OR">O</option></select>';
newcell6.innerHTML='<img class="plus" src="imgs/plus.svg" title="Aggiungi un criterio sotto questo">';
newcell6.style.width='22px';
newcell7.innerHTML='<img class="minus" src="imgs/minus.svg" title="Rimuovi questo criterio">';
newcell7.style.width='22px';
if (refresh) {
synctai();
popusels(index,false);
if (table.rows.length<9) {
var newrow=table.insertRow(index);
var newcell0=newrow.insertCell(0);
var newcell1=newrow.insertCell(1);
var newcell2=newrow.insertCell(2);
var newcell3=newrow.insertCell(3);
var newcell4=newrow.insertCell(4);
var newcell5=newrow.insertCell(5);
var newcell6=newrow.insertCell(6);
var newcell7=newrow.insertCell(7);
newcell0.innerHTML='<select class="openpar"><option value="null"></option><option value="(">(</option><option value="((">((</option><option value="(((">(((</option></select>';
newcell1.innerHTML='<select class="fieldsel"><?php echo($fieldselopts); ?></select>';
newcell2.innerHTML='<select class="condsel"></select>';
newcell3.innerHTML='<select class="valuesel" style="display:none;"></select><input type="text" class="valueinp" maxlength="256" style="display:none;">';
newcell4.innerHTML='<select class="closepar"><option value="null"></option><option value=")">)</option><option value="))">))</option><option value=")))">)))</option></select>';
newcell5.innerHTML='<select class="andor"><option value="AND">E</option><option value="OR">O</option></select>';
newcell6.innerHTML='<img class="plus" src="imgs/plus.svg" title="Aggiungi un criterio sotto questo">';
newcell6.style.width='22px';
newcell7.innerHTML='<img class="minus" src="imgs/minus.svg" title="Rimuovi questo criterio">';
newcell7.style.width='22px';
if (refresh) {
synctai();
popusels(index,false);
}
} else {
alerta('Non è possibile impostare più di 8 criteri di ricerca.');
}
}
function ordaddrow(index,refresh) {
var table=document.getElementById('planciaord');
var newrow=table.insertRow(index);
var newcell0=newrow.insertCell(0);
var newcell1=newrow.insertCell(1);
var newcell2=newrow.insertCell(2);
var newcell3=newrow.insertCell(3);
newcell0.style.width='97%';
newcell1.style.width='1%';
newcell2.style.width='1%';
newcell3.style.width='1%';
newcell0.innerHTML='<select class="ordfieldsel"><?php echo($ordfieldselopts); ?></select>';
newcell1.innerHTML='<select class="ascdesc"><option value="ASC">Crescente</option><option value="DESC">Decrescente</option></select>';
newcell2.innerHTML='<img class="plus" src="imgs/plus.svg" title="Aggiungi un criterio sotto questo">';
newcell3.innerHTML='<img class="minus" src="imgs/minus.svg" title="Rimuovi questo criterio">';
if (refresh)
synctoi();
if (table.rows.length<7) {
var newrow=table.insertRow(index);
var newcell0=newrow.insertCell(0);
var newcell1=newrow.insertCell(1);
var newcell2=newrow.insertCell(2);
var newcell3=newrow.insertCell(3);
newcell0.style.width='97%';
newcell1.style.width='1%';
newcell2.style.width='1%';
newcell3.style.width='1%';
newcell0.innerHTML='<select class="ordfieldsel"><?php echo($ordfieldselopts); ?></select>';
newcell1.innerHTML='<select class="ascdesc"><option value="ASC">Crescente</option><option value="DESC">Decrescente</option></select>';
newcell2.innerHTML='<img class="plus" src="imgs/plus.svg" title="Aggiungi un criterio sotto questo">';
newcell3.innerHTML='<img class="minus" src="imgs/minus.svg" title="Rimuovi questo criterio">';
if (refresh)
synctoi();
} else {
alerta('Non è possibile impostare più di 6 criteri di ordinamento.');
}
}
function synctai() {
var i=0;
@ -1010,7 +1056,6 @@ function pupwait(on) {
pup.style.display='none';
}
}
//function setrow(index,openparv,fieldselv,condselv,valueselv,valueinpv,closeparv,andorv)
function loadpres() {
let pres=document.getElementById('presets');
@ -1020,7 +1065,7 @@ function loadpres() {
formdata.append('act','load');
formdata.append('pid',pres.value);
let xhr=new XMLHttpRequest();
xhr.open('POST','loadsavepres.php');
xhr.open('POST','loadsaverempres.php');
xhr.responseType='json';
xhr.send(formdata);
xhr.onload=function() {
@ -1057,6 +1102,27 @@ function loadpres() {
alerta('<p>Non hai selezionato alcun preset ;)</p>');
}
}
function rempres() {
pupwait(true);
let pres=document.getElementById('presets');
let formdata=new FormData(document.forms.f);
formdata.append('act','remove');
formdata.append('pid',pres.value);
let xhr=new XMLHttpRequest();
xhr.open('POST','loadsaverempres.php');
xhr.responseType='json';
xhr.send(formdata);
xhr.onload=function() {
console.log(xhr.response);
pres.remove(pres.selectedIndex);
pres.selectedIndex=0;
pupwait(false);
};
xhr.onerror=function() {
pupwait(false);
alert('La richiesta è fallita.');
};
}
function savepres(txt,asnew) {
pupwait(true);
let pres=document.getElementById('presets');
@ -1066,7 +1132,7 @@ function savepres(txt,asnew) {
if (!asnew)
formdata.append('pid',pres.value);
let xhr=new XMLHttpRequest();
xhr.open('POST','loadsavepres.php');
xhr.open('POST','loadsaverempres.php');
xhr.responseType='json';
xhr.send(formdata);
xhr.onload=function() {
@ -1092,12 +1158,21 @@ function pupsavepres(asnew) {
var prestext=pres.options[pres.selectedIndex].text;
var pre='<p>Se vuoi puoi modificare il nome del preset che stai per sovrascrivere</p>';
if (asnew) pre='<p>Dai un nuovo nome al nuovo preset che stai per salvare</p>';
inpup.innerHTML='<div class="loadsavepresbub">'+pre+'<input type="text" maxlength="256" value="'+prestext.replace(/"/g,'&quot;')+'" id="presname"><input type="button" value="Salva" onClick="ckpresname('+asnew+');"><input type="button" value="Annulla" onClick="pupoff();"><div id="ckmsg"></div></div>';
inpup.innerHTML='<div class="loadsavepresbub">'+pre+'<input type="text" maxlength="256" value="'+hent(prestext)+'" id="presname"><input type="button" value="Salva" onClick="ckpresname('+asnew+');"><input type="button" value="Annulla" onClick="pupoff();"><div id="ckmsg"></div></div>';
pup.style.display='table';
} else {
alerta('<p>Non hai selezionato alcun preset ;)</p>');
}
}
function puprempres() {
var pres=document.getElementById('presets');
if (pres.value!='null') {
var prestext=pres.options[pres.selectedIndex].text;
confirma('Confermi leliminazione del preset «'+hent(prestext)+'»?','rempres()');
} else {
alerta('<p>Non hai selezionato alcun preset ;)</p>');
}
}
function ckpresname(asnew) {
var pres=document.getElementById('presets');
var presname=document.getElementById('presname').value;
@ -1136,7 +1211,10 @@ function pupoff() {
inpup.innerHTML='<div id="popupcont">...</div>';
pup.style.display='none';
}
function gotopage(pi) {
document.getElementById('p').value=pi;
ckf();
}
//-->
</script>
</head>
@ -1149,7 +1227,8 @@ function pupoff() {
</ul>
<div id="rightdiv">
<div id="plctrl" class="rlinks" onclick="shideplancia();">Mostra plancia</div>
<div id="logout" class="rlinks"><a href="logout.php">Esci</a></div>
<div id="logout" class="rlinks" onclick="document.location.href='logout.php'"><a href="logout.php">Esci</a></div>
</div>
</div>
</nav>
@ -1161,13 +1240,12 @@ function pupoff() {
</div>
</div>
<!--
<div id="footer">
<form action="edinst.php" name="addinst" method="post">
<?php echo($pgout); ?>
<!-- <form action="edinst.php" name="addinst" method="post">
<table><tr><td>Aggiungi unistanza:</td><td><input type="text" name="URI" maxlength="512"></td><td><input type="button" value="Vai" onClick="ckaif();"></td></tr></table>
</form>
</form> -->
</div>
-->
<div id="debug">
<?php echo($dbg); ?>
@ -1184,7 +1262,8 @@ function pupoff() {
<table id="planciaothers" class="planciatab">
<tr><td><input type="button" id="subbut" value="Applica" class="ctrlbut" onclick="ckf();"></td></tr>
</table>
<table class="planciatab"><tr><td style="width:1%">Preset: </td><td style="width:95%"><select name="presets" id="presets" class="presets"><?php echo($presopts); ?></select></td><td style="width:1%"><img src="imgs/carica.svg" class="lilbut" onclick="loadpres();" title="Carica i criteri dal preset selezionato"></td><td style="width:1%"><img src="imgs/salva.svg" class="lilbut" onclick="pupsavepres(false);" title="Salva i criteri impostati nel preset selezionato sovrascrivendolo"></td><td style="width:1%"><img src="imgs/salvacome.svg" class="lilbut" onclick="pupsavepres(true);" title="Salva i criteri impostati come nuovo preset ..."></td><td style="width:1%"><img src="imgs/minus.svg" class="lilbut" onclick="rempres();" title="Elimina il preset selezionato"></td></tr></table>
<table class="planciatab"><tr><td style="width:1%">Preset: </td><td style="width:95%"><select name="presets" id="presets" class="presets"><?php echo($presopts); ?></select></td><td style="width:1%"><img src="imgs/carica.svg" class="lilbut" onclick="loadpres();" title="Carica i criteri dal preset selezionato"></td><td style="width:1%"><img src="imgs/salva.svg" class="lilbut" onclick="pupsavepres(false);" title="Salva i criteri impostati nel preset selezionato sovrascrivendolo (permette inoltre di rinominarlo) ..."></td><td style="width:1%"><img src="imgs/salvacome.svg" class="lilbut" onclick="pupsavepres(true);" title="Salva i criteri impostati come nuovo preset ..."></td><td style="width:1%"><img src="imgs/minus.svg" class="lilbut" onclick="puprempres();" title="Elimina il preset selezionato"></td></tr></table>
<input type="hidden" name="p" id="p" value="...">
</form>
</div>

View file

@ -106,7 +106,16 @@ if (array_key_exists('act',$_POST)) {
or muoribene(mysqli_error($link),true);
}
} elseif ($_POST['act']=='remove' && array_key_exists('pid',$_POST) && preg_match('/^[0-9]+$/',$_POST['pid'])===1) {
echo(json_encode($_POST));
$pid=$_POST['pid'];
$query='DELETE FROM PresFiltConds WHERE PresID='.$pid;
mysqli_query($link,$query)
or muoribene(mysqli_error($link),true);
$query='DELETE FROM PresOrdConds WHERE PresID='.$pid;
mysqli_query($link,$query)
or muoribene(mysqli_error($link),true);
$query='DELETE FROM Presets WHERE ID='.$pid;
mysqli_query($link,$query)
or muoribene(mysqli_error($link),true);
}
}

View file

@ -60,7 +60,7 @@ p {
padding: 3px;
color: white;
height: 30px;
background-color: #916f6f;
background-color: #6f8a91;
border-radius: 5px;
text-align: center;
vertical-align: middle;
@ -68,6 +68,10 @@ p {
font-size: 12pt;
font-weight: bold;
}
.bigtab .insthead a {
color: #1c2224;
/*text-decoration: underline;*/
}
.bigtab img {
max-width: 100%;
display: block;
@ -459,6 +463,78 @@ input {
min-width: 320px;
}
.edtab {
background-color: white;
font-size: 10pt;
margin-left: auto;
margin-right: auto;
width: 400px;
margin-top: 32px;
}
.edtab .insthead {
padding: 3px;
color: white;
height: 30px;
background-color: #916f6f;
border-radius: 5px;
text-align: center;
vertical-align: middle;
color: white;
font-size: 12pt;
font-weight: bold;
}
.edtab input {
width: auto;
font-size: 10pt;
padding: 0;
}
.edtab img {
max-width: 100%;
display: block;
margin-left: auto;
margin-right: auto;
}
/*720x1280*/
.edtab td {
padding: 3px;
text-align: left;
vertical-align: top;
/* word-break: break-word;*/
background-color: lightgrey;
border-radius: 5px;
}
.edtab .left {
width: 1%;
text-align: right;
}
.edtab .right {
width: 99%;
}
.edtab .tarea {
width: 100%;
resize: none;
padding: 3px;
border-radius: 3px;
border: 1px;
}
.cbtab {
background-color: red;
border-spacing: 0;
}
.cbtab td {
border-radius: 0;
padding: 0;
border: none;
}
#pageselect {
position: absolute;
left: 50%;
transform: translateX(-50%);
margin-top: 5px;
}
#debug {
position: fixed;
left: 0;
@ -467,6 +543,20 @@ input {
height: 240px;
font-size: 8pt;
overflow: auto;
display: none;
}
#intro {
width:800px;
margin-left:auto;
margin-right:auto;
padding:10px;
font-size:14pt;
line-height: 18pt;
background-color:lightgrey;
}
#intro p {
margin-bottom: 0;
}
@media only screen and (max-width:720px) {