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(); } }
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(); }
<?php use app\inc\Model; use app\conf\App; include "../header.php"; $postgisdb = $databaseTemplate; \app\models\Database::setDb("postgres"); if (!$_SESSION['screen_name']) { header("location: " . \app\conf\App::$param['userHostName'] . "/user/login/p"); die; } else { $name = Model::toAscii($_SESSION['screen_name'], NULL, "_"); $db = new \app\models\Database(); $dbObj = $db->createdb($name, App::$param['databaseTemplate'], "UTF8"); // databaseTemplate is set in conf/main.php if ($dbObj) { header("location: " . \app\conf\App::$param['userHostName'] . "/user/login/p"); } else { echo "<h2>Sorry, something went wrong. Try again</h2>"; echo "<div><a href='" . \app\conf\App::$param['userHostName'] . "/user/signup' class='btn btn-danger'>Go back</a></div>"; } }
$headers = get_headers(App::$param['host'] . "/cgi/tilecache.py?cfg=_gc2test", 1); if ($headers[0] == "HTTP/1.1 200 OK") { echo "<div class='alert alert-success'>TileCache is working</div>"; } else { echo "<div class='alert alert-error\t'>It seems that TileCache is not working</div>"; } $dbList = new Database(); try { $arr = $dbList->listAllDbs(); $i = 1; echo "<table class='table table-striped'>"; echo "<thead><tr><th>Databases</th><th>PostGIS</th><th>GC2 settings schema</th><th></th></tr></thead>"; foreach ($arr['data'] as $db) { if ($db != "template1" and $db != "template0" and $db != "postgres" and $db != "postgis_template") { echo "<tr><td>{$db}</td>"; Database::setDb($db); $dbc = new Dbcheck(); // Check if postgis is installed $checkPostGIS = $dbc->isPostGISInstalled(); if ($checkPostGIS['success']) { echo "<td style='color:green'>V</td>"; } else { echo "<td style='color:red'>X</td>"; } // Check if schema "settings" is loaded $checkMy = $dbc->isSchemaInstalled(); if ($checkMy['success']) { echo "<td style='color:green'>V"; $checkView = $dbc->isViewInstalled(); if (!$checkView['success']) { echo "<span style='margin-left:20px'>But view is missing</span>";
<?php include_once "../../../app/conf/App.php"; use app\conf\App; use app\inc\Session; new App(); Session::start(); \app\models\Database::setDb("mapcentia"); $sTable = 'users'; $prefix = $_SESSION['zone'] ? App::$param['domainPrefix'] . $_SESSION['zone'] . "." : ""; if (App::$param['domain']) { $host = "//" . $prefix . App::$param['domain'] . ":" . $_SERVER['SERVER_PORT']; } else { $host = App::$param['host']; } if (App::$param['cdnSubDomain']) { $bits = explode("://", $host); $cdnHost = $bits[0] . "://" . App::$param['cdnSubDomain'] . "." . $bits[1]; } else { $cdnHost = $host; }
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(); }
} else { print $cmd . "\n"; print_r($out); $sql = "UPDATE jobs SET lastcheck=:lastcheck WHERE id=:id"; $values = array(":lastcheck" => 0, ":id" => $jobId); } \app\models\Database::setDb("gc2scheduler"); $model = new \app\inc\Model(); $res = $model->prepare($sql); try { $res->execute($values); } catch (\PDOException $e) { print_r($e); } if ($extra) { \app\models\Database::setDb($db); $model = new \app\inc\Model(); $fieldObj = json_decode($extra); $fieldName = $fieldObj->name; $fieldType = $fieldObj->type ?: "varchar"; $fieldValue = $fieldObj->value; $sql = "ALTER TABLE \"{$schema}\".\"{$safeName}\" ADD COLUMN {$fieldName} {$fieldType}"; $res = $model->prepare($sql); try { $res->execute(); } catch (\PDOException $e) { print_r($e); } $sql = "UPDATE \"{$schema}\".\"{$safeName}\" SET {$fieldName} =:value"; $res = $model->prepare($sql); try {
public function get_exist() { \app\models\Database::setDb("postgres"); $this->db = new \app\models\Database(); return $this->db->doesDbExist(Input::getPath()->part(4)); }
} elseif (Input::getPath()->part(1) == "store") { Session::start(); Session::authenticate(App::$param['userHostName'] . "/user/login/"); $_SESSION['postgisschema'] = Input::getPath()->part(3) ?: "public"; include_once "store.php"; if (\app\conf\App::$param['intercom_io']) { include_once "../app/conf/intercom.js.inc"; } } elseif (Input::getPath()->part(1) == "editor") { Session::start(); Session::authenticate(App::$param['userHostName'] . "/user/login/"); include_once "editor.php"; } elseif (Input::getPath()->part(1) == "controllers") { Session::start(); Session::authenticate(null); Database::setDb($_SESSION['screen_name']); Connection::$param["postgisschema"] = $_SESSION['postgisschema']; Route::add("controllers/cfgfile"); Route::add("controllers/classification/"); Route::add("controllers/database/"); Route::add("controllers/layer/"); Route::add("controllers/mapfile"); Route::add("controllers/setting"); Route::add("controllers/table/"); Route::add("controllers/tile/"); Route::add("controllers/tilecache/"); Route::add("controllers/session/"); } elseif (Input::getPath()->part(1) == "wms" || Input::getPath()->part(1) == "ows") { Session::start(); new \app\controllers\Wms(); } elseif (!Input::getPath()->part(1)) {