function add_mbtiles(&$dbh, $user_id, $url, $file_name, $file_path) { $mbtiles_data = get_mbtiles_data($file_path); $mbtiles_id = generate_id(); $q = sprintf('INSERT INTO mbtiles SET id = %s, user_id = %s, url = %s, uploaded_file = %s, min_zoom = %d, max_zoom = %d, center_zoom = %d, center_x_coord = %d, center_y_coord = %d', $dbh->quoteSmart($mbtiles_id), $dbh->quoteSmart($user_id), $dbh->quoteSmart($url), $dbh->quoteSmart($file_name), $dbh->quoteSmart($mbtiles_data['min_zoom']), $dbh->quoteSmart($mbtiles_data['max_zoom']), $dbh->quoteSmart($mbtiles_data["center_coordinates"]['zoom']), $dbh->quoteSmart($mbtiles_data["center_coordinates"]['x']), $dbh->quoteSmart($mbtiles_data["center_coordinates"]['y'])); error_log(preg_replace('/\\s+/', ' ', $q)); $res = $dbh->query($q); if (PEAR::isError($res)) { if ($res->getCode() == DB_ERROR_ALREADY_EXISTS) { continue; } die_with_code(500, "{$res->message}\n{$q}\n"); } return get_mbtiles_by_id($dbh, $mbtiles_id); }
<?php require_once '../lib/lib.everything.php'; $context = default_context(True); $filename = $_GET['filename'] ? $_GET['filename'] : null; $id = $_GET['id'] ? $_GET['id'] : null; $mbtiles_data = get_mbtiles_by_id($context->db, $id); $context->sm->assign('filename', $filename); $context->sm->assign('mbtiles_data', $mbtiles_data); print $context->sm->fetch("display_mbtiles.html.tpl");
header('HTTP/1.1 303'); header("Location: {$redirect_href}"); exit; } $latlon = array($latlonzoom[0], $latlonzoom[1]); $zoom = $latlonzoom[2]; } $context->sm->assign('center', join(',', $latlon)); $context->sm->assign('zoom', $zoom); $redirect_href = sprintf('http://%s%s/make-step2-geography.php?zoom=%s&lat=%s&lon=%s', get_domain_name(), get_base_dir(), $zoom, $latlon[0], $latlon[1]); header('HTTP/1.1 303'); header("Location: {$redirect_href}"); } if (isset($_GET) && !empty($_GET)) { if ($_GET['mbtiles_id']) { $mbtiles = get_mbtiles_by_id($context->db, $_GET['mbtiles_id']); $mbtiles_data = array("provider" => $mbtiles['url'], "uploaded_file" => $mbtiles['uploaded_file'], "center_x" => $mbtiles['center_x_coord'], "center_y" => $mbtiles['center_y_coord'], "zoom" => $mbtiles['center_zoom'], 'min_zoom' => $mbtiles['min_zoom'], 'max_zoom' => $mbtiles['max_zoom']); $context->sm->assign('mbtiles_data', $mbtiles_data); } elseif ($_GET['lat'] && $_GET['lon'] && $_GET['zoom']) { $center = array($_GET['lat'], $_GET['lon']); $zoom = $_GET['zoom']; $context->sm->assign('center', join(',', $center)); $context->sm->assign('zoom', $zoom); } else { $redirect_href = sprintf('http://%s%s/make-step1-search.php?error=no_response', get_domain_name(), get_base_dir()); header('HTTP/1.1 303'); header("Location: {$redirect_href}"); exit; } } $context->sm->assign('providers', get_map_providers());