|
@@ -57,6 +57,7 @@ function edaddrem($id,$table,$column,$dispselarr,$lntable,$lncolumn,$searchid,$d
|
|
|
}
|
|
|
$morejs.='parent.'.$dispselarr.'=parent.cheltxtbyval(parent.'.$dispselarr.','.$id.',"'.jsencode($_POST['v']).'");'.N;
|
|
|
$morejs.='parent.'.$dispselarr.'=parent.sortByKey(parent.'.$dispselarr.',0);'.N;
|
|
|
+ $morejs.='parent.'.$dispselarr.'=parent.selonebyval(parent.'.$dispselarr.','.$id.');'.N;
|
|
|
} elseif ($_POST['m']=='add') {
|
|
|
if ($table!='Languages') {
|
|
|
mysqli_query($link,'INSERT INTO '.$table.' (ID, '.$column.', AddedBy) VALUES (NULL, \''.myesc($link,$_POST['v']).'\', \''.$account['ID'].'\')')
|
|
@@ -68,7 +69,7 @@ function edaddrem($id,$table,$column,$dispselarr,$lntable,$lncolumn,$searchid,$d
|
|
|
'NameES'=>mb_ucfirst(locale_get_display_name($_POST['v'],'es')),
|
|
|
'NameFR'=>mb_ucfirst(locale_get_display_name($_POST['v'],'fr')),
|
|
|
'NameIT'=>mb_ucfirst(locale_get_display_name($_POST['v'],'it')));
|
|
|
- if ($_POST['v']==$langs['NameOrig']) {
|
|
|
+ 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'].')')
|
|
@@ -79,6 +80,7 @@ function edaddrem($id,$table,$column,$dispselarr,$lntable,$lncolumn,$searchid,$d
|
|
|
}
|
|
|
$morejs.='parent.'.$dispselarr.'.push(["'.jsencode($_POST['v']).'",'.$newid.',true]);'.N;
|
|
|
$morejs.='parent.'.$dispselarr.'=parent.sortByKey(parent.'.$dispselarr.',0);'.N;
|
|
|
+ $morejs.='parent.'.$dispselarr.'=parent.selonebyval(parent.'.$dispselarr.','.$newid.');'.N;
|
|
|
} elseif ($_POST['m']=='remove') {
|
|
|
if (!array_key_exists('subst',$_POST) || preg_match('/^[0-9]+$/',$_POST['subst'])!==1)
|
|
|
muoribene(__LINE__.': Malformed input.',true);
|
|
@@ -122,6 +124,7 @@ function edaddrem($id,$table,$column,$dispselarr,$lntable,$lncolumn,$searchid,$d
|
|
|
$morejs.='parent.'.$dispselarr.'=parent.rmelbyval(parent.'.$dispselarr.','.$id.');'.N;
|
|
|
}
|
|
|
$morejs.='parent.filtsel (parent.'.$dispselarr.', parent.document.getElementById("'.$searchid.'").value, "'.$dispselid.'", "'.$recbid.'", "'.$searchid.'", "white", "#ff8080");'.N;
|
|
|
+ $morejs.='parent.closeinpup();'.N;
|
|
|
}
|
|
|
|
|
|
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'],array('edit','add','remove'))) {
|
|
@@ -152,68 +155,88 @@ if (array_key_exists('w',$_GET) && array_key_exists('i',$_GET) && preg_match('/^
|
|
|
break;
|
|
|
}
|
|
|
} elseif (array_key_exists('m',$_POST) && in_array($_POST['m'],array('edit','add','remove')) && array_key_exists('t',$_POST) && in_array($_POST['t'],array('Localities','Languages','Financing','Policies','Tags')) && array_key_exists('i',$_POST) && preg_match('/^[0-9]+$/',$_POST['i'])===1) {
|
|
|
+ $id=$_POST['i']+0;
|
|
|
if (array_key_exists('v',$_POST)) {
|
|
|
$out='';
|
|
|
- $id=$_POST['i']+0;
|
|
|
if ($_POST['t']=='Localities') {
|
|
|
+ if ($_POST['m']!='remove') {
|
|
|
//https://nominatim.openstreetmap.org/search?q=bresso,+milano&format=json&accept-language=fr&email=pezcurrel@tiscali.it
|
|
|
//https://nominatim.openstreetmap.org/lookup?osm_ids=R45266&format=json&accept-language=fr&addressdetails=1&email=pezcurrel@tiscali.it
|
|
|
- $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.='<form action="edinsth.php" method="post" id="f">'.N;
|
|
|
- $addrkeys=array('suburb','city','county','state','country');
|
|
|
- $osmd=json_decode($osmd,true);
|
|
|
- if (count($osmd)>0) {
|
|
|
- $some=false;
|
|
|
- $out.='<p><strong>Please choose the most detailed appropriate entry</strong></p>'.N;
|
|
|
- foreach ($osmd as $loc) {
|
|
|
- if (array_key_exists('osm_id',$loc) && array_key_exists('osm_type',$loc) && $loc['osm_type']=='relation') {
|
|
|
- $out.='<div class="hifloc" onclick="subosmd(\''.$loc['osm_id'].'\');">'.N;
|
|
|
- $out.='<ul class="hiful">'.N;
|
|
|
- foreach ($langs as $code=>$lang) {
|
|
|
- $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='';
|
|
|
- foreach ($addrkeys as $addrkey)
|
|
|
- if (array_key_exists($addrkey,$osmdil[0]['address']))
|
|
|
- $dispname.=$osmdil[0]['address'][$addrkey].', ';
|
|
|
- $dispname=substr($dispname,0,-2);
|
|
|
- $out.='<li><strong>'.$lang.':</strong> '.hspech($dispname).'</li>'.N;
|
|
|
- $out.='<input type="hidden" id="Loc'.ucfirst($code).'-'.$loc['osm_id'].'" value="'.jsencode($dispname).'">'.N;
|
|
|
+ $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.='<form action="edinsth.php" method="post" id="f">'.N;
|
|
|
+ $addrkeys=array('suburb','city','county','state','country');
|
|
|
+ $osmd=json_decode($osmd,true);
|
|
|
+ if (count($osmd)>0) {
|
|
|
+ $some=false;
|
|
|
+ $out.='<p><strong>Please choose the most detailed appropriate entry</strong></p>'.N;
|
|
|
+ foreach ($osmd as $loc) {
|
|
|
+ if (array_key_exists('osm_id',$loc) && array_key_exists('osm_type',$loc) && $loc['osm_type']=='relation') {
|
|
|
+ $out.='<div class="hifloc" onclick="subosmd(\''.$loc['osm_id'].'\');">'.N;
|
|
|
+ $out.='<ul class="hiful">'.N;
|
|
|
+ foreach ($langs as $code=>$lang) {
|
|
|
+ $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='';
|
|
|
+ foreach ($addrkeys as $addrkey)
|
|
|
+ if (array_key_exists($addrkey,$osmdil[0]['address']))
|
|
|
+ $dispname.=$osmdil[0]['address'][$addrkey].', ';
|
|
|
+ $dispname=substr($dispname,0,-2);
|
|
|
+ $out.='<li><strong>'.$lang.':</strong> '.hspech($dispname).'</li>'.N;
|
|
|
+ $out.='<input type="hidden" id="Loc'.strtoupper($code).'-'.$loc['osm_id'].'" value="'.jsencode($dispname).'">'.N;
|
|
|
+ } else {
|
|
|
+ $out.='<li class="hiferr"><strong>'.$lang.':</strong> Couldn’t parse OpenStreetMap lookup data.</li>'.N;
|
|
|
+ $out.='<input type="hidden" id="Loc'.strtoupper($code).'-'.$loc['osm_id'].'" value="">'.N;
|
|
|
+ }
|
|
|
} else {
|
|
|
- $out.='<li class="hiferr"><strong>'.$lang.':</strong> Couldn’t parse OpenStreetMap lookup data.</li>'.N;
|
|
|
- $out.='<input type="hidden" id="Loc'.ucfirst($code).'-'.$loc['osm_id'].'" value="">'.N;
|
|
|
+ $out.='<li class="hiferr"><strong>'.$lang.':</strong> Couldn’t fetch OpenStreetMap lookup data.</li>'.N;
|
|
|
}
|
|
|
- } else {
|
|
|
- $out.='<li class="hiferr"><strong>'.$lang.':</strong> Couldn’t fetch OpenStreetMap lookup data.</li>'.N;
|
|
|
}
|
|
|
+ $out.='</ul>'.N.'</div>'.N;
|
|
|
}
|
|
|
- $out.='</ul>'.N.'</div>'.N;
|
|
|
}
|
|
|
- }
|
|
|
- if ($some) {
|
|
|
- $out.='<input type="hidden" id="i" name="i" value="'.$_POST['i'].'">'.N;
|
|
|
- $out.='<input type="hidden" id="t" name="t" value="'.$_POST['t'].'">'.N;
|
|
|
- $out.='<input type="hidden" id="m" name="m" value="'.$_POST['m'].'">'.N;
|
|
|
- $out.='<input type="hidden" id="LocXx" name="LocXx" value="">'.N;
|
|
|
- $out.='<input type="hidden" id="LocEn" name="LocEn" value="">'.N;
|
|
|
- $out.='<input type="hidden" id="LocEs" name="LocEs" value="">'.N;
|
|
|
- $out.='<input type="hidden" id="LocFr" name="LocFr" value="">'.N;
|
|
|
- $out.='<input type="hidden" id="LocIt" name="LocIt" value="">'.N;
|
|
|
- $out.='</form>'.N;
|
|
|
+ if ($some) {
|
|
|
+ $out.='<input type="hidden" id="i" name="i" value="'.$_POST['i'].'">'.N;
|
|
|
+ $out.='<input type="hidden" id="t" name="t" value="'.$_POST['t'].'">'.N;
|
|
|
+ $out.='<input type="hidden" id="m" name="m" value="'.$_POST['m'].'">'.N;
|
|
|
+ $out.='<input type="hidden" id="LocXX" name="LocXX" value="">'.N;
|
|
|
+ $out.='<input type="hidden" id="LocEN" name="LocEN" value="">'.N;
|
|
|
+ $out.='<input type="hidden" id="LocES" name="LocES" value="">'.N;
|
|
|
+ $out.='<input type="hidden" id="LocFR" name="LocFR" value="">'.N;
|
|
|
+ $out.='<input type="hidden" id="LocIT" name="LocIT" value="">'.N;
|
|
|
+ $out.='</form>'.N;
|
|
|
+ } else {
|
|
|
+ $out='<p class="hiferr">Couldn’t find localized OpenStreetMap data for «'.hspech($_POST['v']).'».</p>';
|
|
|
+ }
|
|
|
} else {
|
|
|
- $out='<p class="hiferr">Couldn’t find localized OpenStreetMap data for «'.hspech($_POST['v']).'».</p>';
|
|
|
+ $out='<p class="hiferr">Couldn’t find OpenStreetMap data for «'.hspech($_POST['v']).'».</p>';
|
|
|
}
|
|
|
} else {
|
|
|
- $out='<p class="hiferr">Couldn’t find OpenStreetMap data for «'.hspech($_POST['v']).'».</p>';
|
|
|
+ $out='<p class="hiferr">Couldn’t fetch OpenStreetMap search data.</p>'.N;
|
|
|
}
|
|
|
} else {
|
|
|
- $out='<p class="hiferr">Couldn’t fetch OpenStreetMap search data.</p>'.N;
|
|
|
+ // locality remove
|
|
|
+ $out='CANCELLO!';
|
|
|
+ if (!array_key_exists('subst',$_POST) || preg_match('/^[0-9]+$/',$_POST['subst'])!==1)
|
|
|
+ muoribene(__LINE__.': Malformed input.',true);
|
|
|
+ $_POST['subst']+=0;
|
|
|
+ if ($_POST['subst']==0) {
|
|
|
+ mysqli_query($link,'UPDATE Instances SET LocalityID=NULL WHERE LocalityID='.$id)
|
|
|
+ or muoribene(__LINE__.': '.mysqli_error($link),true);
|
|
|
+ } else {
|
|
|
+ mysqli_query($link,'UPDATE Instances SET LocalityID='.$_POST['subst'].' WHERE LocalityID='.$id)
|
|
|
+ or muoribene(__LINE__.': '.mysqli_error($link),true);
|
|
|
+ }
|
|
|
+ mysqli_query($link,'DELETE FROM Localities WHERE ID='.$id)
|
|
|
+ or muoribene(__LINE__.': '.mysqli_error($link),true);
|
|
|
+ $morejs.='parent.locselarr=parent.rmelbyval(parent.locselarr,'.$id.');'.N;
|
|
|
+ $morejs.='parent.filtsel (parent.locselarr, parent.document.getElementById("locsearch").value, "LocalityID", "locselre", "locsearch", "white", "#ff8080");'.N;
|
|
|
+ $morejs.='parent.closeinpup();'.N;
|
|
|
}
|
|
|
} elseif ($_POST['t']=='Languages') {
|
|
|
edaddrem($id,'Languages','Name'.$dlang,'langselarr','InstOurLangs','OurLangID','langsearch','DispLangs','langselre');
|
|
@@ -227,8 +250,24 @@ 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('LocEn',$_POST) && array_key_exists('LocEs',$_POST) && array_key_exists('LocFr',$_POST) && array_key_exists('LocIt',$_POST)) {
|
|
|
- $out='CIAO!';
|
|
|
+ } 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)) {
|
|
|
+ // locality edit/add
|
|
|
+ $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'].'\')')
|
|
|
+ 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)
|
|
|
+ or muoribene(__LINE__.': '.mysqli_error($link),true);
|
|
|
+ $morejs.='parent.locselarr=parent.cheltxtbyval(parent.locselarr,'.$id.',"'.jsencode($_POST['Loc'.$dlang]).'");'.N;
|
|
|
+ }
|
|
|
+ $morejs.='parent.locselarr=parent.sortByKey(parent.locselarr,0);'.N;
|
|
|
+ $morejs.='parent.locselarr=parent.selonebyval(parent.locselarr,'.$id.');'.N;
|
|
|
+ $morejs.='parent.filtsel (parent.locselarr, parent.document.getElementById("locsearch").value, "LocalityID", "locselre", "locsearch", "white", "#ff8080");'.N;
|
|
|
+ $morejs.='parent.closeinpup();'.N;
|
|
|
} else {
|
|
|
muoribene(__LINE__.': Malformed input.',true);
|
|
|
}
|
|
@@ -363,7 +402,7 @@ function ckf(mode,table) {
|
|
|
}
|
|
|
if (ok) {
|
|
|
var wdiv=document.getElementById('wait');
|
|
|
- if (table=='Localities')
|
|
|
+ if (table=='Localities' && mode!='remove')
|
|
|
wdiv.innerHTML='Fetching data from OpenStreetMap.org ...';
|
|
|
else
|
|
|
wdiv.innerHTML='Sending data ...';
|
|
@@ -375,11 +414,12 @@ function ckf(mode,table) {
|
|
|
}
|
|
|
|
|
|
function subosmd(osmid) {
|
|
|
- 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('LocEn').value=='' || document.getElementById('LocEs').value=='' || document.getElementById('LocFr').value=='' || document.getElementById('LocIt').value=='') {
|
|
|
+ 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!');
|
|
|
} else {
|
|
|
document.getElementById('f').submit();
|
|
@@ -397,7 +437,9 @@ function subosmd(osmid) {
|
|
|
<?php echo($out); ?>
|
|
|
</div>
|
|
|
</div>
|
|
|
+<div id="debugh">
|
|
|
<?php echo($dbg); ?>
|
|
|
+</div>
|
|
|
<div id="wait">
|
|
|
...
|
|
|
</div>
|