Пример #1
0
 function __construct($table)
 {
     logfile::write($table . "\n");
     parent::__construct();
     preg_match("/^[\\w'-]*\\./", $table, $matches);
     $_schema = $matches[0];
     preg_match("/[\\w'-]*\$/", $table, $matches);
     $_table = $matches[0];
     if (!$_schema) {
         $table = $this->postgisschema . "." . $table;
     }
     logfile::write($table . "\n");
     $this->tableWithOutSchema = $_table;
     $sql = "select 1 from {$table}";
     $this->execQuery($sql);
     if ($this->PDOerror) {
         $this->exits = false;
     } else {
         $this->table = $table;
         $this->metaData = $this->getMetaData($this->table);
         $this->geomField = $this->getGeometryColumns($this->table, "f_geometry_column");
         $this->geomType = $this->getGeometryColumns($this->table, "type");
         $this->primeryKey = $this->getPrimeryKey($this->table);
         //$this->id = $this->getGeometryColumns($this->table, "id");
         $this->setType();
         $this->exits = true;
     }
 }
Пример #2
0
 function __construct($gmlSource)
 {
     parent::__construct();
     include_once "libs/class_xml_check.php";
     $check = new XML_check();
     if ($check->check_string($gmlSource)) {
         print "GML is well-formed\n";
         //print("Elements      : ".$check->get_xml_elements());
         //print("Attributes    : ".$check->get_xml_attributes());
         //print("Size          : ".$check->get_xml_size());
         //print("Text sections : ".$check->get_xml_text_sections());
         //print("Text size     : ".$check->get_xml_text_size());
     } else {
         print "GML is not well-formed. ";
         print $check->get_full_error() . "\n";
         print "Script terminated\n";
         die;
     }
     $this->gmlSource = $gmlSource;
     $this->gmlCon = new gmlConverter();
     require_once "XML/Unserializer.php";
     $unserializer_options = array('parseAttributes' => TRUE);
     $unserializer = new XML_Unserializer($unserializer_options);
     // Serialize the data structure
     $status = $unserializer->unserialize($this->gmlSource);
     $this->gmlArray = $unserializer->getUnserializedData();
     print date('l jS \\of F Y h:i:s A') . " GML serialized\n";
     // Check if XML is a ServiceException
     if ($unserializer->getRootName() == "ServiceExceptionReport") {
         print "The server returned an exception:\n";
         print $this->gmlSource . "\n";
         print "Script terminated\n";
         die;
     }
 }
 function __construct()
 {
     parent::__construct();
     $geometryColumnsObj = new table("settings.geometry_columns_view");
     $this->rows = $geometryColumnsObj->getRecords();
     $this->rows = $this->rows['data'];
 }
Пример #4
0
 function __construct($screenName, $userId = NULL, $tok = NULL, $sec = NULL)
 {
     parent::__construct();
     $this->screenName = $screenName;
     $this->postgisdb = "mygeocloud";
     $sql = "SELECT * FROM users WHERE screenname='{$screenName}'";
     $row = $this->fetchRow($this->execQuery($sql));
     if (!$row['screenname'] && $userId && $tok && $sec) {
         // We create twitter user if not exits
         $sql = "INSERT INTO users(userid,screenname,tok,sec) VALUES({$userId},'{$screenName}','{$tok}','{$sec}')";
         $result = $this->execQuery($sql);
         $this->userId = $userId;
         $this->tok = $tok;
         $this->sec = $sec;
     } elseif ($row['userid'] && $row['tok'] && $row['sec']) {
         // Twitter user exits
         $this->userId = $row['userid'];
         $this->tok = $row['tok'];
         $this->sec = $row['sec'];
     } elseif (!$row['screenname'] && !$userId && !$tok && !$sec) {
         $sql = "INSERT INTO users(userid,screenname,tok,sec) VALUES(NULL,'{$screenName}','NULL','NULL')";
         $result = $this->execQuery($sql);
         $this->userId = NULL;
         $this->tok = NULL;
         $this->sec = NULL;
     } elseif ($row['screenname']) {
         $this->userId = NULL;
         $this->tok = NULL;
         $this->sec = NULL;
     } else {
         //die("Could not init user object");
     }
 }
Пример #5
0
 /**
  *
  *
  * @param unknown $safeFile
  * @param unknown $srid
  * @param unknown $file
  * @param unknown $pdo
  */
 function __construct($safeFile, $srid, $file, $pdo)
 {
     parent::__construct();
     $this->safeFile = $safeFile;
     $this->srid = $srid;
     $this->file = $file;
     $this->pdo = $pdo;
     fb($pdo);
 }
Пример #6
0
 function __construct()
 {
     parent::__construct();
     $sql = "SELECT * FROM settings.geometry_columns_view order by sort_id";
     $result = $this->execQuery($sql);
     $this->rows = $this->fetchAll($result);
     /*
     $geometryColumnsObj = new table("settings.geometry_columns_view");
     $this->rows = $geometryColumnsObj->getRecords();
     $this->rows = $this->rows['data'];
     */
 }
