Example #1
0
 public function delete_index()
 {
     if (Input::getPath()->part(4) === "schema") {
         $response = $this->auth(null, array());
         if (!$response['success']) {
             return $response;
         }
         $dir = App::$param['path'] . "app/tmp/" . Connection::$param["postgisdb"] . "/" . Input::getPath()->part(5) . ".*";
     } else {
         $parts = explode(".", Input::getPath()->part(4));
         $layer = $parts[0] . "." . $parts[1];
         $response = $this->auth(Input::getPath()->part(4), array("all" => true, "write" => true));
         if (!$response['success']) {
             return $response;
         }
         $dir = App::$param['path'] . "app/tmp/" . Connection::$param["postgisdb"] . "/" . $layer;
     }
     $dir = str_replace("..", "", $dir);
     //$dirReal = realpath($dir); // Do not work on *
     if ($dir) {
         exec("rm -R {$dir}");
         if (strpos($dir, ".*") !== false) {
             $dir = str_replace(".*", "", $dir);
             exec("rm -R {$dir}");
         }
         $respons['success'] = true;
         $respons['message'] = "Tile cache deleted";
     } else {
         $respons['success'] = false;
         $respons['message'] = "No tile cache to delete.";
     }
     return Response::json($respons);
 }
Example #2
0
 function __construct()
 {
     $this->db = \app\inc\Input::getPath()->part(2);
     $dbSplit = explode("@", $this->db);
     if (sizeof($dbSplit) == 2) {
         $this->db = $dbSplit[1];
     }
     if ($_SESSION['http_auth'] != $this->db) {
         //error_log("WMS-C auth");
         \app\models\Database::setDb($this->db);
         $postgisObject = new \app\inc\Model();
         if ($_SERVER["QUERY_STRING"]) {
             $auth = $postgisObject->getGeometryColumns(\app\inc\Input::get("LAYERS"), "authentication");
         } else {
             $parts = explode("/", $_SERVER['REQUEST_URI']);
             $auth = $postgisObject->getGeometryColumns($parts[4], "authentication");
         }
         if ($auth == "Read/write" || $auth == "Write") {
             include 'inc/http_basic_authen.php';
         }
         $_SESSION['http_auth'] = $this->db;
     }
     if ($_SERVER["QUERY_STRING"]) {
         $this->get_wms();
     } else {
         $this->get_tms();
     }
 }
Example #3
0
 public function get_index()
 {
     $q = Input::getPath()->part(5);
     $split = explode(".", $q);
     if (sizeof($split) == 1) {
         return $this->layers->getAll($q, null, Session::isAuth(), Input::get("iex"), Input::get("parse"), Input::get("es"));
     } else {
         return $this->layers->getAll(null, $q, Session::isAuth(), Input::get("iex"), Input::get("parse"), Input::get("es"));
     }
 }
Example #4
0
 function get_index()
 {
     $postgisschema = \app\inc\Input::getPath()->part(5);
     $cartomobile = new \app\models\Cartomobile();
     header('Content-Type: text/xml');
     echo '<MobileConfiguration xmlns="http://www.cluetrust.com/XML/C11aMobileConfig/1/0">
     <!--Created by MapCentia-->';
     echo $cartomobile->getXml($postgisschema);
     echo '</MobileConfiguration>';
 }
Example #5
0
 function __construct()
 {
     if (\app\inc\Input::getPath()->part(3) == "tilecache") {
         $postgisschema = \app\inc\Input::getPath()->part(4);
     } else {
         $postgisschema = \app\inc\Input::getPath()->part(3);
     }
     $db = \app\inc\Input::getPath()->part(2);
     $dbSplit = explode("@", $db);
     if (sizeof($dbSplit) == 2) {
         $db = $dbSplit[1];
     }
     $path = App::$param['path'] . "/app/wms/mapfiles/";
     $name = $db . "_" . $postgisschema . ".map";
     $oMap = new \mapObj($path . $name);
     $request = new \OWSRequestObj();
     if ($_SERVER['REQUEST_METHOD'] === 'GET') {
         foreach ($_GET as $k => $v) {
             if (strtolower($k) == "layers" || strtolower($k) == "layer" || strtolower($k) == "typename" || strtolower($k) == "typenames") {
                 $layers = $v;
             }
             $request->setParameter($k, $v);
         }
     } else {
         $request->loadParams();
     }
     if ($_SESSION['http_auth'] != $db) {
         \app\models\Database::setDb($db);
         $postgisObject = new \app\inc\Model();
         foreach (explode(",", $layers) as $layer) {
             $auth = $postgisObject->getGeometryColumns($layer, "authentication");
             $layerSplit = explode(".", $layer);
             $HTTP_FORM_VARS["TYPENAME"] = $layerSplit[1];
             if ($auth == "Read/write") {
                 include 'inc/http_basic_authen.php';
             } else {
                 include 'inc/http_basic_authen_subuser.php';
             }
         }
     }
     ms_ioinstallstdouttobuffer();
     $oMap->owsdispatch($request);
     $contenttype = ms_iostripstdoutbuffercontenttype();
     if ($contenttype == 'image/png') {
         header('Content-type: image/png');
     } else {
         header('Content-type: text/xml');
     }
     ms_iogetStdoutBufferBytes();
     print "<!--\n";
     include "README";
     print "\n-->\n";
     ms_ioresethandlers();
 }
