log("VISITING {$_SERVER['REQUEST_URI']}"); } $result = -1; $rememberhtml = ''; $message; for(;;) { if (isset($_GET['node'])) { $id = $_GET['node']; $elemtype = 'node'; } else if (isset($_GET['way'])) { $id = $_GET['way']; $elemtype = 'way'; } else { $result = 'no_id'; $message = 'missing ?elemtype=id in url, or relation (cannot handle relations yet)'; break; } if (! empty($_POST)) { //print_r($_POST); if (! empty($_POST['login'])) { if (! empty($_POST['user'])) { $session['user'] = $_POST['user']; } if (! empty($_POST['user'])) { $session['password'] = $_POST['password']; } if (! empty($_POST['remember'])) { setlogincookie($session['user'], $session['password']); $rememberhtml = "checked='checked'"; } else { clearlogincookie(); } } else if (! empty($_POST['logout'])) { unset($session['user']); unset($session['password']); $result = 'need_login'; clearlogincookie(); break; } else if (isset($_POST['action'])) { $action = $_POST['action']; switch($action) { case 0: // ok if (empty($_POST['values']) || ! is_array($_POST['values'])) { $message = 'missing values (naughty, naughty)'; break 2; } $newtags = ''; for($i = 0; $i < count($_POST['tags']); $i++) { if (! is_string($_POST['tags'][$i])) { $message = "non-string tag {$i} (naughty, naughty)"; break 2; } if (! isset($_POST['values'][$i])) { $message = "missing value {$i} (naughty, naughty)"; break 2; } if (! is_string($_POST['values'][$i])) { $message = "non-string value {$i} (naughty, naughty)"; break 2; } $uploadtag = trim($_POST['tags'][$i]); if ($uploadtag == '') { continue; } $uploadvalue = $_POST['values'][$i]; $newtags .= "\n"; } $uploadxml = preg_replace("~\\\\s*\\<\\/{$elemtype}\\>~is", $newtags . "", $session['xml'][$elemtype][$id][count($session['xml'][$elemtype][$id])-1]); $uploadxml = str_replace('generator="OpenStreetMap server"', 'generator="osm mini tag editor"', $uploadxml); $uploadxml = preg_replace('/(\\ so $xmlo['lon'], $xmlo['lat'], $xmlo['uid'] $xmlo->tag[$i]->tag['k'] $xmlo->tag[$i]->tag['v'] */ $xmlo = simplexml_load_string($xml); if (empty($xmlo->$elemtype)) { $result = -4; break; } $uid = $xmlo->{$elemtype}['id']; if ($uid != $id) { /* problem */ $result = -2; break; } $tags = array(); foreach ($xmlo->{$elemtype}->tag as $tag) { $tags[(string)$tag['k']] = str_replace("\n", "\\n", (string)$tag['v']); } break; } function setlogincookie($user, $password) { global $cookiename; $expire = time() + 60*60*24* 30 /* days */; /* the last parameter '/' means cookie available site wide */ setcookie("{$cookiename}[un]", $user, $expire, '/'); setcookie("{$cookiename}[up]", $password, $expire, '/'); } function clearlogincookie() { global $cookiename; $expire = time(); setcookie("{$cookiename}[un]", '', $expire, '/'); /* delete cookie */ setcookie("{$cookiename}[up]", '', $expire, '/'); /* delete cookie */ } ?> OpenStreetMap mini tag editor ''); foreach ($mapfeatures as $category => $features) { foreach($features as $feature) { if ($feature{0} == '(') { $feature = preg_replace('/\\(.*\\)/', '', $feature); $ks = "{$category}-{$feature}"; $mapfeatureoptions[$ks] = array($ks, "{$category}={$feature}"); } else { $ks = "{$feature}-{$category}"; $mapfeatureoptions[$ks] = array($ks, "{$feature} ({$category})"); } } $mapfeatureoptions["{$category}-"] = array("-{$category}", "{$category}=..."); } ksort($mapfeatureoptions); $xmlinhtml = empty($debug) ? '' : "

" . htmlspecialchars($xml, ENT_QUOTES, 'UTF-8') . "

"; $mapfeatureoptionssize = count($mapfeatureoptions); $arrs = "

OpenStreetMap mini tag editor

",$message,"\n"; } switch($result) { case 401: // authentication failed case 'need_login': ?>

please log in

email address: 
OSM password: 
remember password: 

Your OSM password is needed to collect data from and submit data to the OSM server.

If you tick the 'remember password' box your email address and password will be stored in a cookie on your PC's disk. This means you won't need to re-enter it here again. You can clear it later.

Otherwise your email and password will only be stored on the mini-editor server for the duration of your session (that is, until a few minutes after you stop using it or you explicitly log out).

Passwords are sent in clear text both between your browser and the mini-editor server and from there to the OpenStreetMap server.

ids don't match '", $uid, "' '", $id, "'

\n"; break; case 'no_id': echo "\n"; break; case -3: echo "

no node

"; break; case 500: ?>

This will forget your email and password both on the server and remove any login cookie.

server returned error {$result} for url " . htmlspecialchars($url, ENT_QUOTES, 'UTF-8') . "\n"; echo htmlspecialchars($xml, ENT_QUOTES, 'UTF-8'); break; case 200: // normal response $name = empty($tags['name']) ? '' : ' - ' . htmlspecialchars($tags['name'], ENT_QUOTES, 'UTF-8'); $timestamp = str_replace('T', ' ', $xmlo->{$elemtype}['timestamp']); $s = "

for {$elemtype} {$id}{$name}:
\n"; if ($elemtype == 'way') { $s .= "bear in mind that streets, buildings etc may be made up of more than one way, so it may not be sufficient just to edit this one
\n"; } if (isset ($xmlo->node['lat'])) { $s .= "at latitude {$xmlo->node['lat']}, longitude {$xmlo->node['lon']}
\n"; $url = "http://www.openstreetmap.org?index.html?lat={$xmlo->node['lat']}&lon={$xmlo->node['lon']}&zoom=15"; $s .= "" . htmlspecialchars($url, ENT_QUOTES, 'UTF-8') . "
\n"; } else if (isset ($xmlo->way)) { $s .= "nodes: "; if (empty($xmlo->way->nd)) { $s .= "NONE!
\n"; } else { $prefix = ''; foreach($xmlo->way->nd as $node) { $s .= "{$prefix}{$node['ref']}"; $prefix = ', '; } $s .= "
\n"; } } $person = $xmlo->{$elemtype}['user']; $s .=<<
{$xmlinhtml}
key
(delete a key to remove the tag)
value
   EOD; if (isset($session['xml'][$elemtype][$id]) && count($session['xml'][$elemtype][$id]) > 1) { $s .= << EOD; } $s .= <<

On Update the database will be changed to reflect the new node contents (all being well) and then the node will be fetched again into this form for confirmation

Logged in as {$userhtml}. The Logout button will forget your email and password on the server and clear any login cookie on your own computer.

EOD; echo $s; break; } ?>