Пример #7
0
function makeTileCacheFile($user, $extentLayer = NULL)
{
    //return;
    global $basePath;
    global $postgisdb;
    global $postgishost;
    global $postgispw;
    global $hostName;
    global $postgisschema;
    $postgisdb = $user;
    $table = $extentLayer;
    $postgisObject = new postgis();
    $srs = "900913";
    $geomField = $postgisObject->getGeometryColumns($table, "f_geometry_column");
    if ($extentLayer) {
        $sql = "SELECT xmin(EXTENT(transform(" . $geomField . ",{$srs}))) AS TXMin,xmax(EXTENT(transform(" . $geomField . ",{$srs}))) AS TXMax, ymin(EXTENT(transform(" . $geomField . ",{$srs}))) AS TYMin,ymax(EXTENT(transform(" . $geomField . ",{$srs}))) AS TYMax  FROM " . $table;
        $result = $postgisObject->execQuery($sql);
        //print_r($postgisObject->PDOerror);
        $row = $postgisObject->fetchRow($result);
    }
    ob_start();
    echo "[cache]\n";
    echo "type=Disk\n";
    echo "base={$basePath}/tmp/{$user}\n\n";
    //echo "type=AWSS3\n";
    //echo "access_key=AKIAIZUYE3I462NPVANQ\n";
    //echo "secret_access_key=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\n";
    $sql = "SELECT * FROM settings.geometry_columns_view";
    //echo $sql;
    $result = $postgisObject->execQuery($sql);
    if ($postgisObject->PDOerror) {
        makeExceptionReport($postgisObject->PDOerror);
    }
    while ($row = $postgisObject->fetchRow($result)) {
        echo "[{$row['f_table_schema']}.{$row['f_table_name']}]\n";
        echo "type=WMS\n";
        echo "url=http://127.0.0.1/cgi-bin/mapserv?map={$basePath}/wms/mapfiles/{$user}_{$row['f_table_schema']}.map\n";
        echo "extension=png\n";
        echo "bbox=-20037508.3427892,-20037508.3427892,20037508.3427892,20037508.3427892\n";
        echo "maxResolution=156543.0339\n";
        echo "metaTile=yes\n";
        echo "metaSize=5,5\n";
        echo "srs=EPSG:900913\n\n";
    }
    $data = ob_get_clean();
    @unlink("{$basePath}wms/cfgfiles/{$user}.tilecache.cfg");
    $newFile = "{$basePath}wms/cfgfiles/{$user}.tilecache.cfg";
    $fh = fopen($newFile, 'w');
    fwrite($fh, $data);
    fclose($fh);
}
Пример #8
0
function UserIDCheck($sValue, &$oStatus)
{
    global $sTable;
    global $postgisObject;
    //$sUserID = addslashes($sValue);
    $sUserID = postgis::toAscii($sValue, NULL, "_");
    $oStatus->bValid = false;
    $oStatus->sErrMsg = "<span class='label label-warning'>User ID '{$sValue}' already exist</span>";
    $sQuery = "SELECT COUNT(*) as count FROM {$sTable} WHERE screenname = '{$sUserID}'";
    $res = $postgisObject->execQuery($sQuery);
    $row = $postgisObject->fetchRow($res);
    //echo($row['count']);
    //die();
    if ($row['count'] > 0) {
        $oStatus->bValid = 0;
        $postgisObject->numRows($res);
    } else {
        $oStatus->bValid = 1;
    }
}
Пример #9
0
function UserIDCheck($sValue, &$oStatus)
{
    global $sTable;
    global $postgisObject;
    global $sUserID;
    $sUserID = postgis::toAscii($sValue, NULL, "_");
    $sPassword = VDFormat($_POST['Password'], true);
    $sPassword = Settings_viewer::encryptPw($sPassword);
    ings_viewerssword;
    $oStatus->bValid = false;
    $oStatus->sErrMsg = "User ID '{$sValue}' already exist";
    $sQuery = "SELECT COUNT(*) as count FROM {$sTable} WHERE screenname = '{$sUserID}' AND pw='{$sPassword}'";
    $res = $postgisObject->execQuery($sQuery);
    $row = $postgisObject->fetchRow($res);
    //echo($sQuery);
    //die();
    if ($row['count'] > 0) {
        $oStatus->bValid = 1;
        $postgisObject->numRows($res);
    } else {
        $oStatus->bValid = 0;
    }
}
Пример #10
0
 function __construct($table)
 {
     parent::__construct();
     $this->table = $table;
 }
Пример #11
0
<?php

