コード例 #1
0
ファイル: search.php プロジェクト: nickw1/Freemap
<?php

require_once 'DataGetter.php';
require_once 'DBDetails.php';
require_once '../../lib/functionsnew.php';
require_once 'xml.php';
header("Access-Control-Allow-Origin: http://www.fixmypaths.org");
$cleaned = clean_input($_GET, null);
$tbl_prefix = isset($cleaned["tbl_prefix"]) && preg_match("/^\\w+\$/", $cleaned["tbl_prefix"]) ? $cleaned["tbl_prefix"] : "planet_osm";
if (!isset($cleaned["q"]) || !preg_match("/^[\\w\\s-']+\$/", $cleaned["q"])) {
    header("HTTP/1.1 400 Bad Request");
    echo "Please specify a valid search term.";
} else {
    $format = isset($cleaned["format"]) && ctype_alpha($cleaned["format"]) ? $cleaned["format"] : "xml";
    if (isset($cleaned["outProj"]) && ctype_alnum($cleaned["outProj"])) {
        adjustProj($cleaned["outProj"]);
    }
    $ns = new NameSearch($cleaned["q"], $cleaned["outProj"], $tbl_prefix);
    $data = $ns->getData($cleaned);
    //,isset($cleaned['outProj'])?$cleaned['outProj']:null);
    switch ($cleaned["format"]) {
        case "json":
        case "geojson":
            header("Content-type: application/json");
            echo json_encode($data);
            break;
        default:
            header("Content-type: text/xml");
            to_xml($data);
            break;
    }
コード例 #2
0
ファイル: tsvr.php プロジェクト: nickw1/Freemap
require_once 'DataGetter.php';
require_once 'xml.php';
require_once 'DBDetails.php';
header("Access-Control-Allow-Origin: http://www.opentrailview.org");
define('CONTOUR_CACHE2', '/home/www-data/contourcache');
define('CACHE2', '/home/www-data/fmapcache2');
$cleaned = clean_input($_GET, null);
// DBDetails: poi way poly contour coast ann
$x = $cleaned["x"];
$y = $cleaned["y"];
$z = $cleaned["z"];
$tbl_prefix = isset($cleaned["tbl_prefix"]) ? $cleaned["tbl_prefix"] : "planet_osm";
$ext = isset($cleaned["ext"]) ? $cleaned["ext"] : 0;
$mftest = isset($cleaned["mftest"]) ? $cleaned["mftest"] : 0;
$outProj = isset($cleaned['outProj']) ? $cleaned['outProj'] : '3857';
adjustProj($outProj);
$kg = isset($cleaned["kg"]) ? $cleaned["kg"] : 1000;
if (!ctype_digit($x) || !ctype_digit($y) || !ctype_digit($z) || !ctype_alnum($outProj) || !preg_match("/^\\w+\$/", $tbl_prefix) || !ctype_digit($kg) || isset($cleaned["poi"]) && !preg_match("/^(\\w+,)*\\w+\$/", $cleaned["poi"]) || isset($cleaned["way"]) && !preg_match("/^(\\w+,)*\\w+\$/", $cleaned["way"]) || isset($cleaned["kothic"]) && !ctype_digit($cleaned["kothic"]) || isset($cleaned["contour"]) && !ctype_digit($cleaned["contour"]) || isset($cleaned["coastline"]) && !ctype_digit($cleaned["coastline"])) {
    header("HTTP/1.1 400 Bad Request");
    echo "Invalid format for input data";
    exit;
}
$bbox = get_sphmerc_bbox($x, $y, $z);
if (isset($cleaned["kothic"]) && $cleaned["kothic"]) {
    $sw = sphmerc_to_ll($bbox[0], $bbox[1]);
    $ne = sphmerc_to_ll($bbox[2], $bbox[3]);
    if (!file_exists(CONTOUR_CACHE . "/{$kg}/{$z}/{$x}")) {
        mkdir(CONTOUR_CACHE . "/{$kg}/{$z}/{$x}", 0755, true);
    }
    if (!file_exists(CACHE . "/{$kg}/{$z}/{$x}")) {
        mkdir(CACHE . "/{$kg}/{$z}/{$x}", 0755, true);
コード例 #3
0
ファイル: annotation.php プロジェクト: nickw1/Freemap
<?php

require_once '../../lib/functionsnew.php';
require_once '../../lib/User.php';
require_once '../../lib/UserManager.php';
session_start();
$cget = clean_input($_GET, null);
$cpost = clean_input($_POST, null);
$inProj = isset($cpost['inProj']) && ctype_alnum($cpost['inProj']) ? $cpost['inProj'] : '4326';
adjustProj($inProj);
$expected = array("create" => array("lon", "lat", "text"), "createMulti" => array("data"), "delete" => array("id"), "deleteMulti" => array("ids"), "move" => array("id", "lat", "lon"));
$userid = 0;
// 0=not supplied; -1=incorrect
$conn = new PDO("pgsql:host=localhost;dbname=gis2;", "gis");
$um = new UserManager($conn);
$action = isset($cpost["action"]) && ctype_alpha($cpost["action"]) ? $cpost["action"] : "";
if (!isset($expected[$action])) {
    header("HTTP/1.1 400 Bad Request");
    exit;
} else {
    foreach ($expected[$action] as $field) {
        if (!isset($cpost[$field])) {
            header("HTTP/1.1 400 Bad Request");
            exit;
        }
    }
}
if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
    $row = $um->isValidLogin($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
    if ($row !== false) {
        $userid = $row["id"];