Example #6
0
 static function add($uri, $func = "", $silent = false)
 {
     $time_start = Util::microtime_float();
     $requestUri = strtok($_SERVER["REQUEST_URI"], '?');
     if (strpos($requestUri, $uri) !== false) {
         if ($func) {
             $func();
         }
         $uri = trim($uri, "/");
         $e = explode("/", $uri);
         $e[count($e) - 1] = ucfirst($e[count($e) - 1]);
         $uri = implode($e, "/");
         $n = sizeof($e);
         $className = strtr($uri, '/', '\\');
         $class = "app\\{$className}";
         $action = Input::getMethod() . "_" . Input::getPath()->part($n + 1);
         if (class_exists($class)) {
             $controller = new $class();
             if (method_exists($controller, $action)) {
                 $response = $controller->{$action}();
             } else {
                 $action = Input::getMethod() . "_index";
                 if (method_exists($controller, $action)) {
                     $response = $controller->{$action}();
                 } else {
                     header('HTTP/1.0 404 Not Found');
                     echo "<h1>404 Not Found</h1>";
                     exit;
                 }
             }
         }
         //header('charset=utf-8');
         //header('Content-Type: text/plain; charset=utf-8');
         $code = isset($response["code"]) ? $response["code"] : "200";
         header("HTTP/1.0 {$code} " . Util::httpCodeText($code));
         if (isset($response["json"])) {
             echo Response::passthru($response["json"]);
         } else {
             if (!$silent) {
                 $response["_execution_time"] = round(Util::microtime_float() - $time_start, 3);
                 echo Response::toJson($response);
             }
         }
         exit;
     }
 }
Example #7
0
 public function post_index()
 {
     $content = urldecode(Input::get());
     $obj = json_decode($content);
     $query = $obj->body->query->filtered->query->query_string->query;
     $split = explode(" ", $query);
     if ($split[0] != $_SESSION["screen_name"]) {
         die("What");
     }
     $ch = curl_init($this->host . "/data");
     curl_setopt($ch, CURLOPT_HEADER, false);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
     $buffer = curl_exec($ch);
     curl_close($ch);
     $response['json'] = $buffer;
     return $response;
 }
