From 48e64bb81e1d3a191faba4893afbdc51000a76b1 Mon Sep 17 00:00:00 2001 From: pezcurrel Date: Tue, 21 Apr 2020 12:35:53 +0200 Subject: [PATCH] ... --- web/admin/crawler/crawler.php | 7 +- web/admin/dafa.txt | 19 +++- web/admin/edinst.php | 40 ++++--- web/admin/edinsth.php | 209 ++++++++++++++++++++++------------ web/admin/edinstres.php | 11 +- web/admin/guestinsts.php | 2 +- web/admin/include/glob.php | 2 +- web/admin/include/menu.php | 80 ++----------- web/admin/instances.php | 2 +- web/admin/theme.css | 29 +++-- web/admin/tools/addlang.php | 104 +++++++++++++++++ web/admin/tools/popudb.php | 89 +-------------- 12 files changed, 330 insertions(+), 264 deletions(-) create mode 100755 web/admin/tools/addlang.php diff --git a/web/admin/crawler/crawler.php b/web/admin/crawler/crawler.php index 30b448d..d9f25de 100755 --- a/web/admin/crawler/crawler.php +++ b/web/admin/crawler/crawler.php @@ -557,12 +557,13 @@ function langs($instid, $uri, $auto) { or mexit(__LINE__.': '.mysqli_error($link).N,3); if (mysqli_num_rows($res)<1) { $code=myesc($link,truncs($lang,'Languages','Code','«'.$instrow['URI'].'»')); - $NameIt=myesc($link,truncs(mb_ucfirst(locale_get_display_name($lang,'it')),'Languages','NameIT','«'.$instrow['URI'].'»')); + $NameOrig=myesc($link,truncs(mb_ucfirst(locale_get_display_name($lang,$lang)),'Languages','NameOrig','«'.$instrow['URI'].'»')); + $NameCa=myesc($link,truncs(mb_ucfirst(locale_get_display_name($lang,'ca')),'Languages','NameCA','«'.$instrow['URI'].'»')); $NameEn=myesc($link,truncs(mb_ucfirst(locale_get_display_name($lang,'en')),'Languages','NameEN','«'.$instrow['URI'].'»')); $NameEs=myesc($link,truncs(mb_ucfirst(locale_get_display_name($lang,'es')),'Languages','NameES','«'.$instrow['URI'].'»')); $NameFr=myesc($link,truncs(mb_ucfirst(locale_get_display_name($lang,'fr')),'Languages','NameFR','«'.$instrow['URI'].'»')); - $NameOrig=myesc($link,truncs(mb_ucfirst(locale_get_display_name($lang,$lang)),'Languages','NameOrig','«'.$instrow['URI'].'»')); - $q = 'INSERT INTO Languages (ID, Code, NameIT, NameEN, NameES, NameFR, NameOrig) VALUES (NULL, \''.$code.'\', \''.$NameIt.'\', \''.$NameEn.'\', \''.$NameEs.'\', \''.$NameFr.'\', \''.$NameOrig.'\')'; + $NameIt=myesc($link,truncs(mb_ucfirst(locale_get_display_name($lang,'it')),'Languages','NameIT','«'.$instrow['URI'].'»')); + $q = 'INSERT INTO Languages (ID, Code, NameOrig, NameCA, NameEN, NameES, NameFR, NameIT) VALUES (NULL, \''.$code.'\', \''.$NameOrig.'\', \''.$NameCa.'\', \''.$NameEn.'\', \''.$NameEs.'\', \''.$NameFr.'\', \''.$NameIt.'\')'; mysqli_query($link, $q) or mexit(__LINE__.': '.mysqli_error($link).N,3); $langid=mysqli_insert_id($link); diff --git a/web/admin/dafa.txt b/web/admin/dafa.txt index ebe59e6..1974f8d 100644 --- a/web/admin/dafa.txt +++ b/web/admin/dafa.txt @@ -3,24 +3,31 @@ * fatto # in corso +* l'icona per l'uscita senza div o quel che è, come in instances.php * edinsth.php: su edit e add, nel js, selezionare solo il valore editato/aggiunto, perché nella finestrella elenco valori mostra il primo selezionato * edinstres.php deve mostrare scheda istanza completa * guestinsts.php, edinst.php e edinstres.php devono avere menu particolare per "guest" con la possibilità di andare alla vista delle istanze +* edinsth.php: per "guest" deve tenere conto dei limiti impostati con MaxLocalities ecc. +- edinst.php: un'icona per deselezionare Locality - nei vari helper, sarebbe meglio morisse in json, alla bisogna - sanificazione input: edinsth.php: su edit e add controllare sempre che il valore "nuovo" non ci sia già -- aggiungere colonna NameCA a Languages e Localities, e relativi pimpumpam nel codice -- troncare tabella languages e far rigirare tools/popudb.php per ricrearla: my_ucfirst metteva in minuscolo tutta la stringa, a parte il primo carattere maiuscolo +* aggiungere colonna "OSMID" a Localities, in modo che se aggiungiamo altre lingue in seguito sia più facile recuperarle per aggiornare la tabella +* aggiungere colonna NameCA a Languages e Localities, e relativi pimpumpam nel codice (greppare "NameES" e "\'es\'" dappertutto) +* troncare tabella languages e far rigirare tools/popudb.php per ricrearla: my_ucfirst metteva in minuscolo tutta la stringa, a parte il primo carattere maiuscolo +- aggiungere notifiche quando "guest" edita istanza, località, lingua, modalità di finanziamento, ecc. +* aggiungere colonna "timestamp" "LastGuestEdit" a Instances: null quando non è stata mai editata da "guest", altrimenti time() php # edinst.php: su languages se account "Level" è "guest", "lock this list" dev'essere checkato per default *se "guest" non ha ancora mai modificato i dati dell'istanza* -- index.php: lunghezza automatica di username +? index.php: lunghezza automatica di username * tutto: visualizzazione notifiche (campanellina e div a s/comparsa) - serve un "notifs.php" (è già linkato dalla lista notifiche accessibile dalla campanella) per la gestione accurata delle notifiche (possibilità di marcarle tutte o "precedenti a" come lette, possibilità di cancellarle tutte o "precedenti a") - rinominare tutto da "Mastodon Startpage Admin" a "MastoStartAdm" - crawler.php: ricorsivizzarlo? +- crawler.php: le notifiche, invece di edinst.php, devono linkare un viewinst.php che mostri l'istanza - crawler.php: deve controllare se nella tabella Instances OurAdmID è definito; se è definito e la mail del corrispettivo account "guest" è cambiata, deve aggiornare l'account "guest" corrispettivo in Admins con la mail e il nome utente attuali e creare nuova password; se i dati dell'istanza sono già stati editati, mandare mail di "aggiornamento"; se non lo sono, mandare invito - instances.php: tradurre tutto in inglese -- tutto: possibilità di *scegliere* la lingua da usare tra quelle supportate -- edinsth.php: finire Localities -- implementare la faccenda dell'invio di mail preformattate agli admin con invito a editare i propri dati (quindi implementare "livelli di admin" e relative restrizioni: admin invitat* può vedere solo la pagina relativa alla propria istanza, solo aggiungere valori - non in tutti i casi, editare ed eliminare solo valori che ha aggiunto e solo se non sono già stati linkati da altr*) +- instances.php: possibilità di *scegliere* la lingua da usare tra quelle supportate per il filtraggio su Localities e Languages +* edinsth.php: finire Localities +# implementare la faccenda dell'invio di mail preformattate agli admin con invito a editare i propri dati (quindi implementare "livelli di admin" e relative restrizioni: admin invitat* può vedere solo la pagina relativa alla propria istanza, solo aggiungere valori - non in tutti i casi, editare ed eliminare solo valori che ha aggiunto e solo se non sono già stati linkati da altr*) ? instances.php: bottoni per pagina precedente-successiva - instances.php: alerta su cambio pagina quando è stato modificato filtro/ordinamento - instances.php: possibilità di vedere solo le istanze che non rispondono da tot giorni (o forse farla a parte?) diff --git a/web/admin/edinst.php b/web/admin/edinst.php index c959689..c238341 100644 --- a/web/admin/edinst.php +++ b/web/admin/edinst.php @@ -7,6 +7,7 @@ require('include/myconn.php'); require('include/getadmacc.php'); require('include/menu.php'); $menu['menu']['selected']=true; +$menu['menu']['submenu']['instances']['selected']=true; buildmenu($menu); $dbg=''; @@ -259,6 +260,8 @@ function edit(selid,what,mode) { } } function ckf() { + // questo qua sotto resetta eventuale filtro su LocalityID in modo che se c'è valore selezionato ma non mostrato viene passato + filtsel(locselarr, '', 'LocalityID', 'locselre', 'locsearch', 'white', '#ff8080'); var selids=['ChosenLangs[]','ChosenFinModes[]','ChosenPolicies[]','ChosenTags[]'], len=selids.length, i, sel, ii; for (i=0; iEditing «»
'.N); ?> - +
@@ -318,21 +321,23 @@ if ($account['Level']!='guest')
'.N); ?> -
+
-
+
-
- +
'.N); + if ($account['Level']=='guest') + echo('
'.$o['desc'].'
'.N); + echo('
@@ -400,12 +405,13 @@ echo(' } selbox(array( + 'desc'=>'If your instance is mainly bound to a particular location (from neighbourhood to country) you can specify it here. You can add up to '.$account['MaxLocalities'].' location[s]. You can edit or remove only the location[s] you added, and only as long as they have not yet been referenced by others. For particular needs don’t hesitate to contact us.', 'multi'=>false, 'dispselid'=>'LocalityID', 'instselid'=>$inst['LocalityID'], - 'title'=>'Locality', + 'title'=>'Location', 'searchid'=>'locsearch', - 'searchtit'=>'Filter available localities', + 'searchtit'=>'Filter available locations', 'disparr'=>'locselarr', 'regexcbid'=>'locselre', 'dispque'=>'SELECT ID, Name'.$dlang.' FROM Localities ORDER BY NameOrig ASC', @@ -413,6 +419,7 @@ selbox(array( 'txtcol'=>'Name'.$dlang)); $o=array( + 'desc'=>'Here you can specify the languages which are mostly used on your instance, in order of importance. The list of available languages to choose from should be fairly complete, but if you find out it is not don’t hesitate to contact us. The list of chosen languages is often pre-populated by our crawler, which tries and guess them automatically, but you can always modify it and prevent the crawler from changing it on its next runs by ticking the “Lock this list” checkbox you find under the list.', 'multi'=>true, 'dispselid'=>'DispLangs', 'title'=>'Languages', @@ -443,27 +450,29 @@ selbox($o); 'Here you can specify the modalities by which your instance is financed, in order of importance. You can add up to '.$account['MaxFinancing'].' modalities to the list of available modalities. You can edit or remove only the modalities you added, and only as long as they have not yet been referenced by others.
For particular needs don’t hesitate to contact us.', 'multi'=>true, 'dispselid'=>'DispFinModes', - 'title'=>'Financing methods', + 'title'=>'Financing modalities', 'searchid'=>'finsearch', - 'searchtit'=>'Filter available financing methods', + 'searchtit'=>'Filter available financing modalities', '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'=>'Above: available fin. methods; below: chosen fin. methods', + 'dida'=>'Above: available fin. modes; below: chosen fin. modes', 'chosenselid'=>'ChosenFinModes[]', 'chosenque'=>'SELECT * FROM InstFinancing LEFT JOIN Financing ON Financing.ID=FinID WHERE InstID='.$inst['ID'].' ORDER BY Pos ASC', 'chosenvalcol'=>'FinID')); selbox(array( + 'desc'=>'Here you can specify the policies defining which kind of contents are allowed or not allowed on your instance. You can add up to '.$account['MaxPolicies'].' policies to the list of available policies. You can edit or remove only the policies you added, and only as long as they have not yet been referenced by others.
For particular needs don’t hesitate to contact us.', 'multi'=>true, 'dispselid'=>'DispPolicies', 'title'=>'Policies', 'searchid'=>'polsearch', - 'searchtit'=>'Filter policies', + 'searchtit'=>'Filter available policies', 'disparr'=>'polselarr', 'regexcbid'=>'polselre', 'dispque'=>'SELECT * FROM Policies WHERE ID NOT IN (SELECT PolID FROM InstPolicies WHERE InstID='.$inst['ID'].') ORDER BY Name ASC', @@ -475,17 +484,18 @@ selbox(array( 'chosenvalcol'=>'PolID')); selbox(array( + 'desc'=>'Here you can specify the “thematic” categories your instance is dedicated to, if any. If your instance isn’t particularly dedicated to any particular topic, please just associate it with the “General” category. You can add '.$account['MaxTags'].' categories to the list of available categories. You can edit or remove only the categories you added, and only as long as they have not yet been referenced by others. For particular needs don’t hesitate to contact us.', 'multi'=>true, 'dispselid'=>'DispTags', - 'title'=>'Tags', + 'title'=>'Categories', 'searchid'=>'tagsearch', - 'searchtit'=>'Filter tags', + 'searchtit'=>'Filter available categories', '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'=>'Above: available tags; below: chosen tags', + 'dida'=>'Above: available categories; below: chosen categories', 'chosenselid'=>'ChosenTags[]', 'chosenque'=>'SELECT * FROM InstTags LEFT JOIN Tags ON Tags.ID=TagID WHERE InstID='.$inst['ID'].' ORDER BY Pos ASC', 'chosenvalcol'=>'TagID')); diff --git a/web/admin/edinsth.php b/web/admin/edinsth.php index fdf4760..1556876 100644 --- a/web/admin/edinsth.php +++ b/web/admin/edinsth.php @@ -29,20 +29,54 @@ $contextopts=array( $context=stream_context_create($contextopts); $email='pezcurrel@tiscali.it'; -$langs=array('xx'=>'Local language','en'=>'English','es'=>'Español','fr'=>'Français','it'=>'Italiano'); +$langs=array('xx'=>'Local language','ca'=>'Català','en'=>'English','es'=>'Español','fr'=>'Français','it'=>'Italiano'); $exvalsjsarr='null;'.N; $morejs=''; $dbg.='
GET:'.N.print_r($_GET,1).'POST:'.N.print_r($_POST,1).'
'; +function check(&$link,&$account,$mode,$table,$lntable,$lncolumn,$id) { + if ($mode=='edit' || $mode=='remove') { + $res=mysqli_query($link,'SELECT * FROM '.$table.' WHERE ID='.$id) + or muoribene(__LINE__.': '.mysqli_error($link),true); + if (mysqli_num_rows($res)==1) { + $row=mysqli_fetch_assoc($res); + if ($account['Level']=='guest') { + if ($row['AddedBy']!=$account['ID']) + muoribene('You can’t modify an entry you didn’t add.',true); + if ($table!='Localities') { + $que='SELECT * FROM '.$lntable.' LEFT JOIN Instances ON Instances.ID='.$lntable.'.InstID WHERE '.$lntable.'.'.$lncolumn.'='.$id.' AND Instances.ID NOT IN (SELECT ID FROM Instances WHERE OurAdmID='.$account['ID'].')'; + } else { + $que='SELECT * FROM Instances WHERE LocalityID='.$id.' AND Instances.ID NOT IN (SELECT ID FROM Instances WHERE OurAdmID='.$account['ID'].')'; + } + $rres=mysqli_query($link,$que) + or muoribene(__LINE__.': '.mysqli_error($link).'
Query: '.hspech($que),true); + if (mysqli_num_rows($rres)>0) + muoribene('You can’t modify an entry that
has already been linked by others.',true); + } + } else { + muoribene('There is no «'.$table.'» entry with ID='.$id.N,true); + } + } elseif ($mode=='add') { + if ($account['Level']=='guest') { + $res=mysqli_query($link,'SELECT * FROM '.$table.' WHERE AddedBy='.$account['ID']) + or muoribene(__LINE__.': '.mysqli_error($link),true); + if (mysqli_num_rows($res)>=$account['Max'.$table]) + muoribene('You can’t add more «'.$table.'»
entries ('.$account['Max'.$table].' max).',true); + } + } +} + function edaddrem($id,$table,$column,$dispselarr,$lntable,$lncolumn,$searchid,$dispselid,$recbid) { global $link, $morejs, $account, $dlang; + check($link,$account,$_POST['m'],$table,$lntable,$lncolumn,$id); if ($_POST['m']=='edit') { if ($table!='Languages') { mysqli_query($link,'UPDATE '.$table.' SET '.$column.'=\''.myesc($link,$_POST['v']).'\' WHERE ID='.$id) or muoribene(__LINE__.': '.mysqli_error($link),true); } else { $langs=array('NameOrig'=>mb_ucfirst(locale_get_display_name($_POST['v'],$_POST['v'])), + 'NameCA'=>mb_ucfirst(locale_get_display_name($_POST['v'],'ca')), 'NameEN'=>mb_ucfirst(locale_get_display_name($_POST['v'],'en')), 'NameES'=>mb_ucfirst(locale_get_display_name($_POST['v'],'es')), 'NameFR'=>mb_ucfirst(locale_get_display_name($_POST['v'],'fr')), @@ -50,7 +84,7 @@ function edaddrem($id,$table,$column,$dispselarr,$lntable,$lncolumn,$searchid,$d if ($_POST['v']==$langs['NameOrig']) { muoribene('«'.$_POST['v'].'»: unknown language identifier.',true); } else { - mysqli_query($link,'UPDATE '.$table.' SET Code=\''.myesc($link,$_POST['v']).'\', NameOrig=\''.myesc($link,$langs['NameOrig']).'\', NameEN=\''.myesc($link,$langs['NameEN']).'\', NameES=\''.myesc($link,$langs['NameES']).'\', NameFR=\''.myesc($link,$langs['NameFR']).'\', NameIT=\''.myesc($link,$langs['NameIT']).'\' WHERE ID='.$id) + mysqli_query($link,'UPDATE '.$table.' SET Code=\''.myesc($link,$_POST['v']).'\', NameOrig=\''.myesc($link,$langs['NameOrig']).'\', NameCA=\''.myesc($link,$langs['NameCA']).'\', NameEN=\''.myesc($link,$langs['NameEN']).'\', NameES=\''.myesc($link,$langs['NameES']).'\', NameFR=\''.myesc($link,$langs['NameFR']).'\', NameIT=\''.myesc($link,$langs['NameIT']).'\' WHERE ID='.$id) or muoribene(__LINE__.': '.mysqli_error($link),true); $_POST['v']=$langs['Name'.$dlang].' ['.$_POST['v'].']'; } @@ -65,6 +99,7 @@ function edaddrem($id,$table,$column,$dispselarr,$lntable,$lncolumn,$searchid,$d $newid=mysqli_insert_id($link); } else { $langs=array('NameOrig'=>mb_ucfirst(locale_get_display_name($_POST['v'],$_POST['v'])), + 'NameCA'=>mb_ucfirst(locale_get_display_name($_POST['v'],'ca')), 'NameEN'=>mb_ucfirst(locale_get_display_name($_POST['v'],'en')), 'NameES'=>mb_ucfirst(locale_get_display_name($_POST['v'],'es')), 'NameFR'=>mb_ucfirst(locale_get_display_name($_POST['v'],'fr')), @@ -72,7 +107,7 @@ function edaddrem($id,$table,$column,$dispselarr,$lntable,$lncolumn,$searchid,$d if (strtolower($_POST['v'])==strtolower($langs['NameOrig'])) { muoribene('«'.$_POST['v'].'»: unknown language identifier.',true); } else { - mysqli_query($link,'INSERT INTO '.$table.' (ID, Code, NameOrig, NameEN, NameES, NameFR, NameIT, AddedBy) VALUES (NULL, \''.myesc($link,$_POST['v']).'\', \''.myesc($link,$langs['NameOrig']).'\', \''.myesc($link,$langs['NameEN']).'\', \''.myesc($link,$langs['NameES']).'\', \''.myesc($link,$langs['NameFR']).'\', \''.myesc($link,$langs['NameIT']).'\', '.$account['ID'].')') + mysqli_query($link,'INSERT INTO '.$table.' (ID, Code, NameOrig, NameCA, NameEN, NameES, NameFR, NameIT, AddedBy) VALUES (NULL, \''.myesc($link,$_POST['v']).'\', \''.myesc($link,$langs['NameOrig']).'\', \''.myesc($link,$langs['NameCA']).'\', \''.myesc($link,$langs['NameEN']).'\', \''.myesc($link,$langs['NameES']).'\', \''.myesc($link,$langs['NameFR']).'\', \''.myesc($link,$langs['NameIT']).'\', '.$account['ID'].')') or muoribene(__LINE__.': '.mysqli_error($link),true); $newid=mysqli_insert_id($link); $_POST['v']=$langs['Name'.$dlang].' ['.$_POST['v'].']'; @@ -139,7 +174,7 @@ if (array_key_exists('w',$_GET) && array_key_exists('i',$_GET) && preg_match('/^ $exvalsjsarr=setjsarr('Languages','Code'); break; case 'DispFinModes': - $out=buildform($id,'Financing','Type','Financing method','InstFinancing','FinID'); + $out=buildform($id,'Financing','Type','Financing modality','InstFinancing','FinID'); $exvalsjsarr=setjsarr('Financing','Type'); break; case 'DispPolicies': @@ -165,53 +200,79 @@ if (array_key_exists('w',$_GET) && array_key_exists('i',$_GET) && preg_match('/^ $url='https://nominatim.openstreetmap.org/search?q='.urlencode($_POST['v']).'&format=json&email='.$email; $osmd=@file_get_contents($url,false,$context); if ($osmd!==false) { - $out.=''.N; - $addrkeys=array('suburb','city','county','state','country'); $osmd=json_decode($osmd,true); if (count($osmd)>0) { - $some=false; - $out.='

Please choose the most detailed appropriate entry

'.N; + $addrkeys=array('neighbourhood','borough','suburb','city','municipality','county','district','province','region','state','country'); + $onegood=false; + $divs=''; foreach ($osmd as $loc) { + $good=false; + $div=''; + //$loc=array(); // simula errore if (array_key_exists('osm_id',$loc) && array_key_exists('osm_type',$loc) && $loc['osm_type']=='relation') { - $out.='
'.N; - $out.='
    '.N; + $div.=''.N; + $div.='
      '.N; foreach ($langs as $code=>$lang) { + $hidval=''; $url='https://nominatim.openstreetmap.org/lookup?osm_ids=R'.$loc['osm_id'].'&format=json&accept-language='.$code.'&addressdetails=1&email='.$email; $osmdil=@file_get_contents($url,false,$context); if ($osmdil!==false) { - $some=true; //+++ $osmdil=json_decode($osmdil,true); if (array_key_exists(0,$osmdil) && array_key_exists('address',$osmdil[0])) { - $dispname=''; + //$osmdil[0]['address']=array(); // simula errore + $dispname=array(); foreach ($addrkeys as $addrkey) if (array_key_exists($addrkey,$osmdil[0]['address'])) - $dispname.=$osmdil[0]['address'][$addrkey].', '; - $dispname=substr($dispname,0,-2); - $out.='
    • '.$lang.': '.hspech($dispname).'
    • '.N; - $out.=''.N; + $dispname[]=$osmdil[0]['address'][$addrkey]; + if (count($dispname)>0) { + $dispname=array_unique($dispname); + $dispname=implode(', ',$dispname); + $div.='
    • '.$lang.': '.hspech($dispname).'
    • '.N; + $hidval=jsencode($dispname); + if ($code=='xx') { + $res=mysqli_query($link,'SELECT NameOrig FROM Localities WHERE NameOrig=\''.myesc($link,$dispname).'\'') + or muoribene(__LINE__.': '.mysqli_error($link),true); + if (mysqli_num_rows($res)==0) + $good=true; + } + } else { + $div.='
    • '.$lang.': No useful «address» data found in OpenStreetMap lookup data.
    • '.N; + } } else { - $out.='
    • '.$lang.': Couldn’t parse OpenStreetMap lookup data.
    • '.N; - $out.=''.N; + $div.='
    • '.$lang.': No «address» found in OpenStreetMap lookup data.
    • '.N; } } else { - $out.='
    • '.$lang.': Couldn’t fetch OpenStreetMap lookup data.
    • '.N; + $div.='
    • '.$lang.': Couldn’t fetch OpenStreetMap lookup data.
    • '.N; } + $div.=''.N; } - $out.='
    '.N.'
'.N; + if ($good) { + $onegood=true; + $divs.='
'.N.$div; + } else { + $divs.='
'.N.$div; + } + $divs.=''.N.'
'.N; } } - if ($some) { + if ($onegood) { + $out.=''.N; + $out.='

Please choose the most appropriate entry
among those with green background

'.N; + $out.=$divs; $out.=''.N; $out.=''.N; $out.=''.N; + $out.=''.N; $out.=''.N; + $out.=''.N; $out.=''.N; $out.=''.N; $out.=''.N; $out.=''.N; $out.=''.N; } else { - $out='

Couldn’t find localized OpenStreetMap data for «'.hspech($_POST['v']).'».

'; + $out.='

Sorry, no good OpenStreetMap entry was found
(they are either incomplete or already in our database)

'.N; + $out.=$divs; } } else { $out='

Couldn’t find OpenStreetMap data for «'.hspech($_POST['v']).'».

'; @@ -221,6 +282,7 @@ if (array_key_exists('w',$_GET) && array_key_exists('i',$_GET) && preg_match('/^ } } else { // locality remove + check($link,$account,$_POST['m'],'Localities','Instances','LocalityID',$id); $out='CANCELLO!'; if (!array_key_exists('subst',$_POST) || preg_match('/^[0-9]+$/',$_POST['subst'])!==1) muoribene(__LINE__.': Malformed input.',true); @@ -250,17 +312,18 @@ if (array_key_exists('w',$_GET) && array_key_exists('i',$_GET) && preg_match('/^ // questo è ridondante ma fa niente muoribene(__LINE__.': Malformed input.',true); } - } elseif (array_key_exists('LocXX',$_POST) && array_key_exists('LocEN',$_POST) && array_key_exists('LocES',$_POST) && array_key_exists('LocFR',$_POST) && array_key_exists('LocIT',$_POST)) { + } elseif (array_key_exists('OSMID',$_POST) && preg_match('/^[0-9]+$/',$_POST['OSMID'])===1 && array_key_exists('LocXX',$_POST) && array_key_exists('LocCA',$_POST) && array_key_exists('LocEN',$_POST) && array_key_exists('LocES',$_POST) && array_key_exists('LocFR',$_POST) && array_key_exists('LocIT',$_POST)) { // locality edit/add + check($link,$account,$_POST['m'],'Localities','Instances','LocalityID',$id); $out='EDITO/AGGIUNGO!'; // qui, sia su add sia su edit, serve check che non esista già +++ if ($_POST['m']=='add') { - mysqli_query($link,'INSERT INTO Localities (ID, NameOrig, NameEN, NameES, NameFR, NameIT, AddedBy) VALUES (NULL, \''.myesc($link,$_POST['LocXX']).'\', \''.myesc($link,$_POST['LocEN']).'\', \''.myesc($link,$_POST['LocES']).'\', \''.myesc($link,$_POST['LocFR']).'\', \''.myesc($link,$_POST['LocIT']).'\', \''.$account['ID'].'\')') + mysqli_query($link,'INSERT INTO Localities (ID, OSMID, NameOrig, NameCA, NameEN, NameES, NameFR, NameIT, AddedBy) VALUES (NULL, \''.myesc($link,$_POST['OSMID']).'\', \''.myesc($link,$_POST['LocXX']).'\', \''.myesc($link,$_POST['LocCA']).'\', \''.myesc($link,$_POST['LocEN']).'\', \''.myesc($link,$_POST['LocES']).'\', \''.myesc($link,$_POST['LocFR']).'\', \''.myesc($link,$_POST['LocIT']).'\', \''.$account['ID'].'\')') or muoribene(__LINE__.': '.mysqli_error($link),true); $id=mysqli_insert_id($link); $morejs.='parent.locselarr.push(["'.jsencode($_POST['Loc'.$dlang]).'",'.$id.',true]);'.N; } elseif ($_POST['m']=='edit') { - mysqli_query($link,'UPDATE Localities SET NameOrig=\''.myesc($link,$_POST['LocXX']).'\', NameEN=\''.myesc($link,$_POST['LocEN']).'\', NameES=\''.myesc($link,$_POST['LocES']).'\', NameFR=\''.myesc($link,$_POST['LocFR']).'\', NameIT=\''.myesc($link,$_POST['LocIT']).'\' WHERE ID='.$id) + mysqli_query($link,'UPDATE Localities SET OSMID=\''.myesc($link,$_POST['OSMID']).'\', NameOrig=\''.myesc($link,$_POST['LocXX']).'\', NameCA=\''.myesc($link,$_POST['LocCA']).'\', NameEN=\''.myesc($link,$_POST['LocEN']).'\', NameES=\''.myesc($link,$_POST['LocES']).'\', NameFR=\''.myesc($link,$_POST['LocFR']).'\', NameIT=\''.myesc($link,$_POST['LocIT']).'\' WHERE ID='.$id) or muoribene(__LINE__.': '.mysqli_error($link),true); $morejs.='parent.locselarr=parent.cheltxtbyval(parent.locselarr,'.$id.',"'.jsencode($_POST['Loc'.$dlang]).'");'.N; } @@ -277,54 +340,43 @@ if (array_key_exists('w',$_GET) && array_key_exists('i',$_GET) && preg_match('/^ function buildform($id,$table,$column,$title,$lntable,$lncolumn) { global $account, $tables, $link; + check($link,$account,$_GET['m'],$table,$lntable,$lncolumn,$id); $out=''; if ($_GET['m']=='edit' || $_GET['m']=='remove') { $res=mysqli_query($link,'SELECT * FROM '.$table.' WHERE ID='.$id) or muoribene(__LINE__.': '.mysqli_error($link),true); - if (mysqli_num_rows($res)==1) { - $row=mysqli_fetch_assoc($res); - if ($account['Level']=='guest') { - if ($row['AddedBy']!=$account['ID']) - muoribene('You can’t modify an entry you didn’t add.',true); - $rres=mysqli_query($link,'SELECT * FROM '.$lntable.' WHERE '.$lncolumn.'='.$id.' AND AddedBy!='.$account['ID']) + $row=mysqli_fetch_assoc($res); + if ($_GET['m']=='edit') { + $out.='
'.N; + $out.=''.N; + $out.=''.N; + } elseif ($_GET['m']=='remove') { + $lnres=mysqli_query($link,'SELECT * FROM '.$lntable.' WHERE '.$lncolumn.'='.$id) + or muoribene(__LINE__.': '.mysqli_error($link),true); + $nlinking=mysqli_num_rows($lnres); + if ($nlinking>0) { + $out.='
«'.hspech($row[$column]).'» is referenced by '.$nlinking.' '.(($nlinking==1) ? 'instance' : 'instances').'!
'.N; + $out.='
What do you want to do with '.(($nlinking==1) ? 'this reference' : 'those '.$nlinking.' references').'?
If you choose “Delete” '.(($nlinking==1) ? 'it' : 'they').' will be removed; otherwise you can select a substitution record.
'.N; + $out.=''.N; - $out.=''.N; - } elseif ($_GET['m']=='remove') { - $lnres=mysqli_query($link,'SELECT * FROM '.$lntable.' WHERE '.$lncolumn.'='.$id) - or muoribene(__LINE__.': '.mysqli_error($link),true); - $nlinking=mysqli_num_rows($lnres); - if ($nlinking>0) { - $out.='
«'.hspech($row[$column]).'» is referenced by '.$nlinking.' '.(($nlinking==1) ? 'instance' : 'instances').'!
'.N; - $out.='
What do you want to do with '.(($nlinking==1) ? 'this reference' : 'those '.$nlinking.' references').'?
If you choose “Delete” '.(($nlinking==1) ? 'it' : 'they').' will be removed; otherwise you can select a substitution record.
'.N; - $out.=''.N; - } else { - $out.=''.N; + while ($lnrow=mysqli_fetch_assoc($lnres)) { + $out.=''.N; } - $out.='
Are you sure you want to remove «'.$row[$column].'»?
'.N; - $out.=''.N; + $out.=''.N; + } else { + $out.=''.N; } - $out.=''.N; - } else { - $out.='

There is no '.$title.' with ID='.$id.'

'.N; + $out.='
Are you sure you want to remove «'.$row[$column].'»?
'.N; + $out.=''.N; } + $out.=''.N; } elseif ($_GET['m']=='add') { $out.='
'.N; $out.=''.N; @@ -403,7 +455,7 @@ function ckf(mode,table) { if (ok) { var wdiv=document.getElementById('wait'); if (table=='Localities' && mode!='remove') - wdiv.innerHTML='Fetching data from OpenStreetMap.org ...'; + wdiv.innerHTML='Fetching data from OpenStreetMap.org (can take some time) ...'; else wdiv.innerHTML='Sending data ...'; wdiv.style.display='block'; @@ -414,14 +466,16 @@ function ckf(mode,table) { } function subosmd(osmid) { - document.getElementById('LocXX').value=document.getElementById('LocXX-'+osmid).value; - document.getElementById('LocEN').value=document.getElementById('LocEN-'+osmid).value; - document.getElementById('LocES').value=document.getElementById('LocES-'+osmid).value; - document.getElementById('LocFR').value=document.getElementById('LocFR-'+osmid).value; - document.getElementById('LocIT').value=document.getElementById('LocIT-'+osmid).value; - if (document.getElementById('LocXX').value=='' || document.getElementById('LocEN').value=='' || document.getElementById('LocES').value=='' || document.getElementById('LocFR').value=='' || document.getElementById('LocIT').value=='') { - alert('NO GOOD!'); + if (document.getElementById('OSMID-'+osmid).value=='' || document.getElementById('LocXX-'+osmid).value=='' || document.getElementById('LocCA-'+osmid).value=='' || document.getElementById('LocEN-'+osmid).value=='' || document.getElementById('LocES-'+osmid).value=='' || document.getElementById('LocFR-'+osmid).value=='' || document.getElementById('LocIT-'+osmid).value=='') { + alerta('

Couldn’t save this entry: missing data for one or more languages.

',true); } else { + document.getElementById('OSMID').value=document.getElementById('OSMID-'+osmid).value; + document.getElementById('LocXX').value=document.getElementById('LocXX-'+osmid).value; + document.getElementById('LocCA').value=document.getElementById('LocCA-'+osmid).value; + document.getElementById('LocEN').value=document.getElementById('LocEN-'+osmid).value; + document.getElementById('LocES').value=document.getElementById('LocES-'+osmid).value; + document.getElementById('LocFR').value=document.getElementById('LocFR-'+osmid).value; + document.getElementById('LocIT').value=document.getElementById('LocIT-'+osmid).value; document.getElementById('f').submit(); } } @@ -437,11 +491,20 @@ function subosmd(osmid) {
+
...
+ diff --git a/web/admin/edinstres.php b/web/admin/edinstres.php index 163579c..e2c552b 100644 --- a/web/admin/edinstres.php +++ b/web/admin/edinstres.php @@ -7,6 +7,7 @@ require('include/myconn.php'); require('include/getadmacc.php'); require('include/menu.php'); $menu['menu']['selected']=true; +$menu['menu']['submenu']['instances']['selected']=true; buildmenu($menu); $dbg=''; @@ -21,11 +22,10 @@ $dbg.='
'.print_r($_POST,1).'
'; if (array_key_exists('id',$_POST) && preg_match('/^[0-9]+$/',$_POST['id'])===1) { $instid=$_POST['id']+0; - $res=mysqli_query($link,'SELECT *, ID AS IID FROM Instances WHERE ID='.$instid) + $res=mysqli_query($link,'SELECT ID FROM Instances WHERE ID='.$instid) or muoribene(__LINE__.': '.mysqli_error($link),true); if (mysqli_num_rows($res)!=1) muoribene(__LINE__.': There is no instance with ID='.$instid.'.'); - $inst=mysqli_fetch_assoc($res); } if (!array_key_exists('id',$_POST) || !array_key_exists('OurDesc',$_POST) || !array_key_exists('OurDescEN',$_POST)) @@ -59,7 +59,7 @@ if (array_key_exists('LocalityID',$_POST)) { $sets[]='LocalityID=NULL'; } -$que.=implode(', ',$sets).' WHERE ID='.$instid; +$que.=implode(', ',$sets).', LastGuestEdit='.time().' WHERE ID='.$instid; $dbg.='QUERONA: '.hspech($que).'
'.N; mysqli_query($link,$que) or muoribene(__LINE__.': '.mysqli_error($link),true); @@ -95,6 +95,9 @@ multi($link,$instid,$dbg,'ChosenFinModes','InstFinancing','FinID',__LINE__); multi($link,$instid,$dbg,'ChosenPolicies','InstPolicies','PolID',__LINE__); multi($link,$instid,$dbg,'ChosenTags','InstTags','TagID',__LINE__); +$res=mysqli_query($link,'SELECT *, ID AS IID FROM Instances WHERE ID='.$instid) + or muoribene(__LINE__.': '.mysqli_error($link),true); +$inst=mysqli_fetch_assoc($res); require('include/columns.php'); require('include/dispinst.php'); $out=dispinst($inst,$cols,$link,$dlang,false,0,0); @@ -131,7 +134,7 @@ mysqli_close($link);
Editing results for «»
- +
diff --git a/web/admin/guestinsts.php b/web/admin/guestinsts.php index d3c5c80..5560c23 100644 --- a/web/admin/guestinsts.php +++ b/web/admin/guestinsts.php @@ -48,7 +48,7 @@ function hspech($str) {
Your instances
- +
diff --git a/web/admin/include/glob.php b/web/admin/include/glob.php index 20d9b73..f21f6c0 100644 --- a/web/admin/include/glob.php +++ b/web/admin/include/glob.php @@ -5,7 +5,7 @@ header("Pragma: no-cache"); // HTTP 1.0. header("Expires: 0"); // Proxies. define('N',"\n"); $cjrand=rand(0,999999); -$supplangs=['en','es','fr','it']; +$supplangs=['ca','en','es','fr','it']; $dlang=substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2); $dlang=in_array($dlang,$supplangs) ? strtoupper($dlang) : 'EN'; diff --git a/web/admin/include/menu.php b/web/admin/include/menu.php index 37eebfb..8c59381 100644 --- a/web/admin/include/menu.php +++ b/web/admin/include/menu.php @@ -1,70 +1,6 @@ array('liadd'=>null, 'href'=>null, 'title'=>'Menu', 'selected'=>false, 'submenu'=> - array( - 'instances'=>array('liadd'=>null, 'href'=>'instances.php', 'title'=>'Instances', '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), - 'notifs'=>array('liadd'=>null, 'href'=>'#', 'title'=>'Notifications', 'selected'=>false, 'submenu'=>null), - 'logout'=>array('liadd'=>null, 'href'=>'logout.php', 'title'=>'Log out', 'selected'=>false, 'submenu'=>null) - ) - ), - 'blacklist'=>array('liadd'=>null, 'href'=>'#', 'title'=>'Blacklist', 'selected'=>false, 'submenu'=>null), - 'certo'=>array('liadd'=>null, 'href'=>'#', 'title'=>'Certo', 'selected'=>false, 'submenu'=> - array( - 'instances'=>array('liadd'=>null, 'href'=>'instances.php', 'title'=>'Instances', '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), - 'notifs'=>array('liadd'=>null, 'href'=>'#', 'title'=>'Notifications', 'selected'=>false, 'submenu'=> - array( - 'instances'=>array('liadd'=>null, 'href'=>'instances.php', 'title'=>'Instances', '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), - 'notifs'=>array('liadd'=>null, 'href'=>'#', 'title'=>'Notifications', 'selected'=>false, 'submenu'=> - array( - 'instances'=>array('liadd'=>null, 'href'=>'instances.php', 'title'=>'Instances', '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), - 'notifs'=>array('liadd'=>null, 'href'=>'#', 'title'=>'Notifications', 'selected'=>false, 'submenu'=>null), - 'logout'=>array('liadd'=>null, 'href'=>'logout.php', 'title'=>'Log out', 'selected'=>false, 'submenu'=>null) - ) - ), - 'logout'=>array('liadd'=>null, 'href'=>'logout.php', 'title'=>'Log out', 'selected'=>false, 'submenu'=>null) - ), - ), - 'logout'=>array('liadd'=>null, 'href'=>'logout.php', 'title'=>'Log out', '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'=> - array( - 'instances'=>array('liadd'=>null, 'href'=>'instances.php', 'title'=>'Instances', '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), - 'notifs'=>array('liadd'=>null, 'href'=>'#', 'title'=>'Notifications', 'selected'=>false, 'submenu'=> - array( - 'instances'=>array('liadd'=>null, 'href'=>'instances.php', 'title'=>'Instances', '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), - 'notifs'=>array('liadd'=>null, 'href'=>'#', 'title'=>'Notifications', 'selected'=>false, 'submenu'=> - array( - 'instances'=>array('liadd'=>null, 'href'=>'instances.php', 'title'=>'Instances', '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), - 'notifs'=>array('liadd'=>null, 'href'=>'#', 'title'=>'Notifications', 'selected'=>false, 'submenu'=>null), - 'logout'=>array('liadd'=>null, 'href'=>'logout.php', 'title'=>'Log out', 'selected'=>false, 'submenu'=>null) - ) - ), - 'logout'=>array('liadd'=>null, 'href'=>'logout.php', 'title'=>'Log out', 'selected'=>false, 'submenu'=>null) - ), - ), - 'logout'=>array('liadd'=>null, 'href'=>'logout.php', 'title'=>'Log out', 'selected'=>false, 'submenu'=>null) - ) - ) - );*/ $menu=array( 'menu'=>array('liadd'=>null, 'href'=>null, 'title'=>'Menu', 'selected'=>false, 'submenu'=> array( @@ -72,7 +8,7 @@ if ($account['Level']!='guest') { 'blacklist'=>array('liadd'=>null, 'href'=>'#', 'title'=>'Blacklist', 'selected'=>false, 'submenu'=>null), 'accounts'=>array('liadd'=>null, 'href'=>'#', 'title'=>'Accounts', 'selected'=>false, 'submenu'=>null), 'notifs'=>array('liadd'=>null, 'href'=>'#', 'title'=>'Notifications', 'selected'=>false, 'submenu'=>null), - 'signout'=>array('liadd'=>null, 'href'=>'logout.php', 'title'=>'Sign out', 'selected'=>false, 'submenu'=>null) + 'signout'=>array('liadd'=>null, 'href'=>'logout.php', 'title'=>'Logout', 'selected'=>false, 'submenu'=>null) ) ) ); @@ -82,13 +18,13 @@ if ($account['Level']!='guest') { array( 'instances'=>array('liadd'=>null, 'href'=>'guestinsts.php', 'title'=>'Instances', 'selected'=>false, 'submenu'=>null), 'account'=>array('liadd'=>null, 'href'=>'#', 'title'=>'Account', 'selected'=>false, 'submenu'=>null), - 'signout'=>array('liadd'=>null, 'href'=>'logout.php', 'title'=>'Sign out', 'selected'=>false, 'submenu'=>null), + 'signout'=>array('liadd'=>null, 'href'=>'logout.php', 'title'=>'Logout', 'selected'=>false, 'submenu'=>null), ) ) ); } -// $menuout va sempre wrappato in che abbia una classe css come quella che si vede in theme.css (#hmenu ul ecc.) +// $menuout va sempre wrappato in che abbia una classe css come quella che si vede in theme.css ("#hmenu ul" ecc.) $menuout=''; function buildmenu($menu,$submenu=false) { @@ -99,10 +35,14 @@ function buildmenu($menu,$submenu=false) { if (!is_null($arr['submenu'])) $menuout.=' onmouseover="chulsh(this,true)" onmouseout="chulsh(this,false)"'; if ($arr['selected']) $menuout.=' class="hil"'; $menuout.='>'; - if (!is_null($arr['href'])) - $menuout.=''.$arr['title'].''; - else + if (!is_null($arr['href'])) { + if (!$arr['selected']) + $menuout.=''.$arr['title'].''; + else + $menuout.=''.$arr['title'].''; + } else { $menuout.=$arr['title']; + } if (!is_null($arr['submenu'])) { ($submenu) ? $class='ulb' : $class='ula'; $menuout.=N.'