die("What are u doing?");
include "../conf/main.php";
include "../libs/functions.php";
include "../models/Database.php";
//echo "test";
$dbList = new databases();
$arr = $dbList->listAllDbs();
$postgisdb = "mygeocloud";
$conn = new postgis();
foreach ($arr['data'] as $db) {
    if ($db != "template1" and $db != "template0" and $db != "postgres" and $db != "postgis_template" and $db != "mhoegh" and $db != "mygeocloud") {
        $sql = "DROP DATABASE {$db}";
        $result = $conn->execQuery($sql, "PDO", "transaction");
        echo "<p>{$conn->PDOerror[0]} SQL loaded in {$db}</p>";
        $conn->PDOerror = NULL;
        echo "<p>---------------------</p>";
        $conn->db = NULL;
        $conn = NULL;
    }
}
Пример #12
0
<?php

include "../server_header.inc";
$db = new postgis();
$db->execQuery("set client_encoding='UTF8'", "PDO");
$response = $db->sql($_REQUEST['q']);
include_once "../server_footer.inc";
Пример #13
0
/**
 *
 *
 * @param unknown $arr
 * @return unknown
 */
function parseFilter($filter, $table, $operator = "=")
{
    global $postgisObject;
    global $postgisschema;
    //global $forUseInSpatialFilter;
    global $srs;
    $st = postgis::explodeTableName($table);
    if (!$st['schema']) {
        $st['schema'] = $postgisschema;
    }
    $primeryKey = $postgisObject->getPrimeryKey($st['schema'] . "." . $st['table']);
    $serializer_options = array('indent' => '  ');
    $Serializer =& new XML_Serializer($serializer_options);
    if (!is_array($filter[0]) && isset($filter) && !(isset($filter['And']) or isset($filter['Or']) or isset($filter['Not']))) {
        $filter = array(0 => $filter);
    }
    $sridOfTable = $postgisObject->getGeometryColumns($table, "srid");
    $i = 0;
    foreach ($filter as $key => $arr) {
        if ($key == "And" || $key == "Or") {
            $BoolOperator = $key;
        }
        if (isset($arr['Not'])) {
            //$where[] = parseFilter($arr['Not'],$table,"<>");
        }
        if (isset($arr['And']) || isset($arr['Or'])) {
            // Recursive call
            $where[] = parseFilter($arr, $table);
        }
        // PropertyIsEqualTo
        $arr['PropertyIsEqualTo'] = addDiminsionOnArray($arr['PropertyIsEqualTo']);
        if (is_array($arr['PropertyIsEqualTo'])) {
            foreach ($arr['PropertyIsEqualTo'] as $value) {
                $where[] = $value['PropertyName'] . "=" . $postgisObject->quote($value['Literal']);
            }
        }
        // PropertyIsNotEqualTo
        $arr['PropertyIsNotEqualTo'] = addDiminsionOnArray($arr['PropertyIsNotEqualTo']);
        if (is_array($arr['PropertyIsNotEqualTo'])) {
            foreach ($arr['PropertyIsNotEqualTo'] as $value) {
                $where[] = $value['PropertyName'] . "<>'" . $value['Literal'] . "'";
            }
        }
        // FeatureID
        if (!is_array($arr['FeatureId'][0]) && isset($arr['FeatureId'])) {
            $arr['FeatureId'] = array(0 => $arr['FeatureId']);
        }
        if (is_array($arr['FeatureId'])) {
            foreach ($arr['FeatureId'] as $value) {
                $value['fid'] = preg_replace("/{$table}\\./", "", $value['fid']);
                // remove table name
                $where[] = "{$primeryKey['attname']}=" . $value['fid'];
            }
        }
        // GmlObjectId
        $arr['GmlObjectId'] = addDiminsionOnArray($arr['GmlObjectId']);
        if (is_array($arr['GmlObjectId'])) {
            foreach ($arr['GmlObjectId'] as $value) {
                $value['id'] = preg_replace("/{$table}\\./", "", $value['id']);
                // remove table name
                $where[] = "{$primeryKey['attname']}=" . $value['id'];
            }
        }
        //Intersects
        $arr['Intersects'] = addDiminsionOnArray($arr['Intersects']);
        if (is_array($arr['Intersects'])) {
            foreach ($arr['Intersects'] as $value) {
                $status = $Serializer->serialize($value);
                $gmlCon = new gmlConverter();
                //logfile::write($Serializer->getSerializedData()."\n\n");
                $wktArr = $gmlCon->gmlToWKT($Serializer->getSerializedData(), array());
                $sridOfFilter = $wktArr[1][0];
                if (!$sridOfFilter) {
                    $sridOfFilter = $srs;
                }
                // If no filter on BBOX we think it must be same as the requested srs
                if (!$sridOfFilter) {
                    $sridOfFilter = $sridOfTable;
                }
                // If still no filter on BBOX we set it to native srs
                $where[] = "intersects" . "(public.transform(public.GeometryFromText('" . $wktArr[0][0] . "'," . $sridOfFilter . "),{$sridOfTable})," . $value['PropertyName'] . ")";
                unset($gmlCon);
                unset($wktArr);
            }
        }
        //BBox
        if ($arr['BBOX']) {
            if (is_array($arr['BBOX']['Box']['coordinates'])) {
                $arr['BBOX']['Box']['coordinates']['_content'] = str_replace(" ", ",", $arr['BBOX']['Box']['coordinates']['_content']);
                $coordsArr = explode(",", $arr['BBOX']['Box']['coordinates']['_content']);
            } else {
                $arr['BBOX']['Box']['coordinates'] = str_replace(" ", ",", $arr['BBOX']['Box']['coordinates']);
                $coordsArr = explode(",", $arr['BBOX']['Box']['coordinates']);
            }
            $sridOfFilter = gmlConverter::parseEpsgCode($arr['BBOX']['Box']['srsName']);
            if (!$sridOfFilter) {
                $sridOfFilter = $srs;
            }
            // If no filter on BBOX we think it must be same as the requested srs
            if (!$sridOfFilter) {
                $sridOfFilter = $sridOfTable;
            }
            // If still no filter on BBOX we set it to native srs
            /*
            			$coordsArr[0] = floor($coordsArr[0]/1000)*1000;
            			$coordsArr[1] = floor($coordsArr[1]/1000)*1000;
            			$coordsArr[2] = ceil($coordsArr[2]/1000)*1000;
            			$coordsArr[3] = ceil($coordsArr[3]/1000)*1000;
            */
            $where[] = "intersects" . "(public.transform(public.GeometryFromText('POLYGON((" . $coordsArr[0] . " " . $coordsArr[1] . "," . $coordsArr[0] . " " . $coordsArr[3] . "," . $coordsArr[2] . " " . $coordsArr[3] . "," . $coordsArr[2] . " " . $coordsArr[1] . "," . $coordsArr[0] . " " . $coordsArr[1] . "))'," . $sridOfFilter . "),{$sridOfTable})," . $arr['BBOX']['PropertyName'] . ")";
        }
        // End of filter parsing
        $i++;
    }
    if (!$BoolOperator) {
        $BoolOperator = "OR";
    }
    return "(" . implode(" " . $BoolOperator . " ", $where) . ")";
}
Пример #14
0
<?php