Example #8
0
 function __construct()
 {
     if (\app\inc\Input::getPath()->part(3) == "tilecache") {
         $postgisschema = \app\inc\Input::getPath()->part(4);
     } else {
         $postgisschema = \app\inc\Input::getPath()->part(3);
     }
     $db = \app\inc\Input::getPath()->part(2);
     $dbSplit = explode("@", $db);
     if (sizeof($dbSplit) == 2) {
         $db = $dbSplit[1];
     }
     $path = App::$param['path'] . "/app/wms/mapfiles/";
     $name = $db . "_" . $postgisschema . ".map";
     $oMap = new \mapObj($path . $name);
     $request = new \OWSRequestObj();
     if ($_SERVER['REQUEST_METHOD'] === 'GET') {
         foreach ($_GET as $k => $v) {
             if (strtolower($k) == "layers" || strtolower($k) == "layer" || strtolower($k) == "typename" || strtolower($k) == "typenames") {
                 $layers = $v;
             }
             $request->setParameter($k, $v);
         }
     } else {
         $request->loadParams();
     }
     if ($_SESSION['http_auth'] != $db) {
         \app\models\Database::setDb($db);
         $postgisObject = new \app\inc\Model();
         foreach (explode(",", $layers) as $layer) {
             $auth = $postgisObject->getGeometryColumns($layer, "authentication");
             $layerSplit = explode(".", $layer);
             $HTTP_FORM_VARS["TYPENAME"] = $layerSplit[1];
             if ($auth == "Read/write") {
                 include 'inc/http_basic_authen.php';
             } else {
                 include 'inc/http_basic_authen_subuser.php';
             }
         }
     }
     if ($_GET['sql_layer']) {
         include '../libs/functions.php';
         include '../conf/main.php';
         $postgisdb = "mydb";
         $request->setParameter("SLD_BODY", "<StyledLayerDescriptor version='1.1.0'><NamedLayer><Name>sql</Name><UserStyle><Title>xxx</Title><FeatureTypeStyle><Rule><LineSymbolizer><Stroke><CssParameter name='stroke'>#FFFF00</CssParameter><CssParameter name='stroke-width'>15</CssParameter></Stroke></LineSymbolizer></Rule></FeatureTypeStyle></UserStyle></NamedLayer></StyledLayerDescriptor>\n                ");
         $postgisObj = new postgis();
         $postgisObj2 = new postgis();
         $view = "public.hello";
         $sqlView = "CREATE VIEW {$view} as " . urldecode($_GET['sql_layer']);
         $postgisObj->connect();
         $postgisObj->execQuery($sqlView);
         $postgisObj->execQuery("CREATE SEQUENCE _serial START 1");
         $arrayWithFields = $postgisObj2->getMetaData($view);
         foreach ($arrayWithFields as $key => $arr) {
             if ($arr['type'] == "geometry") {
                 $fieldsArr[] = "transform(" . $key . ",900913) as the_geom";
             } else {
                 $fieldsArr[] = $key;
             }
         }
         $fieldsArr[] = "nextval('_serial') as _serial";
         $sql = implode(",", $fieldsArr);
         $sql = "SELECT {$sql} FROM {$view}";
         $request->setParameter("LAYERS", $_GET['LAYERS'] . ",sql");
         $layer = ms_newLayerObj($oMap);
         $layer->updateFromString("\n\tLAYER\n\t\tNAME 'sql'\n\t\tSTATUS off\n\t\tPROCESSING 'CLOSE_CONNECTION=DEFER'\n\t\tDATA \"the_geom from ({$sql}) as foo using unique _serial using srid=900913\"\n\t\tTYPE POLYGON\n\t\tCONNECTIONTYPE POSTGIS\n\t\tCONNECTION 'user=postgres dbname=mydb host=127.0.0.1'\n\t\tMETADATA\n\t\t  'wms_title'    'sql'\n\t\t  'wms_srs'    'EPSG:4326'\n\t\t  'wms_name'    'sql'\n\t\tEND\n\t\tPROJECTION\n\t\t  'init=epsg:900913'\n\t\tEND\n\t\tCLASS\n\t\t  NAME 'New style'\n\t\t  STYLE\n\t\t\tOUTLINECOLOR 255 0 0\n\t\t  END\n  \t\tEND\n  \tEND\n\t");
     }
     ms_ioinstallstdouttobuffer();
     $oMap->owsdispatch($request);
     if ($_GET['sql_layer']) {
         $sql = "DROP VIEW {$view}";
         $result = $postgisObj->execQuery($sql);
     }
     $contenttype = ms_iostripstdoutbuffercontenttype();
     if ($contenttype == 'image/png') {
         header('Content-type: image/png');
     } else {
         header('Content-type: text/xml');
     }
     ms_iogetStdoutBufferBytes();
     ms_ioresethandlers();
 }
    }
    if (is_null($username)) {
        header('WWW-Authenticate: Basic realm="' . Input::getPath()->part(2) . '"');
        header('HTTP/1.0 401 Unauthorized');
        header("Cache-Control: no-cache, must-revalidate");
        // HTTP/1.1
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
        // Date in the past
        // Text to send if user hits Cancel button
        die("Could not authenticate you 1");
    } elseif ($username != Input::getPath()->part(2)) {
        header('WWW-Authenticate: Basic realm="' . Input::getPath()->part(2) . '"');
        header('HTTP/1.0 401 Unauthorized');
        header("Cache-Control: no-cache, must-revalidate");
        // HTTP/1.1
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
        // Date in the past
        // Text to send if user hits Cancel button
        die("Could not authenticate you 2");
    } elseif (\app\models\Setting::encryptPw($password) != $response['data']['pw']) {
        header('WWW-Authenticate: Basic realm="' . Input::getPath()->part(2) . '"');
        header('HTTP/1.0 401 Unauthorized');
        header("Cache-Control: no-cache, must-revalidate");
        // HTTP/1.1
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
        // Date in the past
        die("Could not authenticate you 3");
    } else {
        $_SESSION['http_auth'] = $db;
    }
}
Example #10
0
 public function put_index()
 {
     $response = $this->auth(Input::getPath()->part(4));
     return !$response['success'] ? $response : $this->wmslayer->update(Input::get('data'));
 }
