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(); } }
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")); } }
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; }
public function get_index($lifetime = 0) { return $this->tweet->search(urldecode(Input::get('search')), Input::get('store'), Input::getPath()->part(5)); }
public function put_cluster() { $response = $this->auth(Input::getPath()->part(4)); return !$response['success'] ? $response : $this->class->createCluster(Input::getPath()->part(5), json_decode(urldecode(Input::get()))->data); }
public function put_index() { $response = $this->auth(Input::getPath()->part(4)); return !$response['success'] ? $response : $this->wmslayer->update(Input::get('data')); }
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; }
public function put_roles() { $response = $this->auth(null, array()); return !$response['success'] ? $response : $this->table->updateRoles(json_decode(Input::get())->data); }
public function get_usergroups() { return $this->settings->updateUserGroups(json_decode(Input::get("q"))->data); }
public function delete_columns() { $response = $this->auth(Input::getPath()->part(5)); return !$response['success'] ? $response : $this->table->deleteColumn(json_decode(Input::get())->data, null, Input::getPath()->part(5)); }
public function get_quantile() { $this->class = new \app\models\Classification(Input::get("l")); return $this->class->createQuantile(Input::get("f"), Input::get("n"), "#" . Input::get(s), "#" . Input::get(e), null, false); }
public function post_index() { //die(Input::get()); $content = json_decode(Input::get(), true); return $this->collector->store($content); }
public function post_start() { return $this->session->start(Input::get("u"), Input::get("p")); }
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); }
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))); }
public function get_createschema() { $response = $this->auth(); return !$response['success'] ? $response : $this->db->createSchema(Input::get('schema')); }
public function put_table() { $response = $this->auth(null, array()); return !$response['success'] ? $response : $this->osm->create(json_decode(Input::get(null, true)), true); }
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; }
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); }
public function post_index() { return $this->drawing->save(Input::get(), $this->username); }