<?php require '../lib/config.php'; require '../lib/db/pie_geometry.php'; $id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT); try { $pie_geometry = new PieGeometry(); $pie_geometry->load_from_db($id); // header("Content-type: text/plain"); // echo $pie_geometry->dump(); // var_dump($pie_geometry); header("Content-type: application/binary"); header("Content-Disposition: attachment; filename=\"mapcraft-cake-" . $id . ".osm\""); echo $pie_geometry->export_to_osm(); } catch (Exception $e) { header("HTTP/1.1 500 Internal Server Error"); header("Content-type: text/plain"); echo $e->getMessage(); }
<?php exit; } // // Actually creating process // $result = pg_query_params($connection, 'INSERT INTO pies (name, author, description, visible) VALUES ($1, $2, $3, $4) RETURNING id', array($_POST['name'], $user_id, htmlspecialchars($_POST['description']), isset($_POST['hide']) ? '0' : '1')); $pie_id = pg_fetch_result($result, 0, 0); // Adding access for owner if (!pg_query_params($connection, "INSERT INTO access VALUES (\$1, \$2, '', 'o')", array($user_id, $pie_id))) { echo 'Failed to add access for owner. <br /><a href="javascript:history.back();">Back</a>'; exit; } try { $current = new PieGeometry(); $current->load_from_db($pie_id); $current->apply_steps($steps, $user_id); } catch (Exception $e) { ?> <div class="error"><?php echo $e->getMessage(); ?> </div> <p class="small"> If you are sure there is no error from your side, fill bug at <a href="https://github.com/Foxhind/MapCraft/issues?state=open" target="_blank">github.com/Foxhind/MapCraft/issues</a> and attach your osm file. </p> <p> Failed to create a file. <br /><a href="javascript:history.back();">Back</a> </p>
} $filename = tempnam('/tmp', 'uploaded-' . $id . '-'); if (!copy($_FILES['file']['tmp_name'], $filename)) { throw new Exception("Failed to save uploaded file"); } } else { // After second step the file is in hidden input field 'filename' pointing to tmp file $filename = filter_input(INPUT_POST, 'filename', FILTER_VALIDATE_REGEXP, array("options" => array("regexp" => "/^\\/tmp\\/uploaded-\\d+-\\w+\$/"))); } // // Parse file with modifications // $new = new PieGeometry(); $current = new PieGeometry(); $steps = array(); $current->load_from_db($id); $new->import_from_osm($filename); $steps = $current->get_update_steps($new); } catch (Exception $e) { ?> <div id="pageheader" style="background-color: #92836c;">Can't to parse a new cake</div> <div class="error"><?php echo $e->getMessage(); ?> </div> <p class="small"> If you are sure there is no error from your side, fill bug at <a href="https://github.com/Foxhind/MapCraft/issues?state=open" target="_blank">github.com/Foxhind/MapCraft/issues</a> and attach your modified cake. </p> <br/><p><form class="inline" action="" method="post" enctype="multipart/form-data">