Beispiel #1
0
            $errors = array('OK', _('too big'), _('bigger than MAX_FILE_SIZE'), _('partial upload'), _('no file'), '', _('nowhere to store'), _('failed to write'), _('extension error'));
            $error = sprintf(_('Error uploading file: %s.'), $errors[$_FILES['file']['error']]);
        } else {
            $url = $_FILES['file']['tmp_name'];
        }
    } elseif (isset($_REQUEST['url']) && strlen($_REQUEST['url']) > 0) {
        $url = url_to_api($_REQUEST['url']);
        if ($url === false) {
            $error = _('Could not parse the URL.');
        }
    } else {
        $error = isset($_REQUEST['replace']) ? _('Replace with what?') : _('Add what?');
    }
    if (isset($url) && $url) {
        $validation = array();
        update_data_array(is_array($url) ? $url : array($url));
    }
} elseif (isset($_REQUEST['clear'])) {
    clear_data();
    $text = '';
} elseif (isset($_REQUEST['revert'])) {
    $text = revert();
    $validation = array();
} elseif (isset($_REQUEST['download'])) {
    $e = prepare_export();
    if (is_array($e)) {
        $osm = create_osm($e);
        header("Cache-Control: no-cache, must-revalidate");
        header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
        header('Content-Type: application/x-openstreetmap+xml');
        header('Content-Disposition: attachment; filename=level0_export.osm');
Beispiel #2
0
function update_modified()
{
    global $error, $messages;
    $data = prepare_export();
    if (!is_array($data)) {
        $error = sprintf(_('Error preparing data: %s.'), $data);
        return;
    }
    $update = array('node' => array(), 'way' => array(), 'relation' => array());
    $count = 0;
    foreach ($data as $obj) {
        if (isset($obj['action']) && $obj['id'] > 0) {
            $update[$obj['type']][] = $obj['id'];
            $count++;
        }
    }
    if (!$count) {
        $error = _('Nothing is modified, not going to update everything');
        return;
    } elseif ($count > MAX_REQUEST_OBJECTS) {
        $messages = sprintf(ngettext('%d object was modified, can update only %d of them (repeat for more).', '%d objects were modified, can update only %d of them (repeat for more).', $count), $count, MAX_REQUEST_OBJECTS);
        $count = MAX_REQUEST_OBJECTS;
        foreach (array('relation', 'way', 'node') as $type) {
            if (count($update[$type]) > $count) {
                array_splice($update[$type], $count);
            }
            $count = max(0, $count - count($update[$type]));
        }
    }
    $urls = array();
    foreach ($update as $type => $ids) {
        if (count($ids)) {
            $urls[] = OSM_API_URL . $type . 's?' . $type . 's=' . implode(',', $ids);
        }
    }
    update_data_array($urls);
}