Example #11
0
                           value="<?php 
echo \app\conf\App::$param['protocol'] ?: "http";
?>
://<?php 
echo $_SERVER['HTTP_HOST'];
?>
/wms/mydb/tilecache/1.0.0/{layer}"
                           />
                </td>
            </tr>
            <tr>
                <td>Eg. <?php 
echo $_SERVER['HTTP_HOST'];
?>
/wms/mydb/tilecache/1.0.0/<?php 
echo \app\inc\Input::getPath()->part(3) ?: "public";
?>
.mylayer</td>
            </tr>
            </tbody>
        </table>
    </div>
    <div id="sql-dialog">
        <table border="0">
            <tbody>
            <tr>
                <td>The HTTP SQL API end point.</td>
            </tr>
            <tr>
                <td>
                    <input type="text" readonly="readonly"
Example #12
0
 public function get_index($lifetime = 0)
 {
     return $this->tweet->search(urldecode(Input::get('search')), Input::get('store'), Input::getPath()->part(5));
 }
Example #13
0
 public function put_table()
 {
     $response = $this->auth(null, array());
     return !$response['success'] ? $response : $this->osm->create(json_decode(Input::get(null, true)), true);
 }
Example #14
0
 public function get_checkcolumn()
 {
     return $this->table->checkcolumn(Input::getPath()->part(5));
 }
Example #15
0
 public function get_html()
 {
     $db = Input::getPath()->part(5);
     $baseLayer = Input::get("baselayer");
     $bits = explode(".", $baseLayer);
     if (sizeof($bits) == 1) {
         $baseLayer = "geocloud.{$baseLayer}";
     } else {
         $baseLayer = "'{$baseLayer}'";
     }
     if (Input::get("layers")) {
         $layers = json_encode(explode(",", Input::get("layers")));
     } else {
         $layers = null;
     }
     $center = str_replace('"', '', json_encode(explode(",", Input::get("center"))));
     $zoom = Input::get("zoom");
     $size = explode("x", Input::get("size"));
     $bbox = Input::get("bbox");
     $sql = Input::get("sql");
     echo "\n        <script src='/js/leaflet/leaflet.js'></script>\n        <script src='/js/openlayers/proj4js-combined.js'></script>\n        <script src='" . \app\conf\App::$param['host'] . "/api/v3/js/geocloud.js'></script>\n        <div id='map' style='width: {$size[0]}px; height: {$size[1]}px'></div>\n        <style>\n        body {margin: 0px; padding: 0px;}\n        .leaflet-control-zoom{display: none}\n        .leaflet-control-attribution{white-space: nowrap;}\n        </style>\n        <script>\n            (function () {\n                var map = new geocloud.map({\n                    el: 'map'\n                });\n                map.bingApiKey = '" . \app\conf\App::$param['bingApiKey'] . "'\n                map.addBaseLayer({$baseLayer});\n                map.setBaseLayer({$baseLayer});";
     if (!$sql) {
         if ($bbox) {
             $bboxArr = explode(",", Input::get("bbox"));
             $bbox = "[{$bboxArr[0]},{$bboxArr[1]},{$bboxArr[2]},{$bboxArr[3]}]";
             echo "map.zoomToExtent({$bbox});";
         } else {
             echo "map.setView({$center},{$zoom});";
         }
     } else {
         echo "\n                var store = new geocloud.sqlStore({\n                    db: '{$db}',\n                    sql: '" . rawurlencode($sql) . "',\n                    async: false\n                });\n                map.addGeoJsonStore(store);\n                store.load();\n                map.zoomToExtentOfgeoJsonStore(store);";
     }
     if ($layers) {
         echo "\n                map.addTileLayers({\n                    db: '{$db}',\n                    layers: {$layers}\n                });";
     }
     echo "}())";
     echo "</script>";
     exit;
 }
Example #16
0
 public function put_index()
 {
     return $this->workflow->touch(Input::getPath()->part(3), Input::getPath()->part(4), Input::getPath()->part(5), $_SESSION['subuser']);
 }
