This commit is contained in:
pezcurrel 2020-03-24 23:22:07 +01:00
parent 55f237a688
commit 6f84b20137
20 changed files with 23338 additions and 76 deletions

View file

@ -16,11 +16,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define('N',"\n");
require __DIR__ . "/../../vendor/autoload.php";
use LanguageDetection\Language;
define('N',"\n");
if (strtoupper(substr(PHP_OS,0,3))==='WIN')
$iswin=true;
else
@ -226,6 +226,8 @@ while ($row=mysqli_fetch_row($res)) {
}
$tables[$row[0]]=$fields;
}
print_r($tables);
exit();
if ($riprendi) {
lecho('Pare che ci sia un lavoro in sospeso, provo a riprenderlo...'.N);
@ -646,12 +648,11 @@ function langs($instid, $uri) {
$res=mysqli_query($link,'SELECT * FROM Languages WHERE Code=\''.myesc($link,$lang).'\'')
or mexit(mysqli_error($link).N,3);
if (mysqli_num_rows($res)<1) {
$code=myesc($link,truncs($lang,'Languages','Code','«'.$instrow['URI'].'»'));
$NameIt=myesc($link,truncs(my_ucfirst(locale_get_display_name($lang,'it')),'Languages','NameIT','«'.$instrow['URI'].'»'));
$NameEn=myesc($link,truncs(my_ucfirst(locale_get_display_name($lang,'en')),'Languages','NameEN','«'.$instrow['URI'].'»'));
$NameFr=myesc($link,truncs(my_ucfirst(locale_get_display_name($lang,'fr')),'Languages','NameFR','«'.$instrow['URI'].'»'));
$NameEs=myesc($link,truncs(my_ucfirst(locale_get_display_name($lang,'es')),'Languages','NameES','«'.$instrow['URI'].'»'));
$NameOrig=myesc($link,truncs(my_ucfirst(locale_get_display_name($lang,$lang)),'Languages','NameES','«'.$instrow['URI'].'»'));
$q = 'INSERT INTO Languages (ID, Code, NameIT, NameEN, NameFR, NameES, NameOrig) VALUES (NULL, \''.myesc($link,truncs($lang,'Languages','Code','«'.$instrow['URI'].'»')).'\', \''.$NameIt.'\', \''.$NameEn.'\', \''.$NameFr.'\', \''.$NameEs.'\', \''.$NameOrig.'\')';
$NameOrig=myesc($link,truncs(my_ucfirst(locale_get_display_name($lang,$lang)),'Languages','NameOrig','«'.$instrow['URI'].'»'));
$q = 'INSERT INTO Languages (ID, Code, NameIT, NameEN, NameOrig) VALUES (NULL, \''.$code.'\', \''.$NameIt.'\', \''.$NameEn.'\', \''.$NameOrig.'\')';
mysqli_query($link, $q)
or mexit(mysqli_error($link).N,3);
$langid=mysqli_insert_id($link);
@ -796,7 +797,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, '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);
$instrow=array('ID'=>null, 'FirstSeen'=>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'];
@ -894,6 +895,7 @@ while ($i<$cinsts) {
flushtronc($oldinstrow['ID']);
$instid=$oldinstrow['ID'];
$instrow['ID']=$oldinstrow['ID'];
$instrow['FirstSeen']=$oldinstrow['FirstSeen'];
$instrow['New']=$oldinstrow['New'];
if ($instrow['Good']==1 && $oldinstrow['Good']==0) {
notify('Listanza «<a href="editinst.php?id='.$instrow['ID'].'">'.$instrow['URI'].'</a>» non era papabile, ma lo è diventata!',1);
@ -937,6 +939,7 @@ while ($i<$cinsts) {
}
} else {
lecho('«'.$info['uri'].'» non è già presente nel DB, la aggiungo...'.N);
$instrow['FirstSeen']=time();
$instrow['New']=1;
$fields=array();
$values='';

View file

@ -0,0 +1,2 @@
/\.gab\.best$/
/\.4chan\.icu$/

197
web/admin/crawler/crawlerone.php Executable file
View file

@ -0,0 +1,197 @@
#!/bin/php
<?php
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
setlocale(LC_ALL,'it_IT.UTF-8');
define('N',"\n");
$contextopts=array(
'http'=>array(
'timeout'=>3
),
'socket'=>array(
'tcp_nodelay'=>true
)
);
$context=stream_context_create($contextopts);
$startinst='mastodon.social';
$exfp='crawlerone.exclude';
$allfp='listaglobale.txt';
$okfp='listamastodon.txt';
$softfp='listasoft.txt';
$allf=@fopen($allfp,'w');
$okf=@fopen($okfp,'w');
$softf=@fopen($softfp,'w');
//$insts=array(array('dom'=>$startinst,'ckd'=>false));
$insts=array();
$okinsts=array();
$softwares=array();
function isempty($val) {
if (preg_match('/^\s*$/',$val)===1)
return(true);
else
return(false);
}
function cdate() {
return(strftime('%a %d %b %Y, %T'));
}
function waituntilonline() {
global $context;
$url='http://www.google.coma';
while (@file_get_contents($url,false,$context)===false) {
echo(cdate().' - Pare che siamo offline...'.N);
sleep(5);
}
echo(cdate().' - Pare che siamo online! :-)'.N);
}
function updexarr() {
global $exarr, $exfp;
$exarr=file($exfp,FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
}
function ckexarr($inst) {
global $exarr;
foreach ($exarr as $re)
if (preg_match($re,$inst)===1) return(true);
return(false);
}
function crawl($inst) {
global $insts, $okinsts, $softwares, $allf, $okf, $softf, $context;
waituntilonline();
updexarr();
foreach ($softwares as $key=>$val)
echo('Software «'.$key.'»: '.$val.' istanze.'.N);
if (!isempty($inst)) {
// i check sulla presenza di $inst tra le già scovate e crawlate e quello sull'eventuale esclusione vengon fatti subito prima della chiamata ricorsiva di crawl, sotto
echo('«'.$inst.'» non è presente nella lista delle istanze scovate, la aggiungo.'.N);
$insts[]=$inst;
fwrite($allf,$inst.N);
echo('«'.$inst.'»: provo a recuperare info da Nodeinfo ... ');
$buf=@file_get_contents('https://'.$inst.'/nodeinfo/2.0',false,$context);
if ($buf!=false) {
echo('OK :-)'.N);
echo('«'.$inst.'»: Nodeinfo: controllo che il software sia mastodon ... ');
$buf=json_decode($buf,true);
if (is_array($buf) && array_key_exists('software',$buf) && array_key_exists('name',$buf['software'])) {
if (preg_match('/mastodon/i',$buf['software']['name'])===1) {
echo('SI! :-)'.N);
echo('«'.$inst.'»: il software è mastodon, aggiungo listanza alla lista delle istanze OK! :-)'.N);
$okinsts[]=$inst;
fwrite($okf,$inst.N);
} else {
echo('NO :-('.N);
echo('«'.$inst.'»: il software non è mastodon, NON aggiungo listanza alla lista delle istanze ok :-('.N);
}
$software=strtolower($buf['software']['name']);
if (!isempty($software)) {
if (!array_key_exists($software,$softwares)) {
echo('Ho trovato un software che non mi è ancora noto: «'.$software.'»!'.N);
$softwares[$software]=1;
fwrite($softf,$software.N);
} else {
$softwares[$software]++;
}
}
} else {
echo('ERRORE! :-('.N);
}
} else {
echo('ERRORE :-('.N);
echo('«'.$inst.'»: Nodeinfo non ha risposto, NON aggiungo listanza alla lista delle istanze ok :-('.N);
}
echo('«'.$inst.'»: provo a recuperare la lista delle istanze conosciute allistanza ... ');
$peers=@file_get_contents('https://'.$inst.'/api/v1/instance/peers',false,$context);
if ($peers!=false) {
echo('OK :-)'.N);
$peers=json_decode($peers,true);
if (is_array($peers)) {
foreach ($peers as $peer) {
if (@is_string($peer)) {
if (!ckexarr($peer)) {
if (!in_array($peer,$insts)) {
echo('>>> Crawlo «'.$peer.'».'.N);
crawl($peer);
} else {
echo('>>> NON crawlo «'.$peer.'» perché lho già fatto.'.N);
}
} else {
echo('>>> NON crawlo «'.$peer.'» perché il suo nome corrisponde a unesclusione.'.N);
}
} else {
echo('>>> NON crawlo «'.$peer.'» perché il suo nome non è una stringa.'.N);
}
}
}
} else {
echo('ERRORE :-('.N);
}
} else {
echo('NON aggiungo istanze senza nome.'.N);
}
echo('~~~~~~~ Stats: '.count($insts).' istanze note, '.count($okinsts).' istanze mastodon vive, '.count($softwares).' software trovati. ~~~~~~~'.N);
}
crawl($startinst);
echo('FINE CRAWLING! :-)'.N);
@fclose($allfp);
@fclose($okfp);
@fclose($softfp);
echo('Salvo i risultati (tutte le istanze, istanze ok, softwares) ordinati nei rispettivi file.'.N);
sort($insts);
sort($okinsts);
arsort($softwares,SORT_NUMERIC);
$f=@fopen($allfp,'w');
if ($f!==false) {
foreach ($insts as $inst)
fwrite($f,$inst.N);
fclose($f);
} else {
echo('Non ho potuto aprire in scrittura il file «'.$allfp.'».'.N);
}
$f=@fopen($okfp,'w');
if ($f!==false) {
foreach ($okinsts as $inst)
fwrite($f,$inst.N);
fclose($f);
} else {
echo('Non ho potuto aprire in scrittura il file «'.$okfp.'».'.N);
}
$f=@fopen($softfp,'w');
if ($f!==false) {
foreach ($softwares as $software=>$num)
fwrite($f,$software.' '.$num.N);
fclose($f);
} else {
echo('Non ho potuto aprire in scrittura il file «'.$softfp.'».'.N);
}
exit(0);
?>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,22 @@
bacn 1
corgidon 1
diaspora 26
dolphin 29
epicyon 2
fedimoe 1
friendica 167
groundpolis 3
hackhackhack 1
hubzilla 87
imaginarium 1
mastodon 2253
misskey 97
osada 1
plume 45
prismo 4
pub-relay 1
red 1
reel2bits 4
selective-relay 2
tavern 1
zap 9

View file

@ -22,16 +22,26 @@ function hspech($str) {
return(htmlspecialchars($str,ENT_QUOTES|ENT_HTML5,'UTF-8'));
}
$dbg.='<pre>'.print_r($_POST,1).'</pre>';
$dbg.='<pre>'.print_r($_GET,1).'</pre>';
if (array_key_exists('id',$_GET) && preg_match('/^[0-9]+$/',$_GET['id'])===1) {
$res=mysqli_query($link,'SELECT * FROM Instances WHERE ID='.$_GET['id'])
or muoribene(mysqli_error($link).'<br>Puoi <a href="instances.php">tornare allelenco delle istanze</a>.',true);
if (mysqli_num_rows($res)!=1)
muoribene('Non esiste alcuna istanza con ID='.$_GET['ID'].'<br>Puoi <a href="instances.php">tornare allelenco delle istanze</a>.');
$inst=mysqli_fetch_assoc($res);
}
mysqli_close($link);
function check($row,$col) {
if ($row[$col]>0)
echo(' checked');
}
?>
<!DOCTYPE HTML>
<html lang="it">
<head>
<title>Mastodon Startpage Admin - Modifica di «<?php //echo($data['URI']); ?>»</title>
<title>Mastodon Startpage Admin - Modifica di «<?php echo($inst['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">
@ -45,17 +55,158 @@ mysqli_close($link);
<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 getselarr(selid) {
var sel=document.getElementById(selid), selc=sel.length, i, arr=[], selected;
for (i=0; i<selc; i++) {
(!sel.options[i].selected) ? selected=false : selected=true;
arr.push([sel.options[i].text,sel.options[i].value,selected]);
}
return arr;
}
function ulsh(el,sh) {
if (sh)
el.style.display='block';
else
el.style.display='none';
function filtsel(selarr,filt,selid,recbid,inpid,ocol,ecol) {
var sel=document.getElementById(selid), selarrc=selarr.length, i, ii, go=true;
if (!document.getElementById(recbid).checked) {
filt=filt.replace(/([.?*+^$[\]\\(){}|-])/g,'\\$1');
} else {
try { (RegExp(filt)); }
catch(e) { go=false; }
}
if (go) {
sel.length=0;
for (i=0; i<selarrc; i++) {
if (RegExp(filt,'i').test(selarr[i][0]))
sel.options.add(new Option(selarr[i][0],selarr[i][1],false,selarr[i][2]));
}
if (ocol!=null)
document.getElementById(inpid).style.backgroundColor=ocol;
} else if (ecol!=null) {
document.getElementById(inpid).style.backgroundColor=ecol;
}
}
function selup(selid) {
var sel=document.getElementById(selid), len=sel.length, i, prevopt, curopt;
if (sel.selectedIndex>0) {
for (i=0; i<len; i++) {
if (sel.options[i].selected) {
prevopt=sel.options[i-1];
curopt=sel.options[i];
sel.remove(i-1);
sel.remove(i-1);
sel.add(curopt,i-1);
sel.add(prevopt,i);
}
}
}
}
function seltop(selid) {
var sel=document.getElementById(selid);
while (sel.selectedIndex>0)
selup(selid);
}
function seldown(selid) {
var sel=document.getElementById(selid), len=sel.length, i, nextopt, curopt;
if (!sel.options[len-1].selected) {
for (i=len-1; i>-1; i--) {
if (sel.options[i].selected) {
curopt=sel.options[i];
nextopt=sel.options[i+1];
sel.remove(i);
sel.remove(i);
sel.add(curopt,i);
sel.add(nextopt,i);
}
}
}
}
function selbot(selid) {
var sel=document.getElementById(selid), len=sel.length;
if (sel.selectedIndex>=0) {
while (!sel.options[len-1].selected)
seldown(selid);
}
}
function rmelbyval(refarr,valindex,val) {
var len=refarr.length, i;
for (i=len-1; i>-1; i--) {
if (refarr[i][valindex]==val)
refarr.splice(i,1);
}
return refarr;
}
function seladd(fromselid,toselid,refarr) {
var fromsel=document.getElementById(fromselid), fslen=fromsel.length, tosel=document.getElementById(toselid), i;
// farlo a scalare invece che a crescere inverte nella select di destinazione l'ordine delle opzioni scelte in quella di origine, perciò lo faccio a crescere
for (i=0; i<fslen; i++) {
if (fromsel.options[i].selected) {
refarr=rmelbyval(refarr,1,fromsel.options[i].value);
tosel.add(fromsel.options[i]);
fslen--;
i--;
}
}
return refarr;
}
function sortByKey(array, key) {
return array.sort(function(a, b) {
var x = a[key]; var y = b[key];
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
});
}
function selrem(fromselid,toselid,refarr) {
var fromsel=document.getElementById(fromselid), fslen=fromsel.length, tosel=document.getElementById(toselid), i;
for (i=fslen-1; i>-1; i--) {
if (fromsel.options[i].selected) {
refarr.push([fromsel.options[i].text,fromsel.options[i].value,true]);
fromsel.remove(i);
}
}
refarr=sortByKey(refarr,0);
tosel.length=0;
for (i=0; i<refarr.length; i++) {
tosel.add(new Option(refarr[i][0],refarr[i][1]));
}
return refarr;
}
function selordalf(selid) {
var sel=document.getElementById(selid), len=sel.length, arr=[], i;
for (i=0; i<len; i++)
arr.push([sel.options[i].text,sel.options[i].value,sel.options[i].selected]);
arr=sortByKey(arr,0);
sel.length=0;
for (i=0; i<len; i++)
sel.add(new Option(arr[i][0],arr[i][1],false,arr[i][2]));
}
function selordinv(selid) {
var sel=document.getElementById(selid), len=sel.length, arr=[], i;
for (i=0; i<len; i++)
arr.push([sel.options[i].text,sel.options[i].value,sel.options[i].selected]);
arr=arr.reverse();
sel.length=0;
for (i=0; i<len; i++)
sel.add(new Option(arr[i][0],arr[i][1],false,arr[i][2]));
}
function closeinpup() {
document.getElementById('inpopup').innerHTML='<div id="popupcont">...</div>';
document.getElementById('popup').style.display='none';
}
function edit(selid,what,mode) {
var act='', id=0;
if (mode=='edit')
act={0:'Modifica',1:'modificare'};
else if (mode=='add')
act={0:'Aggiungi',1:'aggiungere'};
else if (mode=='remove')
act={0:'Elimina',1:'eliminare'};
var sel=document.getElementById(selid);
if ((mode=='edit' || mode=='remove') && sel.selectedIndex<0) {
alerta('<p>Devi selezionare una voce da '+act[1]+' ;-)</p>');
} else {
if (mode=='edit' || mode=='remove')
id=sel.options[sel.selectedIndex].value;
document.getElementById('inpopup').innerHTML='<div class="hiftit"><img src="imgs/p.png" style="float:left;width:24px;height:24px">'+act[0]+' voce «'+what+'»<img src="imgs/close.svg" class="imgbut" style="float:right;" onclick="closeinpup()"></div><iframe src="edinsth.php?w='+selid+'&i='+id+'&m='+mode+'" class="hiframe"></iframe>';
document.getElementById('popup').style.display='table';
}
}
//-->
</script>
@ -70,6 +221,7 @@ function ulsh(el,sh) {
<div id="rightdiv">
<a href="logout.php" class="rlinks"><img src="imgs/esci.svg" title="Esci"></a>
</div>
</div>
</nav>
<div id="popup">
@ -83,69 +235,201 @@ function ulsh(el,sh) {
<!-- <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 class="insthead"><?php echo($inst['URI']); ?></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>
<tr><td><label for="Blacklisted">Blacklistata:</label></td><td>&nbsp;<input type="checkbox" name="Blacklisted" id="Blacklisted"<?php check($inst,'Blacklisted'); ?>></td></tr>
<tr><td><label for="New">Nuova:</label></td><td>&nbsp;<input type="checkbox" name="New" id="New"<?php check($inst,'New'); ?>></td></tr>
<tr><td><label for="Chosen">Scelta:</label></td><td>&nbsp;<input type="checkbox" name="Chosen" id="Chosen"<?php check($inst,'Chosen'); ?>></td></tr>
<tr><td><label for="Visible">Visibile:</label></td><td>&nbsp;<input type="checkbox" name="Visible" id="Visible"<?php check($inst,'Visible'); ?>></td></tr>
</table>
<div class="ruler"></div>
<div class="tit"><label for="OurDesc">Descrizione nostra</label></div>
<textarea name="OurDesc" id="OurDesc" rows="10" class="tarea"></textarea>
<textarea name="OurDesc" id="OurDesc" rows="10" class="tarea"><?php echo(hspech($inst['OurDesc'])); ?></textarea>
<div class="ruler"></div>
<div class="tit"><label for="LocalityID">Località</label></div>
<input type="text" placeholder="Cerca ..." class="search">
<select id="LocalityID" size="10" class="mselect">
<option value="1">Giamaica</option>
<option value="2">Angariate</option>
</select>
<div class="ruler"></div>
<div class="tit"><label for="Languages">Lingue</label></div>
<input type="text" placeholder="Cerca ..." class="search">
<table class="picktab"><tr>
<td style="width:98%;"><input type="text" placeholder="Cerca ..." class="search" id="locsearch" onkeyup="filtsel(locselarr, this.value, 'LocalityID', 'locselre', 'locsearch', 'white', '#ff8080')"></td>
<td style="width:1%;padding-left:3px;padding-right:3px;"><label for="locselre">Regex:</label></td>
<td style="width:1%"><input type="checkbox" id="locselre" style="float:right;" onchange="filtsel(locselarr, document.getElementById('locsearch').value, 'LocalityID', 'locselre', 'locsearch', 'white', '#ff8080')"></td>
</tr></table>
<table class="picktab">
<tr>
<td style="width:99%;">
<select id="DispLangs" multiple size="10" class="mselect">
<option value="1">Inglese</option>
<option value="2">Esperanto</option>
<select id="LocalityID" size="10" class="mselect">
<?php
$res=mysqli_query($link,'SELECT *, Localities.ID AS LocID FROM Localities LEFT JOIN States ON States.ID=Localities.StateID ORDER BY States.State ASC, Localities.Locality ASC') or muoribene(mysqli_error($link).'<br>Puoi <a href="instances.php">tornare allelenco delle istanze</a>.',true);
while ($row=mysqli_fetch_assoc($res)) {
($row['LocID']==$inst['LocalityID']) ? $selected=' selected' : $selected='';
echo('<option value="'.$row['LocID'].'"'.$selected.'>'.hspech($row['Locality']).' ('.hspech($row['State']).')</option>'.N);
}
?>
</select>
<img src="imgs/fresu.svg" style="float:left;"><img src="imgs/fregiu.svg" style="float:right;">
</td>
<td style="width:99%;">
<div class="butdiv"><img src="imgs/edit.svg" class="imgbut" title="Modifica la voce selezionata" onclick="edit('LocalityID','Località','edit')"></div>
<div class="butdiv"><img src="imgs/plus.svg" class="imgbut" title="Aggiungi una voce" onclick="edit('LocalityID','Località','add')"></div>
<div class="butdiv"><img src="imgs/minus.svg" class="imgbut" title="Elimina la voce selezionata" onclick="edit('LocalityID','Località','remove')"></div>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
selordalf('LocalityID');
var locselarr=getselarr('LocalityID');
//-->
</script>
<?php
function multi($o) {
global $link;
echo('<div class="ruler"></div>
<div class="tit"><label for="'.$o['dispselid'].'">'.$o['title'].'</label></div>
<table class="picktab"><tr>
<td style="width:98%"><input type="text" placeholder="Cerca ..." class="search" title="'.$o['searchtit'].'" id="'.$o['searchid'].'" onkeyup="filtsel('.$o['disparr'].', this.value, \''.$o['dispselid'].'\', \''.$o['regexcbid'].'\', \''.$o['searchid'].'\', \'white\', \'#ff8080\')"></td>
<td style="width:1%;padding-left:3px;padding-right:3px;"><label for="'.$o['regexcbid'].'" title="Usa espressioni regolari">Regex:</label></td>
<td style="width:1%"><input type="checkbox" id="'.$o['regexcbid'].'" style="float:right;" title="Usa espressioni regolari" onchange="filtsel('.$o['disparr'].', document.getElementById(\''.$o['searchid'].'\').value, \''.$o['dispselid'].'\', \''.$o['regexcbid'].'\', \''.$o['searchid'].'\', \'white\', \'#ff8080\')"></td>
</tr></table>
<table class="picktab">
<tr>
<td style="width:99%;">
<select id="'.$o['dispselid'].'" multiple size="8" class="mselect">'.N);
$res=mysqli_query($link,$o['dispque'])
or muoribene(mysqli_error($link).'<br>Puoi <a href="instances.php">tornare allelenco delle istanze</a>.',true);
while ($row=mysqli_fetch_assoc($res)) {
echo('<option value="'.$row[$o['valcol']].'">'.hspech($row[$o['txtcol']]).'</option>'.N);
}
echo('</select>
<script type="text/javascript">
<!--
selordalf(\''.$o['dispselid'].'\');
var '.$o['disparr'].'=getselarr(\''.$o['dispselid'].'\');
//-->
</script>
</td>
<td style="width:1%;">
<div class="butdiv"><img src="imgs/fresu.svg"></div>
<div class="butdiv"><img src="imgs/plus.svg"></div>
<div class="butdiv"><img src="imgs/minus.svg"></div>
<div class="butdiv"><img src="imgs/edit.svg" class="imgbut" title="Modifica la voce selezionata" onclick="edit(\''.$o['dispselid'].'\',\''.$o['title'].'\')"></div>
<div class="butdiv"><img src="imgs/plus.svg" class="imgbut" title="Aggiungi una voce" onclick="edit(\''.$o['dispselid'].'\',\''.$o['title'].'\'),m=\'add\'"></div>
<div class="butdiv"><img src="imgs/minus.svg" class="imgbut" title="Elimina la voce selezionata" onclick="edit(\''.$o['dispselid'].'\',\''.$o['title'].'\',m=\'remove\')"></div>
</td>
</tr>
<tr>
<td style="width:99%;">
<select id="ChosenLangs" multiple size="10" class="mselect">
<option value="3">Italiano</option>
<option value="4">Lappone</option>
</select>
<div class="move">'.$o['dida'].'
<img src="imgs/fregiu.svg" class="imgbut" style="float:left;" title="Sposta sotto le voci selezionate sopra" onclick="'.$o['disparr'].'=seladd(\''.$o['dispselid'].'\', \''.$o['chosenselid'].'\', '.$o['disparr'].')">
<img src="imgs/fresu.svg" class="imgbut" style="float:right;" title="Sposta sopra le voci selezionate sotto" onclick="'.$o['disparr'].'=selrem(\''.$o['chosenselid'].'\', \''.$o['dispselid'].'\', '.$o['disparr'].'); filtsel('.$o['disparr'].', document.getElementById(\''.$o['searchid'].'\').value, \''.$o['dispselid'].'\', \''.$o['regexcbid'].'\', \''.$o['searchid'].'\', \'white\', \'#ff8080\')">
</div>
</td>
<td style="width:1%;">
<div class="butdiv"><img src="imgs/fresucim.svg" title="Sposta in cima"></div>
<div class="butdiv"><img src="imgs/fresu.svg" title="Sposta su"></div>
<div class="butdiv"><img src="imgs/fregiu.svg" title="Sposta giù"></div>
<div class="butdiv"><img src="imgs/fregiufon.svg" title="Sposta in fondo"></div>
</td>
</tr>
</table>
<tr>
<td style="width:99%;">
<select id="'.$o['chosenselid'].'" multiple size="12" class="mselect">'.N);
$res=mysqli_query($link,$o['chosenque'])
or muoribene(mysqli_error($link).'<br>Puoi <a href="instances.php">tornare allelenco delle istanze</a>.',true);
while ($row=mysqli_fetch_assoc($res)) {
echo('<option value="'.$row[$o['chosenvalcol']].'">'.hspech($row[$o['txtcol']]).'</option>'.N);
}
echo('</select>
</td>
<td style="width:1%;">
<div class="butdiv"><img src="imgs/fresucim.svg" class="imgbut" title="Sposta in cima" onclick="seltop(\''.$o['chosenselid'].'\')"></div>
<div class="butdiv"><img src="imgs/fresu.svg" class="imgbut" title="Sposta su" onclick="selup(\''.$o['chosenselid'].'\')"></div>
<div class="butdiv"><img src="imgs/fregiu.svg" class="imgbut" title="Sposta giù" onclick="seldown(\''.$o['chosenselid'].'\')"></div>
<div class="butdiv"><img src="imgs/fregiufon.svg" class="imgbut" title="Sposta in fondo" onclick="selbot(\''.$o['chosenselid'].'\')"></div>
<div class="butdiv"><img src="imgs/alph.svg" class="imgbut" title="Ordina alfabeticamente" onclick="selordalf(\''.$o['chosenselid'].'\')"></div>
<div class="butdiv"><img src="imgs/invert.svg" class="imgbut" title="Inverti ordine" onclick="selordinv(\''.$o['chosenselid'].'\')"></div>
</td>
</tr>
</table>'.N);
}
/*multi(array(
'dispselid'=>'DispLangs',
'title'=>'Lingue',
'searchid'=>'langsearch',
'searchtit'=>'Cerca tra le lingue disponibili',
'disparr'=>'langselarr',
'regexcbid'=>'langselre',
'dispque'=>'SELECT * FROM Languages WHERE ID NOT IN (SELECT OurLangID FROM InstOurLangs WHERE InstID='.$inst['ID'].') ORDER BY NameIT ASC',
'valcol'=>'ID',
'txtcol'=>'NameIT',
'dida'=>'Sopra: lingue disponibili; sotto: lingue scelte',
'chosenselid'=>'ChosenLangs',
'chosenque'=>'SELECT * FROM InstOurLangs LEFT JOIN Languages ON Languages.ID=OurLangID WHERE InstID='.$inst['ID'].' ORDER BY Pos ASC',
'chosenvalcol'=>'OurLangID'));*/
multi(array(
'dispselid'=>'DispFinModes',
'title'=>'Modalità di finanziamento',
'searchid'=>'finsearch',
'searchtit'=>'Cerca tra le modalità di finanziamento disponibili',
'disparr'=>'finselarr',
'regexcbid'=>'finselre',
'dispque'=>'SELECT * FROM Financing WHERE ID NOT IN (SELECT FinID FROM InstFinancing WHERE InstID='.$inst['ID'].') ORDER BY Type ASC',
'valcol'=>'ID',
'txtcol'=>'Type',
'dida'=>'Sopra: mod. di fin. disponibili; sotto: mod. di fin. scelte',
'chosenselid'=>'ChosenFinModes',
'chosenque'=>'SELECT * FROM InstFinancing LEFT JOIN Financing ON Financing.ID=FinID WHERE InstID='.$inst['ID'].' ORDER BY Pos ASC',
'chosenvalcol'=>'FinID'));
multi(array(
'dispselid'=>'DispPolicies',
'title'=>'Restrizioni sui contenuti',
'searchid'=>'polsearch',
'searchtit'=>'Cerca tra le restrizioni sui contenuti disponibili',
'disparr'=>'polselarr',
'regexcbid'=>'polselre',
'dispque'=>'SELECT * FROM Policies WHERE ID NOT IN (SELECT PolID FROM InstPolicies WHERE InstID='.$inst['ID'].') ORDER BY Name ASC',
'valcol'=>'ID',
'txtcol'=>'Name',
'dida'=>'Sopra: rest. sui cont. disponibili; sotto: rest. sui cont. scelte',
'chosenselid'=>'ChosenPolicies',
'chosenque'=>'SELECT * FROM InstPolicies LEFT JOIN Policies ON Policies.ID=PolID WHERE InstID='.$inst['ID'].' ORDER BY Pos ASC',
'chosenvalcol'=>'PolID'));
multi(array(
'dispselid'=>'DispTags',
'title'=>'Tags',
'searchid'=>'tagsearch',
'searchtit'=>'Cerca tra le tags disponibili',
'disparr'=>'tagselarr',
'regexcbid'=>'tagselre',
'dispque'=>'SELECT * FROM Tags WHERE ID NOT IN (SELECT TagID FROM InstTags WHERE InstID='.$inst['ID'].') ORDER BY Name ASC',
'valcol'=>'ID',
'txtcol'=>'Name',
'dida'=>'Sopra: tags disponibili; sotto: tags scelte',
'chosenselid'=>'ChosenTags',
'chosenque'=>'SELECT * FROM InstTags LEFT JOIN Tags ON Tags.ID=TagID WHERE InstID='.$inst['ID'].' ORDER BY Pos ASC',
'chosenvalcol'=>'TagID'));
?>
</td></tr>
</table>
</div>
</div>
<div id="debug">
<?php echo($dbg); ?>
</div>
</body>
</html>
<?php
mysqli_close($link);
?>

98
web/admin/edinsth.php Normal file
View file

@ -0,0 +1,98 @@
<?php
require('include/glob.php');
require('include/muoribene.php');
require('include/sessionstart.php');
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($_GET,1).'</pre>';
$modes=array('edit','add','remove');
if (array_key_exists('w',$_GET) && array_key_exists('i',$_GET) && preg_match('/^[0-9]+$/',$_GET['i'])===1 && array_key_exists('m',$_GET) && in_array($_GET['m'],$modes)) {
$id=$_GET['i']+0;
$fout='<form action="edinsth.php" method="post" id="f" onsubmit="ckf();">'.N;
switch ($_GET['w']) {
case 'LocalityID':
$res=mysqli_query($link,'SELECT * FROM Localities WHERE ID='.$id)
or muoribene(mysqli_error($link),true);
if (mysqli_num_rows($res)==1) {
$row=mysqli_fetch_assoc($res);
$stateid=$row['StateID'];
$locname=$row['Locality'];
$fout.='<div class="hiflab"><label for="StateID">State</label></div>'.N;
$fout.='<select id="StateID" name="StateID" class="hifinp">'.N;
$res=mysqli_query($link,'SELECT * FROM States ORDER BY State ASC')
or muoribene(mysqli_error($link),true);
$stateid=0;
while ($row=mysqli_fetch_assoc($res)) {
($row['ID']!=$stateid) ? $selected='' : $selected=' selected';
$fout.='<option value="'.$row['ID'].'"'.$selected.'>'.hspech($row['State']).'</option>'.N;
}
$fout.='</select>'.N;
$fout.='<div class="hiflab"><label for="Locality:'.$id.'">Locality (local name)</label></div>'.N;
$fout.='<input type="text" class="hifinp" name="Locality:'.$id.'" id="Locality:'.$id.'" maxlength="256" value="'.hspech($locname).'">'.N;
$fout.='<script language="JavaScript">'.N;
$fout.='<!--'.N;
$fout.='document.getElementById(\'Locality:'.$id.'\').focus();'.N;
$fout.='//-->'.N;
$fout.='</script>'.N;
} else {
$fout.='<p>There is no Locality with ID='.$id.'</p>'.N;
}
break;
case 'DispFinModes':
break;
case 'DispPolicies':
break;
case 'DispTags':
break;
default:
muoribene('Malformed input.',true);
break;
}
$fout.='</form>'.N;
} else {
muoribene('Malformed input.',true);
}
mysqli_close($link);
?>
<!DOCTYPE HTML>
<html lang="it">
<head>
<title>Mastodon Startpage Admin - Little edits helper</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">
<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">
<!--
//-->
</script>
</head>
<body style="font-size:10pt;background-color:lightgrey;">
<div id="fullscreen">
<div id="middlerow">
<?php echo($fout); ?>
</div>
</div>
<?php echo($dbg); ?>
</body>
</html>

124
web/admin/imgs/alph.svg Normal file
View file

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="22"
height="22"
viewBox="0 0 5.8208332 5.8208335"
version="1.1"
id="svg8"
inkscape:version="0.92.4 5da689c313, 2019-01-14"
sodipodi:docname="alph.svg">
<defs
id="defs2">
<marker
style="overflow:visible"
id="DistanceEnd"
refX="0.0"
refY="0.0"
orient="auto"
inkscape:stockid="DistanceEnd"
inkscape:isstock="true">
<g
id="g2301"
style="stroke:#000000;stroke-opacity:1;fill:#ffffff;fill-opacity:1">
<path
style="fill:#ffffff;stroke:#000000;stroke-width:1.15;stroke-linecap:square;stroke-opacity:1;fill-opacity:1"
d="M 0,0 L -2,0"
id="path2316" />
<path
style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-opacity:1;fill-opacity:1"
d="M 0,0 L -13,4 L -9,0 -13,-4 L 0,0 z "
id="path2312" />
<path
style="fill:#ffffff;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-opacity:1;fill-opacity:1"
d="M 0,-4 L 0,40"
id="path2314" />
</g>
</marker>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
inkscape:cx="6.44396"
inkscape:cy="16.87676"
inkscape:document-units="px"
inkscape:current-layer="text4555"
showgrid="false"
units="px"
inkscape:snap-bbox="true"
inkscape:snap-page="true"
inkscape:bbox-nodes="true"
inkscape:window-width="3840"
inkscape:window-height="2037"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
showguides="true"
inkscape:guide-bbox="true" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Livello 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-291.17916)">
<rect
style="opacity:1;vector-effect:none;fill:#3088d4;fill-opacity:1;stroke:none;stroke-width:0.37526914;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="rect861"
width="5.8208332"
height="5.8208265"
x="-1.110223e-16"
y="291.17917"
ry="0.78214943" />
<g
aria-label="E"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11.90897846px;line-height:1.25;font-family:'Noto Sans';-inkscape-font-specification:'Noto Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.29772446"
id="text4555">
<g
aria-label="Ab"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.58333302px;line-height:1.25;font-family:'Noto Sans';-inkscape-font-specification:'Noto Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.07877292"
id="text1469"
transform="translate(-4.85e-7,-1.1785581)">
<path
d="M 2.4757971,295.5448 2.2740082,294.88511 H 1.2650638 L 1.0632749,295.5448 H 0.43074432 l 0.97789998,-2.78236 h 0.7179028 l 0.9817806,2.78236 z M 2.1343082,294.39227 1.9325193,293.7481 q -0.019403,-0.066 -0.050447,-0.16686 -0.031044,-0.1009 -0.062089,-0.20567 -0.031044,-0.10478 -0.050447,-0.18239 -0.019403,0.0776 -0.054328,0.19403 -0.031044,0.11254 -0.062089,0.21731 -0.027164,0.1009 -0.042686,0.14358 l -0.1979083,0.64417 z"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.88055563px;font-family:'Noto Sans';-inkscape-font-specification:'Noto Sans Bold';fill:#ffffff;stroke-width:0.07877292"
id="path1476"
inkscape:connector-curvature="0" />
<path
d="m 3.9892084,292.59558 v 0.68686 q 0,0.12029 -0.00776,0.23671 -0.00776,0.11642 -0.015522,0.18239 h 0.023283 q 0.085372,-0.13194 0.2289528,-0.2212 0.1435806,-0.0931 0.3725333,-0.0931 0.3570112,0 0.5782028,0.2794 0.2211917,0.27552 0.2211917,0.81492 0,0.54328 -0.2250722,0.82268 -0.2250723,0.2794 -0.5898445,0.2794 -0.2328333,0 -0.3686528,-0.0815 -0.1319389,-0.0854 -0.2173111,-0.19014 h -0.038807 l -0.097014,0.2328 H 3.4110056 v -2.94922 z m 0.4152195,1.25342 q -0.2250723,0 -0.3182056,0.1397 -0.089253,0.1397 -0.097014,0.42686 v 0.0621 q 0,0.30656 0.089253,0.47342 0.093133,0.16299 0.3337278,0.16299 0.1785055,0 0.2832805,-0.16299 0.104775,-0.16686 0.104775,-0.4773 0,-0.31045 -0.1086555,-0.46567 -0.104775,-0.1591 -0.2871611,-0.1591 z"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:3.88055563px;font-family:'Noto Sans';-inkscape-font-specification:'Noto Sans Bold';fill:#ffffff;stroke-width:0.07877292"
id="path1478"
inkscape:connector-curvature="0" />
</g>
<path
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.23701932;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="m 2.9026734,296.81168 c -0.051063,-0.002 -0.097206,-0.0195 -0.1224421,-0.0473 l -1.87802109,-2.0275 c -0.0584756,-0.0623 0.0135137,-0.1407 0.12934039,-0.14082 h 3.7577666 c 0.1157814,1.3e-4 0.1877481,0.0784 0.1293403,0.14078 l -1.8780211,2.0275 c -0.027985,0.0307 -0.08135,0.049 -0.137963,0.0473 z"
id="path4529"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccccc" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.5 KiB

112
web/admin/imgs/close.svg Normal file
View file

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="24"
height="24"
viewBox="0 0 6.3499999 6.3500002"
version="1.1"
id="svg8"
inkscape:version="0.92.4 5da689c313, 2019-01-14"
sodipodi:docname="close.svg">
<defs
id="defs2">
<marker
style="overflow:visible"
id="DistanceEnd"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="DistanceEnd"
inkscape:isstock="true">
<g
id="g2301"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-opacity:1">
<path
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.14999998;stroke-linecap:square;stroke-opacity:1"
d="M 0,0 H -2"
id="path2316"
inkscape:connector-curvature="0" />
<path
style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-opacity:1"
d="m 0,0 -13,4 4,-4 -4,-4 z"
id="path2312"
inkscape:connector-curvature="0" />
<path
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-opacity:1"
d="M 0,-4 V 40"
id="path2314"
inkscape:connector-curvature="0" />
</g>
</marker>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#bebebe"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
inkscape:zoom="22.627417"
inkscape:cx="16.477924"
inkscape:cy="4.8747564"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:snap-bbox="true"
inkscape:snap-page="true"
inkscape:bbox-nodes="true"
inkscape:window-width="3840"
inkscape:window-height="2037"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
showguides="true"
inkscape:guide-bbox="true" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Livello 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-290.64999)">
<g
aria-label="E"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11.90897846px;line-height:1.25;font-family:'Noto Sans';-inkscape-font-specification:'Noto Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.29772446"
id="text4555" />
<circle
style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.427827;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="path868"
cx="3.175"
cy="293.82498"
r="2.3530483" />
<path
style="fill:none;stroke:#ffffff;stroke-width:0.427827;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 2.1355143,292.7855 2.0789716,2.07897"
id="path870"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#ffffff;stroke-width:0.427827;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 2.135513,294.86447 4.214487,292.7855"
id="path870-6"
inkscape:connector-curvature="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.1 KiB

107
web/admin/imgs/edit.svg Normal file
View file

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="22"
height="22"
viewBox="0 0 5.8208332 5.8208335"
version="1.1"
id="svg8"
inkscape:version="0.92.4 5da689c313, 2019-01-14"
sodipodi:docname="edit.svg">
<defs
id="defs2">
<marker
style="overflow:visible"
id="DistanceEnd"
refX="0.0"
refY="0.0"
orient="auto"
inkscape:stockid="DistanceEnd"
inkscape:isstock="true">
<g
id="g2301"
style="stroke:#000000;stroke-opacity:1;fill:#ffffff;fill-opacity:1">
<path
style="fill:#ffffff;stroke:#000000;stroke-width:1.15;stroke-linecap:square;stroke-opacity:1;fill-opacity:1"
d="M 0,0 L -2,0"
id="path2316" />
<path
style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-opacity:1;fill-opacity:1"
d="M 0,0 L -13,4 L -9,0 -13,-4 L 0,0 z "
id="path2312" />
<path
style="fill:#ffffff;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-opacity:1;fill-opacity:1"
d="M 0,-4 L 0,40"
id="path2314" />
</g>
</marker>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="45.254834"
inkscape:cx="5.3272069"
inkscape:cy="11.603776"
inkscape:document-units="px"
inkscape:current-layer="text4555"
showgrid="false"
units="px"
inkscape:snap-bbox="true"
inkscape:snap-page="true"
inkscape:bbox-nodes="true"
inkscape:window-width="3840"
inkscape:window-height="2037"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
showguides="true"
inkscape:guide-bbox="true" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Livello 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-291.17916)">
<rect
style="opacity:1;vector-effect:none;fill:#3088d4;fill-opacity:1;stroke:none;stroke-width:0.37526914;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="rect861"
width="5.8208332"
height="5.8208265"
x="-1.110223e-16"
y="291.17917"
ry="0.78214943" />
<g
aria-label="E"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11.90897846px;line-height:1.25;font-family:'Noto Sans';-inkscape-font-specification:'Noto Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.29772446"
id="text4555">
<path
d="m 2.2139106,294.3767 h 1.9843313 v -0.71072 H 2.2139106 v -0.93815 H 4.3574433 V 292.0171 H 1.3610462 v 4.14493 H 4.459787 v -0.71072 H 2.2139106 Z"
style="font-style:normal;font-variant:normal;font-weight:600;font-stretch:normal;font-size:7.14538765px;font-family:FreeSans;-inkscape-font-specification:'FreeSans Semi-Bold';fill:#ffffff;stroke-width:0.23690677"
id="path4579"
inkscape:connector-curvature="0" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4 KiB

124
web/admin/imgs/invert.svg Normal file
View file

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="22"
height="22"
viewBox="0 0 5.8208332 5.8208335"
version="1.1"
id="svg8"
inkscape:version="0.92.4 5da689c313, 2019-01-14"
sodipodi:docname="invert.svg">
<defs
id="defs2">
<marker
style="overflow:visible"
id="DistanceEnd"
refX="0.0"
refY="0.0"
orient="auto"
inkscape:stockid="DistanceEnd"
inkscape:isstock="true">
<g
id="g2301"
style="stroke:#000000;stroke-opacity:1;fill:#ffffff;fill-opacity:1">
<path
style="fill:#ffffff;stroke:#000000;stroke-width:1.15;stroke-linecap:square;stroke-opacity:1;fill-opacity:1"
d="M 0,0 L -2,0"
id="path2316" />
<path
style="fill:#ffffff;fill-rule:evenodd;stroke:#000000;stroke-opacity:1;fill-opacity:1"
d="M 0,0 L -13,4 L -9,0 -13,-4 L 0,0 z "
id="path2312" />
<path
style="fill:#ffffff;stroke:#000000;stroke-width:1;stroke-linecap:square;stroke-opacity:1;fill-opacity:1"
d="M 0,-4 L 0,40"
id="path2314" />
</g>
</marker>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
inkscape:cx="6.44396"
inkscape:cy="16.87676"
inkscape:document-units="px"
inkscape:current-layer="text4555"
showgrid="false"
units="px"
inkscape:snap-bbox="true"
inkscape:snap-page="true"
inkscape:bbox-nodes="true"
inkscape:window-width="3840"
inkscape:window-height="2037"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
showguides="true"
inkscape:guide-bbox="true" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Livello 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-291.17916)">
<rect
style="opacity:1;vector-effect:none;fill:#3088d4;fill-opacity:1;stroke:none;stroke-width:0.37526914;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="rect861"
width="5.8208332"
height="5.8208265"
x="-1.110223e-16"
y="291.17917"
ry="0.78214943" />
<g
aria-label="E"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11.90897846px;line-height:1.25;font-family:'Noto Sans';-inkscape-font-specification:'Noto Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.29772446"
id="text4555">
<rect
rx="0.4608396"
style="opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.22136872;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal"
id="rect4521"
width="1.5827367"
height="2.9905612"
x="2.0668476"
y="-295.55185"
ry="0.46083957"
transform="scale(1,-1)" />
<path
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.23701932;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="m 2.9026734,296.76832 c -0.051063,-0.002 -0.097206,-0.0195 -0.1224421,-0.0473 l -1.87802103,-2.0275 c -0.0584756,-0.0623 0.0135137,-0.1407 0.12934033,-0.14082 h 3.7577666 c 0.1157814,1.3e-4 0.1877481,0.0784 0.1293403,0.14078 l -1.8780211,2.0275 c -0.027985,0.0307 -0.08135,0.049 -0.137963,0.0473 z"
id="path4529"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccccc" />
<path
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;-inkscape-font-specification:'Noto Sans, Normal';font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.23701932;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="m 2.9026734,291.41084 c -0.051063,0.002 -0.097206,0.0195 -0.1224421,0.0473 l -1.87802103,2.0275 c -0.0584756,0.0623 0.0135137,0.1407 0.12934033,0.14082 h 3.7577666 c 0.1157814,-1.3e-4 0.1877481,-0.0784 0.1293403,-0.14078 l -1.8780212,-2.0275 c -0.027985,-0.0307 -0.08135,-0.049 -0.1379629,-0.0473 z"
id="path4529-9"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccccc" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.3 KiB

BIN
web/admin/imgs/p.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

View file

@ -114,18 +114,12 @@ $cols=array(
'Instances.OurDesc'=>array('field'=>'Instances.OurDesc','name'=>'[Descrizione nostra]','type'=>'text'),
//--------------------------------
//+++
'Instances.LocalityID'=>array('field'=>'Instances.LocalityID','name'=>'[Località] ⮞','type'=>'join','join'=>array(),'ord'=>false),
'Localities.Locality'=>array('field'=>'Localities.Locality','name'=>'[Località]','type'=>'joini','join'=>array('Localities ON Localities.ID=Instances.LocalityID'),'subtype'=>'text'),
'Provinces.ID'=>array('field'=>'Provinces.ID','name'=>'[Provincia] ⮞','type'=>'join','join'=>array('Localities ON Localities.ID=Instances.LocalityID','Provinces ON Provinces.ID=Localities.ProvinceID'),'ord'=>false),
'Provinces.Province'=>array('field'=>'Provinces.Province','name'=>'[Provincia]','type'=>'joini','join'=>array('Localities ON Localities.ID=Instances.LocalityID','Provinces ON Provinces.ID=Localities.ProvinceID'),'subtype'=>'text'),
'Regions.ID'=>array('field'=>'Regions.ID','name'=>'[Regione] ⮞','type'=>'join','join'=>array('Localities ON Localities.ID=Instances.LocalityID','Provinces ON Provinces.ID=Localities.ProvinceID','Regions ON Regions.ID=Provinces.RegionID'),'ord'=>false),
'Regions.Region'=>array('field'=>'Regions.Region','name'=>'[Regione]','type'=>'joini','join'=>array('Localities ON Localities.ID=Instances.LocalityID','Provinces ON Provinces.ID=Localities.ProvinceID','Regions ON Regions.ID=Provinces.RegionID'),'subtype'=>'text'),
'States.ID'=>array('field'=>'States.ID','name'=>'[Stato] ⮞','type'=>'join','join'=>array('Localities ON Localities.ID=Instances.LocalityID','Provinces ON Provinces.ID=Localities.ProvinceID','Regions ON Regions.ID=Provinces.RegionID','States ON States.ID=Regions.StateID'),'ord'=>false),
'States.State'=>array('field'=>'States.State','name'=>'[Stato]','type'=>'joini','join'=>array('Localities ON Localities.ID=Instances.LocalityID','Provinces ON Provinces.ID=Localities.ProvinceID','Regions ON Regions.ID=Provinces.RegionID','States ON States.ID=Regions.StateID'),'subtype'=>'text'),
'States.ID'=>array('field'=>'States.ID','name'=>'[Stato] ⮞','type'=>'join','join'=>array('Localities ON Localities.ID=Instances.LocalityID','States ON States.ID=Localities.StateID'),'ord'=>false),
'States.State'=>array('field'=>'States.State','name'=>'[Stato]','type'=>'joini','join'=>array('Localities ON Localities.ID=Instances.LocalityID','States ON States.ID=Localities.StateID'),'subtype'=>'text'),
//--------------------------------
@ -522,10 +516,10 @@ if ($cinstsp<1) {
$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'])
$sres=mysqli_query($link,'SELECT * FROM Localities LEFT JOIN States ON States.ID=Localities.StateID WHERE Localities.ID='.$row['LocalityID'])
or muoribene(mysqli_error($link),true);
$srow=mysqli_fetch_assoc($sres);
$out.=hspech($srow['Locality']).' ('.$srow['Province'].', '.$srow['Region'].', '.$srow['State'].')</div>'.N;
$out.=hspech($srow['Locality']).' ('.hspech($srow['State']).')</div>'.N;
} else {
$out.='<span class="nully">Non definita</span></div>'.N;
}
@ -668,9 +662,8 @@ 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--)
sel.remove(i);
var sel=document.getElementById(el);
sel.length=0;
}
function inpdisif(index) {
console.log('inpdisif index: '+index);

View file

@ -8,13 +8,9 @@ require('include/sessionstart.php');
$cols=array(
'Instances.LocalityID'=>array('select'=>'SELECT Localities.ID AS Lid, CONCAT(Locality,\' (\',Province,\', \',Region,\', \',State,\') (\',COUNT(Localities.ID),\')\') AS Txt FROM Instances LEFT JOIN Localities ON Localities.ID=Instances.LocalityID 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 Instances.LocalityID IS NOT NULL GROUP BY Lid ORDER BY Localities.Locality ASC, Provinces.Province ASC, Regions.Region ASC, States.State ASC','optcol'=>'Lid','txtcol'=>'Txt'),
'Instances.LocalityID'=>array('select'=>'SELECT Localities.ID AS Lid, CONCAT(Locality,\' (\',State,\') (\',COUNT(Localities.ID),\')\') AS Txt FROM Instances LEFT JOIN Localities ON Localities.ID=Instances.LocalityID LEFT JOIN States ON States.ID=Localities.StateID WHERE Instances.LocalityID IS NOT NULL GROUP BY Lid ORDER BY States.State ASC, Localities.Locality ASC','optcol'=>'Lid','txtcol'=>'Txt'),
'Provinces.ID'=>array('select'=>"SELECT Provinces.ID AS Pid, CONCAT(Province,' (',Region,', ',State,') (',COUNT(Localities.ID),')') AS Txt FROM Instances LEFT JOIN Localities ON Localities.ID=Instances.LocalityID 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 Instances.LocalityID IS NOT NULL GROUP BY Pid ORDER BY Provinces.Province ASC, Regions.Region ASC, States.State ASC",'optcol'=>'Pid','txtcol'=>'Txt'),
'Regions.ID'=>array('select'=>"SELECT Regions.ID AS Rid, CONCAT(Region,' (',State,') (',COUNT(Regions.ID),')') AS Txt FROM Instances LEFT JOIN Localities ON Localities.ID=Instances.LocalityID 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 Instances.LocalityID IS NOT NULL GROUP BY Rid ORDER BY Regions.Region ASC, States.State ASC",'optcol'=>'Rid','txtcol'=>'Txt'),
'States.ID'=>array('select'=>"SELECT States.ID AS Sid, CONCAT(State,' (',COUNT(States.ID),')') AS Txt FROM Instances LEFT JOIN Localities ON Localities.ID=Instances.LocalityID 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 Instances.LocalityID IS NOT NULL GROUP BY Sid ORDER BY States.State ASC",'optcol'=>'Sid','txtcol'=>'Txt'),
'States.ID'=>array('select'=>"SELECT States.ID AS Sid, CONCAT(State,' (',COUNT(States.ID),')') AS Txt FROM Instances LEFT JOIN Localities ON Localities.ID=Instances.LocalityID LEFT JOIN States ON States.ID=Localities.StateID WHERE Instances.LocalityID IS NOT NULL GROUP BY Sid ORDER BY States.State ASC",'optcol'=>'Sid','txtcol'=>'Txt'),
'InstLangs.LangID'=>array('select'=>'SELECT Languages.ID AS Lid, CONCAT(Code, \' [\', NameIT, \'] (\', COUNT(Languages.ID), \')\') AS Txt FROM InstLangs LEFT JOIN Languages ON Languages.ID=LangID GROUP BY Languages.ID ORDER BY Code ASC','optcol'=>'Lid','txtcol'=>'Txt'),

View file

@ -540,12 +540,18 @@ input {
text-align: center;
border-radius: 3px;
margin-bottom: 6px;
height: 24px;
line-height: 24px;
}
.edtab .butdiv {
width: 22px;
margin-bottom: 3px;
margin-left: 3px;
}
.edtab .move {
line-height: 22px;
font-size: 8pt;
}
.cbtab {
border-spacing: 0;
@ -562,6 +568,49 @@ input {
.picktab td {
border-radius: 0;
padding: 0;
vertical-align: middle;
text-align: center;
}
.imgbut:hover {
cursor: pointer;
}
.hiframe {
border-radius: 6px;
border: 1px solid darkgrey;
width: 400px;
height: 200px;
}
.hiftit {
background-color: #6f916f;
color: white;
font-size: 11pt;
font-weight: bold;
border-radius: 6px;
width: 400px;
height: 24px;
line-height: 24px;
vertical-align: middle;
margin-left: auto;
margin-right: auto;
margin-bottom: 6px;
}
.hifinp {
width: 320px;
font-size: 10pt;
margin-bottom: 3px;
}
.hiflab {
width: 320px;
font-weight: bold;
background-color: #6f916f;
color: white;
border-radius: 3px;
margin-left: auto;
margin-right: auto;
margin-bottom: 1px;
padding: 2px;
}
#pageselect {
@ -579,7 +628,7 @@ input {
height: 240px;
font-size: 8pt;
overflow: auto;
display: none;
/*display: none;*/
}
#intro {

File diff suppressed because one or more lines are too long

185
web/admin/tools/popudb.php Executable file
View file

@ -0,0 +1,185 @@
#!/bin/php
<?php
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define('N',"\n");
use function mysqli_real_escape_string as myesc;
$inifp=__DIR__.'/../sec/mastostartadmin.ini';
$iniarr=@parse_ini_file($inifp)
or mexit('Impossibile aprire il file di configurazione «'.$inifp.'»'.N,1);
$link=@mysqli_connect($iniarr['db_host'],$iniarr['db_admin_name'],$iniarr['db_admin_password'],$iniarr['db_name'],$iniarr['db_port'],$iniarr['db_socket'])
or mexit('Impossibile connettersi al server MySQL: '.mysqli_connect_error().N,1);
mysqli_set_charset($link,'utf8mb4')
or mexit(mysqli_error($link).N,1);
$tables=array();
$res=mysqli_query($link,'SHOW TABLES')
or mexit(mysqli_error($link).N,1);
while ($row=mysqli_fetch_row($res)) {
$resb=mysqli_query($link,'SHOW COLUMNS FROM '.$row[0])
or mexit(mysqli_error($link).N,1);
$fields=array();
// lo uso solo per alcuni tipi, quindi non sto a cercare completezza
while ($rowb=mysqli_fetch_assoc($resb)) {
if (preg_match('/(\w+)\((.*)\)( unsigned)?/',$rowb['Type'],$buf)===1) {
switch ($buf[1]) {
case 'char':
case 'varchar':
$fields[$rowb['Field']]=$buf[2];
break;
case 'tinyint':
if (array_key_exists(3,$buf))
$fields[$rowb['Field']]=array('min'=>0,'max'=>255);
else
$fields[$rowb['Field']]=array('min'=>-128,'max'=>127);
break;
case 'smallint':
if (array_key_exists(3,$buf))
$fields[$rowb['Field']]=array('min'=>0,'max'=>65535);
else
$fields[$rowb['Field']]=array('min'=>-32768,'max'=>32767);
break;
case 'mediumint':
if (array_key_exists(3,$buf))
$fields[$rowb['Field']]=array('min'=>0,'max'=>16777215);
else
$fields[$rowb['Field']]=array('min'=>-8388608,'max'=>8388607);
break;
case 'int':
if (array_key_exists(3,$buf))
$fields[$rowb['Field']]=array('min'=>0,'max'=>4294967295);
else
$fields[$rowb['Field']]=array('min'=>-2147483648,'max'=>2147483647);
break;
// bigint non ci sta in php a meno di usare bcmath o gmp che non è detto siano abilitate sul server, in ogni caso poco importa perché valori bigint vengono usati solo internamente al db, non "vengono da fuori"
case 'bigint':
if (array_key_exists(3,$buf))
$fields[$rowb['Field']]=array('min'=>'0','max'=>'18446744073709551615');
else
$fields[$rowb['Field']]=array('min'=>'-9223372036854775808','max'=>'9223372036854775807');
break;
case 'decimal':
// questo è da testare contro un decimale vero
// fatto, il risultato è che in mysql devo usare decimal(14,4)
if (preg_match('/,/',$buf[2])===1) {
$lim=explode(',',$buf[2]);
} else {
$lim[0]=$buf[2];
$lim[1]=0;
}
$int=$lim[0]-$lim[1];
$sint='';
for ($i=0; $i<$int; $i++)
$sint.='9';
$sdec='';
for ($i=0; $i<$lim[1]; $i++)
$sdec.='9';
$max=$sint.'.'.$sdec;
if (array_key_exists(3,$buf))
$fields[$rowb['Field']]=array('min'=>0,'max'=>floatval($max));
else
$fields[$rowb['Field']]=array('min'=>floatval('-'.$max),'max'=>floatval($max));
break;
default:
$fields[$rowb['Field']]=$rowb['Type'];
break;
}
} elseif ($rowb['Type']=='text') {
$fields[$rowb['Field']]=65535;
} else {
$fields[$rowb['Field']]=$rowb['Type'];
}
}
$tables[$row[0]]=$fields;
}
$localesfp='locales.json';
$locales=@file_get_contents($localesfp);
if ($locales===false)
mexit('Non ho potuto aprire il file «'.$localesfp.'».'.N,1);
$locales=json_decode($locales,true);
print_r($locales);
foreach ($locales as $key=>$val) {
$code=myesc($link,$key);
$NameIt=myesc($link,my_ucfirst(locale_get_display_name($key,'it')));
$NameEn=myesc($link,my_ucfirst(locale_get_display_name($key,'en')));
$NameOrig=myesc($link,my_ucfirst(locale_get_display_name($key,$key)));
$que='INSERT INTO Languages (ID, Code, NameIT, NameEN, NameOrig) VALUES (NULL, \''.$code.'\', \''.$NameIt.'\', \''.$NameEn.'\', \''.$NameOrig.'\')';
echo($que.N);
mysqli_query($link,$que)
or mexit(mysqli_error($link).N,2);
}
mysqli_close($link);
exit(0);
function mexit($msg,$rv) {
global $link;
if ($link)
mysqli_close($link);
echo($msg);
exit($rv);
}
function truncs($str,$tab,$col,$ctx) {
global $tables, $tronconi, $iswin;
if ($iswin)
$tab=strtolower($tab);
$size=$tables[$tab][$col];
$len=mb_strlen($str,'UTF-8');
if ($len>$size) {
$tronconi[]=array('id'=>null,'tab'=>$tab,'col'=>$col,'ctx'=>$ctx,'len'=>$len,'size'=>$size);
$str=mb_substr($str,0,$size-1,'UTF-8').'…';
}
return($str);
}
function truncn($num,$tab,$col,$ctx) {
global $tables, $iswin;
if ($iswin)
$tab=strtolower($tab);
if (is_numeric($num)) {
if ($num>$tables[$tab][$col]['max']) {
notify($ctx.': ho dovuto troncare «'.$num.'» al valore massimo «'.$tables[$tab][$col]['max'].'» che può avere nella colonna «'.$col.'» della tabella «'.$tab.'»).',2);
$num=$tables[$tab][$col]['max'];
} elseif ($num<$tables[$tab][$col]['min']) {
notify($ctx.': ho dovuto troncare «'.$num.'» al valore minimo «'.$tables[$tab][$col]['min'].'» che può avere nella colonna «'.$col.'» della tabella «'.$tab.'»).',2);
$num=$tables[$tab][$col]['min'];
}
} else {
notify($ctx.': truncn(): mi aspettavo un numero, invece non lo era; ritorno «0».',3);
$num=0;
}
return($num);
}
function my_ucfirst($string, $e ='utf-8') {
if (function_exists('mb_strtoupper') && function_exists('mb_substr') && !empty($string)) {
$string = mb_strtolower($string, $e);
$upper = mb_strtoupper($string, $e);
preg_match('#(.)#us', $upper, $matches);
$string = $matches[1] . mb_substr($string, 1, mb_strlen($string, $e), $e);
} else {
$string = ucfirst($string);
}
return $string;
}
?>