include_once "server_header.inc";
//$geometryColumns = new GeometryColumns();
$sql = "SELECT * FROM settings.geometry_columns_view order by sort_id";
$result = $postgisObject->execQuery($sql);
$rows = pg_fetch_all($result);
//print_r($rows);
if ($_REQUEST['layer']) {
    $_REQUEST['layers'] = $_REQUEST['layer'];
}
$layers = explode(";", $_REQUEST['layers']);
$response['html'] .= "<table>";
for ($i = 0; $i < sizeof($layers); $i++) {
    if ($layers[$i]) {
        $st = postgis::explodeTableName($layers[$i]);
        $wmsUrl = getValueFromKey($layers[$i] . ".the_geom", "wmssource");
        //echo "test".$wmsUrl;
        if (!$wmsUrl) {
            $layerConnectionString = "http://{$_SERVER['SERVER_NAME']}/wms/{$postgisdb}/{$st["schema"]}";
            $response['html'] .= "<tr><td><img src='{$layerConnectionString}/?LAYER={$layers[$i]}&SERVICE=WMS&VERSION=1.1.1&REQUEST=getlegendgraphic&FORMAT=image/png'/></td></tr>";
        } else {
            $layerConnectionString = $wmsUrl;
            $response['html'] .= str_replace("layers", "layer", "<tr><td><img src='{$layerConnectionString}&REQUEST=getlegendgraphic&FORMAT=image/png'/></td></tr>");
        }
    }
}
$response['html'] .= "</table>";
function getValueFromKey($_key_, $column)
{
    global $rows;
Пример #15
0
include '../libs/FirePHPCore/FirePHP.class.php';
include '../libs/FirePHPCore/fb.php';
include '../model/geometry_columns.php';
//$userFromUri = "mhoegh"; // for testing
logfile::write($userFromUri . "\n\n");
if (!$gmlNameSpace) {
    $gmlNameSpace = $userFromUri;
}
if (!$gmlNameSpaceUri) {
    $gmlNameSpaceUri = "http://twitter/{$userFromUri}";
}
// We connect to the users db
$postgisdb = $userFromUri;
$srs = $srsFromUri;
$postgisschema = $schemaFromUri;
$postgisObject = new postgis();
//$user = new users($userFromUri);
//$version = new version($user);
$geometryColumnsObj = new GeometryColumns();
function microtime_float()
{
    list($utime, $time) = explode(" ", microtime());
    return (double) $utime + (double) $time;
}
$startTime = microtime_float();
//ini_set("display_errors", "On");
$thePath = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REDIRECT_URL'];
//$thePath= "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
$server = "http://" . $_SERVER['SERVER_NAME'];
$BBox = null;
//end added
Пример #16
0
 function wfs_server()
 {
     // Manually tested this piece of code in order to check the requests.
     // Code based on a similar idea but build in Java
     header('Content-Type:text/xml; charset=UTF-8', TRUE);
     header('Connection:close', TRUE);
     //$userFromUri = "mhoegh"; // for testing
     logfile::write($userFromUri . "\n\n");
     // We connect to the users db
     $postgisdb = $userFromUri;
     $srs = $srsFromUri;
     $postgisschema = $schemaFromUri;
     $postgisObject = new postgis();
     //$user = new users($userFromUri);
     //$version = new version($user);
     $geometryColumnsObj = new GeometryColumns();
     function microtime_float()
     {
         list($utime, $time) = explode(" ", microtime());
         return (double) $utime + (double) $time;
     }
     $startTime = microtime_float();
     //ini_set("display_errors", "On");
     $thePath = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REDIRECT_URL'];
     //$thePath= "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
     $server = "http://" . $_SERVER['SERVER_NAME'];
     $BBox = null;
     //end added
     $currentTable = null;
     $currentTag = null;
     $gen = array();
     $gen[0] = "";
     $level = 0;
     $depth = 0;
     $tables = array();
     $fields = array();
     $wheres = array();
     $limits = array();
     logfile::write("\nRequest\n\n");
     logfile::write($HTTP_RAW_POST_DATA . "\n\n");
     $unserializer_options = array('parseAttributes' => TRUE, 'typeHints' => FALSE);
     $unserializer = new XML_Unserializer($unserializer_options);
     /*$HTTP_RAW_POST_DATA = '<?xml version="1.0" encoding="utf-8"?><wfs:Transaction service="WFS" version="1.0.0" xmlns="http://www.opengis.net/wfs" xmlns:mrhg="http://twitter/mrhg" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><wfs:Insert idgen="GenerateNew"><mrhg:hej><the_geom><gml:MultiPolygon srsName="urn:x-ogc:def:crs:EPSG:6.9:4326"><gml:polygonMember><gml:Polygon><gml:exterior><gml:LinearRing><gml:coordinates>5.0657329559,-41.1107215881 8.4824724197,-39.3435783386 4.3241734505,-34.6001853943 5.0657329559,-41.1107215881 </gml:coordinates></gml:LinearRing></gml:exterior></gml:Polygon></gml:polygonMember></gml:MultiPolygon></the_geom></mrhg:hej></wfs:Insert></wfs:Transaction>';*/
     /*$HTTP_RAW_POST_DATA = '<?xml version="1.0"?><DescribeFeatureType  version="1.1.0"  service="WFS"  xmlns="http://www.opengis.net/wfs"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">    <TypeName>california_coastline</TypeName></DescribeFeatureType>';
      */
     // Post method is used
     if ($HTTP_RAW_POST_DATA) {
         //$forUseInSpatialFilter = $HTTP_RAW_POST_DATA; // We store a unaltered version of the raw request
         $HTTP_RAW_POST_DATA = dropNameSpace($HTTP_RAW_POST_DATA);
         logfile::write($HTTP_RAW_POST_DATA . "\n\n");
         $status = $unserializer->unserialize($HTTP_RAW_POST_DATA);
         $arr = $unserializer->getUnserializedData();
         $request = $unserializer->getRootName();
         //print_r($arr);
         switch ($request) {
             case "GetFeature":
                 if (!is_array($arr['Query'][0])) {
                     $arr['Query'] = array(0 => $arr['Query']);
                 }
                 for ($i = 0; $i < sizeof($arr['Query']); $i++) {
                     if (!is_array($arr['Query'][$i]['PropertyName'])) {
                         $arr['Query'][$i]['PropertyName'] = array(0 => $arr['Query'][$i]['PropertyName']);
                     }
                 }
                 $HTTP_FORM_VARS["REQUEST"] = "GetFeature";
                 foreach ($arr['Query'] as $queries) {
                     $HTTP_FORM_VARS["TYPENAME"] .= $queries['typeName'] . ",";
                     if ($queries['PropertyName'][0]) {
                         foreach ($queries['PropertyName'] as $PropertyNames) {
                             // We check if typeName is prefix and add it if its not
                             if (strpos($PropertyNames, ".")) {
                                 $HTTP_FORM_VARS["PROPERTYNAME"] .= $PropertyNames . ",";
                             } else {
                                 $HTTP_FORM_VARS["PROPERTYNAME"] .= $queries['typeName'] . "." . $PropertyNames . ",";
                             }
                         }
                     }
                     if (is_array($queries['Filter']) && $arr['version'] == "1.0.0") {
                         @($checkXml = simplexml_load_string($queries['Filter']));
                         if ($checkXml === FALSE) {
                             makeExceptionReport("Filter is not valid");
                         }
                         $wheres[$queries['typeName']] = parseFilter($queries['Filter'], $queries['typeName']);
                     }
                 }
                 $HTTP_FORM_VARS["TYPENAME"] = dropLastChrs($HTTP_FORM_VARS["TYPENAME"], 1);
                 $HTTP_FORM_VARS["PROPERTYNAME"] = dropLastChrs($HTTP_FORM_VARS["PROPERTYNAME"], 1);
                 break;
             case "DescribeFeatureType":
                 $HTTP_FORM_VARS["REQUEST"] = "DescribeFeatureType";
                 $HTTP_FORM_VARS["TYPENAME"] = $arr['TypeName'];
                 //if (!$HTTP_FORM_VARS["TYPENAME"]) $HTTP_FORM_VARS["TYPENAME"] = $arr['typeName'];
                 break;
             case "GetCapabilities":
                 $HTTP_FORM_VARS["REQUEST"] = "GetCapabilities";
                 break;
             case "Transaction":
                 $HTTP_FORM_VARS["REQUEST"] = "Transaction";
                 if (isset($arr["Insert"])) {
                     $transactionType = "Insert";
                 }
                 if ($arr["Update"]) {
                     $transactionType = "update";
                 }
                 if ($arr["Delete"]) {
                     $transactionType = "Delete";
                 }
                 break;
         }
     } else {
         if (sizeof($_GET) > 0) {
             logfile::write($_SERVER['QUERY_STRING'] . "\n\n");
             $HTTP_FORM_VARS = $_GET;
             $HTTP_FORM_VARS = array_change_key_case($HTTP_FORM_VARS, CASE_UPPER);
             // Make keys case insensative
             $HTTP_FORM_VARS["TYPENAME"] = dropNameSpace($HTTP_FORM_VARS["TYPENAME"]);
             // We remove name space, so $where will get key without it.
             if ($HTTP_FORM_VARS['FILTER']) {
                 @($checkXml = simplexml_load_string($HTTP_FORM_VARS['FILTER']));
                 if ($checkXml === FALSE) {
                     makeExceptionReport("Filter is not valid");
                 }
                 //$forUseInSpatialFilter = $HTTP_FORM_VARS['FILTER'];
                 $status = $unserializer->unserialize(dropNameSpace($HTTP_FORM_VARS['FILTER']));
                 $arr = $unserializer->getUnserializedData();
                 $wheres[$HTTP_FORM_VARS['TYPENAME']] = parseFilter($arr, $HTTP_FORM_VARS['TYPENAME']);
             }
         } else {
             $HTTP_FORM_VARS = array("");
         }
     }
     //HTTP_FORM_VARS is set in script if POST is used
     $HTTP_FORM_VARS = array_change_key_case($HTTP_FORM_VARS, CASE_UPPER);
     // Make keys case
     $HTTP_FORM_VARS["TYPENAME"] = dropNameSpace($HTTP_FORM_VARS["TYPENAME"]);
     $tables = explode(",", $HTTP_FORM_VARS["TYPENAME"]);
     $properties = explode(",", dropNameSpace($HTTP_FORM_VARS["PROPERTYNAME"]));
     $featureids = explode(",", $HTTP_FORM_VARS["FEATUREID"]);
     $bbox = explode(",", $HTTP_FORM_VARS["BBOX"]);
     // Start HTTP basic authentication
     //if(!$_SESSION["oauth_token"]) {
     $auth = $postgisObject->getGeometryColumns($postgisschema . "." . $HTTP_FORM_VARS["TYPENAME"], "authentication");
     //}
     // End HTTP basic authentication
     print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
     ob_start();
     if (!empty($properties[0])) {
         foreach ($properties as $property) {
             $__u = explode(".", $property);
             // Is it "/" for get method?
             // We first check if typeName is namespace
             if ($__u[1]) {
                 foreach ($tables as $table) {
                     if ($table == $__u[0]) {
                         $fields[$table] .= $__u[1] . ",";
                     }
                 }
             } else {
                 foreach ($tables as $table) {
                     $fields[$table] .= $property . ",";
                 }
             }
         }
     }
     if (!empty($featureids[0])) {
         foreach ($featureids as $featureid) {
             $__u = explode(".", $featureid);
             foreach ($tables as $table) {
                 $primeryKey = $postgisObject->getPrimeryKey($postgisschema . "." . $table);
                 if ($table == $__u[0]) {
                     $wheresArr[$table][] = "{$primeryKey['attname']}={$__u[1]}";
                 }
                 $wheres[$table] = implode(" OR ", $wheresArr[$table]);
             }
         }
     }
     //get the request
     switch (strtoupper($HTTP_FORM_VARS["REQUEST"])) {
         case "GETCAPABILITIES":
             getCapabilities($postgisObject);
             break;
         case "GETFEATURE":
             if (!$gmlFeatureCollection) {
                 $gmlFeatureCollection = "wfs:FeatureCollection";
             }
             print "<" . $gmlFeatureCollection . "\n";
             print "xmlns=\"http://www.opengis.net/wfs\"\n";
             print "xmlns:wfs=\"http://www.opengis.net/wfs\"\n";
             print "xmlns:gml=\"http://www.opengis.net/gml\"\n";
             print "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
             print "xmlns:{$gmlNameSpace}=\"{$gmlNameSpaceUri}\"\n";
             if ($gmlSchemaLocation) {
                 print "xsi:schemaLocation=\"{$gmlSchemaLocation}\"";
             } else {
                 //print "xsi:schemaLocation=\"{$gmlNameSpaceUri} {$thePath}?REQUEST=DescribeFeatureType&amp;TYPENAME=".$HTTP_FORM_VARS["TYPENAME"]." http://www.opengis.net/wfs ".str_replace("server.php","",$thePath)."schemas/wfs/1.0.0/WFS-basic.xsd\"";
                 print "xsi:schemaLocation=\"{$gmlNameSpaceUri} {$thePath}?REQUEST=DescribeFeatureType&amp;TYPENAME=" . $HTTP_FORM_VARS["TYPENAME"] . " http://www.opengis.net/wfs http://wfs.plansystem.dk:80/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd\"";
             }
             print ">\n";
             doQuery("Select");
             print "</" . $gmlFeatureCollection . ">";
             break;
         case "DESCRIBEFEATURETYPE":
             getXSD($postgisObject);
             break;
         case "TRANSACTION":
             doParse($arr);
             break;
         default:
             makeExceptionReport("Don't know that request");
             break;
     }
 }
Пример #17
0
<?php

include "../conf/main.php";
include "../libs/functions.php";
include "../model/databases.php";
include "../model/dbchecks.php";
include '../model/settings_viewer.php';
$dbList = new databases();
try {
    $arr = $dbList->listAllDbs();
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
    die;
}
$postgisdb = "mygeocloud";
$postgis = new postgis();
$i = 1;
foreach ($arr['data'] as $db) {
    if ($db != "template1" and $db != "template0" and $db != "postgres" and $db != "postgis_template") {
        $postgisdb = $db;
        //$dbc = new dbcheck();
        $viewer = new Settings_viewer();
        $arr = $viewer->get();
        $sql = "INSERT INTO users(screenname,pw) VALUES('{$db}','{$arr['data']['pw']}')";
        $postgis->execQuery($sql);
        echo $sql . "\n";
        $i++;
    }
    //if ($i>10) die();
}
Пример #18
0
 function __construct($srs = "900913")
 {
     parent::__construct();
     $this->srs = $srs;
 }
Пример #19
0
 function __construct()
 {
     parent::__construct();
 }
Пример #20
0
 function __construct()
 {
     parent::__construct();
     /** URL for REST request, see: https://dev.twitter.com/docs/api/1.1/ **/
     $this->settings = array('oauth_access_token' => "1252476258-DVO9x6mwnz05f5VL8WIsTx4XmpeUbOjDSs9hLXc", 'oauth_access_token_secret' => "regt6Vo082Bq3uaSDKyrGnHYPNSccncU6woXN1Mlw", 'consumer_key' => "AtDjL4UxITwrwBIMBicCQ", 'consumer_secret' => "GsFWDIR8bCuuigshxVhj9ZFK0lU00ecMm0ZeEd2Go");
 }
Пример #21
0
<?php

ini_set("display_errors", "On");
error_reporting(3);
session_start();
include '../../../conf/main.php';
include 'libs/functions.php';
include 'inc/user_name_from_uri.php';
include 'libs/FirePHPCore/FirePHP.class.php';
include 'libs/FirePHPCore/fb.php';
include 'model/tables.php';
$postgisdb = $parts[3];
$postgisObject = new postgis();
?>


    	<table border="0" width="100%" height="200" cellpadding="0" cellspacing="0">
    	  <tbody><tr>
		    <td class="boxtopblueleft"><img src="/gifs/apps/holbaektemaplaner/dottrans.gif" width="5px" height="5px"></td>
    		<td class="boxmainblue"><img src="/gifs/apps/holbaektemaplaner/dottrans.gif" width="195px" height="1px"></td>
    		<td class="boxtopblueright"><img src="/gifs/apps/holbaektemaplaner/dottrans.gif" width="5px" height="5px"></td>
    	  </tr>
    	  <tr>
			<td class="boxmainblue"></td>
    	    <td class="boxbluecontent">
    	    <p class="h3">Staus</p>
    	    <div class="blueshade"></div>
    	    <p class="focusheader">
    	    

<?php 
Пример #22
0
 function getUtmZone($table, $field, $value)
 {
     $query = "SELECT X(Centroid(the_geom)) as x FROM {$table} WHERE {$field}={$value}";
     $result = $this->execQuery($query);
     $row = postgis::fetchRow($result);
     $zone = floor((180 + $row['x']) / 6);
     if ($zone < 10) {
         $zone = "0" . $zone;
     }
     return $zone;
 }
Пример #23
0
include 'libs/functions.php';
include 'inc/user_name_from_uri.php';
include 'model/users.php';
include 'model/databases.php';
include 'model/classes.php';
include 'model/wmslayers.php';
include 'model/settings_viewer.php';
// we need to get pw for http authentication
include 'libs/FirePHPCore/FirePHP.class.php';
include 'libs/FirePHPCore/fb.php';
if ($parts[1] == "store" || $parts[1] == "editor") {
    $db = new databases();
    if (!$parts[2]) {
        die("<script>window.location='/?db=false'</script>");
    }
    if ($db->doesDbExist(postgis::toAscii($parts[2], NULL, "_"))) {
        $postgisdb = $parts[2];
    } else {
        die("<script>window.location='/?db=false'</script>");
    }
    include "inc/oauthcheck.php";
}
?>
<!DOCTYPE html>
<html>
<head>
    <title>MapCentia GeoCloud</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="description"
          content="Analyze and visualize your data. Use a powerful API for adding maps to your own apps."/>
    <meta name="description"
Пример #24
0
// Start HTML doc
include "html_header.php";
?>
<link rel="stylesheet" href="/css/style.css" type="text/css" media="screen" />
</head>
<body>
<div id="outercontainer">
<div id="innercontainer">
<div id='stylized' class="myform">
<?php 
if (!$_REQUEST['name']) {
    echo "<h1>Need a name!</h1>";
    echo "<p></p>";
} else {
    $name = postgis::toAscii($_REQUEST['name'], NULL, "_");
    $db = new databases();
    $dbObj = $db->createdb($name, $databaseTemplate, "LATIN1");
    // databaseTemplate is set in conf/main.php
    if ($dbObj) {
        echo "<h1>Your geocloud \"{$name}\" was created!</h1>";
        echo "<p>When asked type in \"{$name}\" and use \"1234\" for password. Remember to change it!</p>";
        echo "<button onclick=\"window.location.href='/store/{$name}'\">Take me to my cloud</button>";
    } else {
        echo "<h1>Sorry, something went wrong. Try again</h1>";
    }
}
?>
<div class="spacer"></div>
</div>
</div>
Пример #25
0
$targetPath = "{$_SERVER["DOCUMENT_ROOT"]}/tmp/";
$fileName = $_SESSION['screen_name'] . "_" . time();
$file = $targetPath . $fileName;
$response['uploaded'] = true;
$SafeFile = $_FILES['shp']['name'];
$SafeFile = str_replace("#", "No.", $SafeFile);
$SafeFile = str_replace("-", "_", $SafeFile);
$SafeFile = str_replace("\$", "Dollar", $SafeFile);
$SafeFile = str_replace("%", "Percent", $SafeFile);
$SafeFile = str_replace("^", "", $SafeFile);
$SafeFile = str_replace("&", "and", $SafeFile);
$SafeFile = str_replace("*", "", $SafeFile);
$SafeFile = str_replace("?", "", $SafeFile);
$SafeFile = str_replace(".shp", "", $SafeFile);
$SafeFile = strtolower($SafeFile);
$SafeFile = postgis::toAscii($SafeFile, array(), "_");
$SafeFile = $postgisschema . "." . $SafeFile;
if (move_uploaded_file($_FILES['shp']['tmp_name'], $file . ".shp")) {
} else {
    $response['uploaded'] = false;
}
if (move_uploaded_file($_FILES['dbf']['tmp_name'], $file . ".dbf")) {
} else {
    $response['uploaded'] = false;
}
if (move_uploaded_file($_FILES['shx']['tmp_name'], $file . ".shx")) {
} else {
    $response['uploaded'] = false;
}
if ($response['uploaded']) {
    $shapeFile = new shapefile($SafeFile, $_REQUEST['srid'], $file, $_REQUEST['pdo']);
Пример #26
0
<?php

ini_set("display_errors", "On");
error_reporting(3);
include '../../../../../conf/main.php';
include 'libs/functions.php';
$postgisdb = "cowitrack";
$db = new postgis();
$sql = "INSERT INTO dhl (id,mytime,the_geom,speed,accuracy) VALUES('" . strtolower($_POST['id']) . "',{$_POST['mytime']},geomfromtext('POINT({$_POST['lon']} {$_POST['lat']})',4326),{$_POST['speed']},{$_POST['accuracy']})";
if ($_POST['id']) {
    $db->execQuery($sql, "PDO");
}
echo $sql;
Пример #27
0
 function __construct($userId)
 {
     parent::__construct();
     $this->userId = $userId;
     $this->postgisdb = "mapcentia";
 }
Пример #28
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();
 }
Пример #29
0
<?php

include "../conf/main.php";
include "../libs/functions.php";
include "../model/databases.php";
include "sqls.php";
$postgisdb = $_REQUEST['db'];
$conn = new postgis();
try {
    $conn->connect();
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
    die;
}
$conn->begin();
//Try to drop schema
/*
$result = $conn->execQuery("DROP SCHEMA settings CASCADE","PDO","transaction");
if (!$conn->PDOerror[0]) {
	echo "Schema dropped<br/>";
}
else {
	echo "Something went wrong; {$conn->PDOerror[0]}";
	$conn->rollback();
}
*/
//Try to create schema
$result = $conn->execQuery($sqls['schema'], "PDO", "transaction");
if (!$conn->PDOerror[0]) {
    echo "Schema created<br/>";
} else {
Пример #30
0
 function __construct($userObj)
 {
     parent::__construct();
     $this->userObj = $userObj;
 }