Example #17
0
 public function post_index()
 {
     //die(Input::get());
     $content = json_decode(Input::get(), true);
     return $this->collector->store($content);
 }
Example #18
0
 public function post_start()
 {
     return $this->session->start(Input::get("u"), Input::get("p"));
 }
Example #19
0
 public function get_createschema()
 {
     $response = $this->auth();
     return !$response['success'] ? $response : $this->db->createSchema(Input::get('schema'));
 }
Example #20
0
 private function transaction($sql, $clientEncoding = null)
 {
     $parsedSQL = \app\inc\SqlParser::ParseString($sql)->getArray();
     if ($parsedSQL['from']) {
         if (strpos(strtolower($parsedSQL['from']), 'settings.') !== false || strpos(strtolower($parsedSQL['from']), 'geometry_columns') !== false) {
             $this->response['success'] = false;
             $this->response['message'] = "Can't complete the query";
             $this->response['code'] = 406;
             return serialize($this->response);
         }
     }
     if (strpos($sql, ';') !== false) {
         $this->response['success'] = false;
         $this->response['code'] = 403;
         $this->response['message'] = "You can't use ';'. Use the bulk transaction API instead";
     } elseif (strpos($sql, '--') !== false) {
         $this->response['success'] = false;
         $this->response['code'] = 403;
         $this->response['message'] = "SQL comments '--' are not allowed";
     } elseif ($parsedSQL['drop']) {
         $this->response['success'] = false;
         $this->response['code'] = 403;
         $this->response['message'] = "DROP is not allowed through the API";
     } elseif ($parsedSQL['alter']) {
         $this->response['success'] = false;
         $this->response['code'] = 403;
         $this->response['message'] = "ALTER is not allowed through the API";
     } elseif ($parsedSQL['create']) {
         if (strpos(strtolower($parsedSQL['create']), 'create view') !== false) {
             if ($this->apiKey == Input::get('key') && $this->apiKey != false) {
                 $api = new \app\models\Sql();
                 $this->response = $api->transaction($this->q);
             } else {
                 $this->response['success'] = false;
                 $this->response['message'] = "Not the right key!";
                 $this->response['code'] = 403;
             }
         } else {
             $this->response['success'] = false;
             $this->response['message'] = "Only CREATE VIEW is allowed through the API";
             $this->response['code'] = 403;
         }
     } elseif ($parsedSQL['update'] || $parsedSQL['insert'] || $parsedSQL['delete']) {
         if ($this->apiKey == Input::get('key') && $this->apiKey != false) {
             $api = new \app\models\Sql();
             $this->response = $api->transaction($this->q);
         } else {
             $this->response['success'] = false;
             $this->response['message'] = "Not the right key!";
             $this->response['code'] = 403;
         }
     } elseif ($parsedSQL['select']) {
         $lifetime = Input::get('lifetime') ?: 0;
         $options = array('cacheDir' => \app\conf\App::$param['path'] . "app/tmp/", 'lifeTime' => $lifetime);
         $Cache_Lite = new \Cache_Lite($options);
         if ($this->data = $Cache_Lite->get($this->q)) {
             //echo "Cached";
         } else {
             //echo "Not cached";
             ob_start();
             $srs = Input::get('srs') ?: "900913";
             $api = new \app\models\Sql($srs);
             $this->response = $api->sql($this->q, $clientEncoding);
             echo serialize($this->response);
             // Cache script
             $this->data = ob_get_contents();
             $Cache_Lite->save($this->data, $this->q);
             ob_get_clean();
         }
     } else {
         $this->response['success'] = false;
         $this->response['message'] = "Check your SQL. Could not recognise it as either SELECT, INSERT, UPDATE or DELETE";
         $this->response['code'] = 400;
     }
     return serialize($this->response);
 }
Example #21
0
 public function put_copy()
 {
     $response = $this->auth(Input::getPath()->part(4));
     return !$response['success'] ? $response : $this->class->copyClasses(Input::getPath()->part(4), Input::getPath()->part(5));
 }
Example #22
0
 public function delete_index()
 {
     $response = $this->auth(null, array(), true);
     // Never sub-user
     return !$response['success'] ? $response : $this->job->deleteJob(json_decode(Input::get(null, true)));
 }
Example #23
0
include "libs/PEAR/XML/Unserializer.php";
include "libs/PEAR/XML/Serializer.php";
include "libs/PEAR/Cache_Lite/Lite.php";
include 'convertgeom.php';
include 'explodefilter.php';
if (!$gmlNameSpace) {
    $gmlNameSpace = Connection::$param["postgisdb"];
}
if (!$gmlNameSpaceUri) {
    $gmlNameSpaceUri = "http://twitter/" . Connection::$param["postgisdb"];
}
$postgisdb = Connection::$param["postgisdb"];
$postgisschema = Connection::$param["postgisschema"];
$layerObj = new Layer();
$srs = \app\inc\Input::getPath()->part(4);
$timeSlice = \app\inc\Input::getPath()->part(5);
if ($timeSlice != "all") {
    $unixTime = strtotime(urldecode($timeSlice));
    if ($unixTime) {
        $timeSlice = date("Y-m-d G:i:s.u", $unixTime);
    } else {
        $timeSlice = false;
    }
}
$postgisObject = new \app\inc\Model();
$geometryColumnsObj = new \app\controllers\Layer();
function microtime_float()
{
    list($utime, $time) = explode(" ", microtime());
    return (double) $utime + (double) $time;
}
Example #24
0
 public function get_usergroups()
 {
     return $this->settings->updateUserGroups(json_decode(Input::get("q"))->data);
 }
Example #25
0
    new \app\controllers\Wms();
} elseif (Input::getPath()->part(1) == "wmsc") {
    Session::start();
    new \app\controllers\Wmsc();
} elseif (Input::getPath()->part(1) == "wfs") {
    Session::start();
    $db = Input::getPath()->part(2);
    $dbSplit = explode("@", $db);
    if (sizeof($dbSplit) == 2) {
        $db = $dbSplit[1];
        $user = $dbSplit[0];
        $parentUser = false;
    } else {
        $user = $db;
        $parentUser = true;
    }
    Database::setDb($db);
    Connection::$param["postgisschema"] = Input::getPath()->part(3);
    include_once "app/wfs/server.php";
} elseif (!Input::getPath()->part(1)) {
    if (App::$param["redirectTo"]) {
        \app\inc\Redirect::to(App::$param["redirectTo"]);
    } else {
        \app\inc\Redirect::to("/user/login");
    }
} else {
    header('HTTP/1.0 404 Not Found');
    echo "<h1>404 Not Found</h1>";
    echo "The page that you have requested could not be found.";
    exit;
}
Example #26
0
 public function put_roles()
 {
     $response = $this->auth(null, array());
     return !$response['success'] ? $response : $this->table->updateRoles(json_decode(Input::get())->data);
 }
Example #27
0
 public function delete_data()
 {
     $data = (array) json_decode(urldecode(Input::get(null, true)));
     $this->table = new \app\models\table(Input::getPath()->part(4));
     $key = Input::getPath()->part(5);
     $response = $this->auth(Input::getPath()->part(6), array("write" => true, "all" => true));
     return !$response['success'] ? $response : $this->table->deleteRecord($data, $key);
 }
Example #28
0
 public function put_upsert()
 {
     $put = Input::get();
     if ($response = $this->checkAuth(Input::getPath()->part(5), $put['key'])) {
         return $response;
     }
     $schema = Input::getPath()->part(6);
     $table = Input::getPath()->part(7);
     $priKey = Input::getPath()->part(8);
     $id = Input::getPath()->part(9);
     $index = $schema;
     $type = $table;
     $db = Input::getPath()->part(5);
     $fullTable = $schema . "." . $table;
     $fullIndex = $db . "_" . $index;
     if (mb_substr($type, 0, 1, 'utf-8') == "_") {
         $type = "a" . $type;
     }
     $sql = "SELECT * FROM {$fullTable} WHERE \"{$priKey}\"=" . $id;
     $api = new \app\models\Sql_to_es("4326");
     $api->execQuery("set client_encoding='UTF8'", "PDO");
     $res = $api->sql($sql, $index, $type, $priKey, $db);
     if (!$res["success"]) {
         return $res;
     }
     $res["_index"] = $fullIndex;
     $res["_type"] = $type;
     $res["_id"] = $id;
     return $res;
 }
Example #29
0
 public function get_index()
 {
     $layer = Input::getPath()->part(5);
     $extent = Input::getPath()->part(6) ?: "4326";
     return $this->layers->getExtent($layer, $extent);
 }
Example #30
0
 public function get_run()
 {
     $response = $this->auth(null, array(), true);
     // Never sub-user
     return !$response['success'] ? $response : $this->job->runJob(Input::getPath()->part(4), $_SESSION['screen_name']);
 }