function __construct() { // Prevent unauthorized use of gc2scheduler if (!\app\conf\App::$param["gc2scheduler"][$_SESSION["screen_name"]]) { $code = "401"; header("HTTP/1.0 {$code} " . \app\inc\Util::httpCodeText($code)); die(\app\inc\Response::toJson(array("success" => false, "message" => "Not allowed"))); } $this->job = new \app\models\Job(); }
private function get_file($type) { include_once 'Cache_Lite/Lite.php'; $db = Input::getPath()->part(5); $baseLayer = Input::get("baselayer"); $layers = Input::get("layers"); $center = Input::get("center"); $zoom = Input::get("zoom"); $size = Input::get("size"); $sizeArr = explode("x", Input::get("size")); $bbox = Input::get("bbox"); $sql = Input::get("sql"); $id = $db . "_" . $baseLayer . "_" . $layers . "_" . $center . "_" . $zoom . "_" . $size . "_" . $bbox . "_" . $sql; $lifetime = Input::get('lifetime') ?: 0; $options = array('cacheDir' => \app\conf\App::$param['path'] . "app/tmp/", 'lifeTime' => $lifetime); $Cache_Lite = new \Cache_Lite($options); if ($data = $Cache_Lite->get($id)) { //echo "Cached"; } else { ob_start(); $fileName = md5(time() . rand(10000, 99999) . microtime()); $file = \app\conf\App::$param["path"] . "/app/tmp/_" . $fileName . "." . $type; $cmd = "wkhtmltoimage " . "--height {$sizeArr[1]} --disable-smart-width --width {$sizeArr[0]} --quality 90 --javascript-delay 1000 " . "\"" . "http://127.0.0.1" . "/api/v1/staticmap/html/{$db}?baselayer={$baseLayer}&layers={$layers}¢er={$center}&zoom={$zoom}&size={$size}&bbox={$bbox}&sql={$sql}\" " . $file; //die($cmd); exec($cmd); switch ($type) { case "png": $res = imagecreatefrompng($file); break; case "jpg": $res = imagecreatefromjpeg($file); break; } if (!$res) { $response['success'] = false; $response['message'] = "Could not create image"; $response['code'] = 406; header("HTTP/1.0 {$response['code']} " . \app\inc\Util::httpCodeText($response['code'])); echo \app\inc\Response::toJson($response); exit; } header('Content-type: image/png'); imageAlphaBlending($res, true); imageSaveAlpha($res, true); imagepng($res); // Cache script $data = ob_get_contents(); $Cache_Lite->save($data, $id); ob_get_clean(); } header("Content-type: image/png"); echo $data; exit; }
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; } }
public function get_tms() { $parts = explode("/", $_SERVER['REQUEST_URI']); $url = "http://127.0.0.1/cgi/tilecache.py/{$parts[3]}/{$parts[4]}/{$parts[5]}/{$parts[6]}/{$parts[7]}?cfg={$this->db}"; $res = imagecreatefrompng($url); if (!$res) { $response['success'] = false; $response['message'] = "Could create tile"; $response['code'] = 406; header("HTTP/1.0 {$response['code']} " . \app\inc\Util::httpCodeText($response['code'])); echo \app\inc\Response::toJson($response); exit; } header('Content-type: image/png'); imageAlphaBlending($res, true); imageSaveAlpha($res, true); imagepng($res); exit; }
private function checkAuth($db, $key) { //die($this->clientIp); $trusted = false; foreach (App::$param["trustedAddresses"] as $address) { if (Util::ipInRange($this->clientIp, $address)) { $trusted = true; break; } } if (!$trusted) { if (!$this->authApiKey($db, $key)) { $response['success'] = false; $response['message'] = "Not the right key."; $response['code'] = 403; return $response; } } return false; //Auth passed }
static function createClass($type, $name = "Unnamed class", $expression = null, $sortid = 1, $color = null, $data = null) { $symbol = $data->symbol ?: ""; $size = $data->symbolSize ?: ""; $outlineColor = $data->outlineColor ?: ""; $color = $color ?: Util::randHexColor(); if ($type == "POINT" || $type == "MULTIPOINT") { $symbol = $data->symbol ?: "circle"; $size = $data->symbolSize ?: 10; } return (object) array("sortid" => $sortid, "name" => $name, "expression" => $expression, "label" => $data->labelText ? true : false, "label_size" => $data->labelSize ?: "", "label_color" => $data->labelColor ?: "", "color" => $color, "outlinecolor" => $outlineColor ?: "", "style_opacity" => $data->opacity ?: "", "symbol" => $symbol, "angle" => $data->angle ?: "", "size" => $size, "width" => $data->lineWidth ?: "", "overlaycolor" => $data->overlayColor ?: "", "overlayoutlinecolor" => "", "overlaysymbol" => $data->overlaySymbol ?: "", "overlaysize" => $data->overlaySize ?: "", "overlaywidth" => "", "label_text" => $data->labelText ?: "", "label_position" => $data->labelPosition ?: "", "label_font" => $data->labelFont ?: "", "label_fontweight" => $data->labelFontWeight ?: "", "label_angle" => $data->labelAngle ?: "", "label_backgroundcolor" => $data->labelBackgroundcolor ?: "", "style_opacity" => $data->opacity ?: "", "overlaystyle_opacity" => $data->overlayOpacity ?: "", "label_force" => $data->force ?: ""); }
<link href="/js/bootstrap/css/bootstrap.css" rel="stylesheet"> <div class="container"> <div class="row"> <div class="span9 offset2"> <?php use app\inc\Util; use app\conf\App; use app\models\Database; use app\models\Dbcheck; include "../../app/conf/App.php"; new \app\conf\App(); App::$param['protocol'] = App::$param['protocol'] ?: Util::protocol(); App::$param['host'] = App::$param['host'] ?: App::$param['protocol'] . "://" . $_SERVER['SERVER_NAME'] . ":" . $_SERVER['SERVER_PORT']; //print_r(App::$param); echo "<div>PHP version " . phpversion() . " "; if (function_exists(apache_get_modules)) { echo " running as mod_apache</div>"; $mod_apache = true; } else { echo " running as CGI/FastCGI</div>"; $mod_apache = false; } // We check if "wms/mapfiles" is writeable $ourFileName = "../../app/wms/mapfiles/testFile.txt"; $ourFileHandle = @fopen($ourFileName, 'w'); if ($ourFileHandle) { echo "<div class='alert alert-success'>app/wms/mapfiles dir is writeable</div>"; @fclose($ourFileHandle); @unlink($ourFileName); } else { echo "<div class='alert alert-error'>app/wms/mapfiles dir is not writeable. You must set permissions so the webserver can write in the wms/mapfiles dir.</div>";
function get_index() { $postgisObject = new \app\inc\Model(); ob_start(); ?> MAP # # Start of map file # NAME "<?php echo Connection::$param['postgisdb']; ?> " STATUS on EXTENT -180 -90 180 90 SIZE 2000 1500 MAXSIZE 4096 #SYMBOLSET "../etc/symbols.sym" FONTSET "../fonts/fonts.txt" IMAGECOLOR 255 2 255 UNITS METERS INTERLACE OFF OUTPUTFORMAT NAME "png" DRIVER AGG/PNG MIMETYPE "image/png" IMAGEMODE RGBA EXTENSION "png" TRANSPARENT ON FORMATOPTION "GAMMA=0.75" END #CONFIG "MS_ERRORFILE" "/srv/www/sites/betamygeocloud/wms/mapfiles/ms_error.txt" #DEBUG 5 WEB IMAGEPATH "<?php echo App::$param['path']; ?> /tmp" IMAGEURL "<?php echo App::$param['host']; ?> /tmp" METADATA "wms_title" "<?php echo Connection::$param['postgisdb']; ?> 's awesome WMS" "wfs_title" "<?php echo Connection::$param['postgisdb']; ?> 's awesome WFS" "wms_srs" "EPSG:4326 EPSG:3857 EPSG:900913 EPSG:3044 EPSG:25832" "wfs_srs" "EPSG:4326 EPSG:3857 EPSG:900913 EPSG:3044 EPSG:25832" "wms_name" "<?php echo $user; ?> " "wfs_name" "<?php echo $user; ?> " "wms_format" "image/png" "wms_onlineresource" "<?php echo App::$param['protocol'] ?: "http"; ?> ://<?php echo $_SERVER['HTTP_HOST']; ?> /ows/<?php echo Connection::$param['postgisdb']; ?> /<?php echo Connection::$param['postgisschema']; ?> /" "wfs_onlineresource" "<?php echo App::$param['protocol'] ?: "http"; ?> ://<?php echo $_SERVER['HTTP_HOST']; ?> /ows/<?php echo Connection::$param['postgisdb']; ?> /<?php echo Connection::$param['postgisschema']; ?> /" "ows_enable_request" "*" "wms_enable_request" "*" "wfs_namespace_prefix" "gc2" "wfs_namespace_uri" "http://eu1.mapcentia.com" "wms_encoding" "UTF8" "wfs_encoding" "UTF8" END END # # Start of reference map # PROJECTION "init=epsg:4326" END # # Start of legend # LEGEND STATUS off IMAGECOLOR 255 255 255 KEYSIZE 18 12 LABEL WRAP "#" TYPE truetype FONT "arialnormal" SIZE 8 COLOR 0 0 0 #SHADOWSIZE 2 2 #BACKGROUNDSHADOWSIZE 1 1 END END # # Start of scalebar # SCALEBAR STATUS off COLOR 255 255 255 OUTLINECOLOR 0 0 0 BACKGROUNDCOLOR 0 0 0 IMAGECOLOR 255 255 255 UNITS METERS INTERVALS 3 SIZE 150 5 LABEL FONT "courierb" SIZE SMALL COLOR 0 0 0 SHADOWSIZE 2 2 END END Symbol Name 'triangle' Type VECTOR Filled TRUE Points 0 1 .5 0 1 1 0 1 END END SYMBOL NAME "circle" TYPE ellipse FILLED true POINTS 1 1 END END Symbol Name 'square' Type VECTOR Filled TRUE Points 0 1 0 0 1 0 1 1 0 1 END END Symbol Name 'star' Type VECTOR Filled TRUE Points 0 .375 .35 .375 .5 0 .65 .375 1 .375 .75 .625 .875 1 .5 .75 .125 1 .25 .625 END END SYMBOL NAME "hatch1" TYPE VECTOR POINTS 0 1 1 0 END END SYMBOL NAME "dashed1" TYPE ELLIPSE FILLED TRUE POINTS 1 1 END #STYLE 4 2 END END SYMBOL NAME "arrow" TYPE vector FILLED true POINTS 0 0.4 3 0.4 3 0 5 0.8 3 1.6 3 1.2 0 1.2 0 0.4 END # POINTS ANCHORPOINT 0 0.5 END # SYMBOL # ============================================================================ # Vector Line Types # ============================================================================ SYMBOL NAME "continue" TYPE ELLIPSE FILLED TRUE POINTS 1 1 END END # -------------------- SYMBOL NAME "dashed-line-short" TYPE ELLIPSE FILLED TRUE POINTS 10 1 END #STYLE 5 5 END END # -------------------- SYMBOL NAME "dashed-line-long" TYPE ELLIPSE FILLED TRUE POINTS 10 10 END #STYLE 10 10 END END # -------------------- SYMBOL NAME "dash-dot" TYPE ELLIPSE FILLED TRUE POINTS 20 6 2 6 END #STYLE 20 6 2 6 END END # -------------------- SYMBOL NAME "dash-dot-dot" TYPE ELLIPSE FILLED TRUE POINTS 1 1 END #STYLE 10 6 2 6 2 6 END END # -------------------- SYMBOL NAME "dot-dot" TYPE ELLIPSE FILLED TRUE POINTS 1 1 END #STYLE 2 2 END END # # Start of layers # <?php $sql = "SELECT * FROM settings.getColumns('geometry_columns.f_table_schema=''" . Connection::$param['postgisschema'] . "''','raster_columns.r_table_schema=''" . Connection::$param['postgisschema'] . "''') ORDER BY sort_id"; $result = $postgisObject->execQuery($sql); if ($postgisObject->PDOerror) { ob_get_clean(); return false; } while ($row = $postgisObject->fetchRow($result)) { if ($row['srid'] > 1) { $versioning = $postgisObject->doesColumnExist("{$row['f_table_schema']}.{$row['f_table_name']}", "gc2_version_gid"); $versioning = $versioning["exists"]; $workflow = $postgisObject->doesColumnExist("{$row['f_table_schema']}.{$row['f_table_name']}", "gc2_status"); $workflow = $workflow["exists"]; $arr = (array) json_decode($row['def']); // Cast stdclass to array $props = array("label_column", "theme_column"); foreach ($props as $field) { if (!$arr[$field]) { $arr[$field] = ""; } } $layerArr = array("data" => array($arr)); $sortedArr = array(); // Sort classes $arr = $arr2 = (array) json_decode($row['class']); for ($i = 0; $i < sizeof($arr); $i++) { $last = 1000; foreach ($arr2 as $key => $value) { if ($value->sortid < $last) { $temp = $value; $del = $key; $last = $value->sortid; } } array_push($sortedArr, $temp); unset($arr2[$del]); $temp = null; } $arr = $sortedArr; for ($i = 0; $i < sizeof($arr); $i++) { $arrNew[$i] = (array) \app\inc\Util::casttoclass('stdClass', $arr[$i]); $arrNew[$i]['id'] = $i; } $classArr = array("data" => $arrNew); $primeryKey = $postgisObject->getPrimeryKey("{$row['f_table_schema']}.{$row['f_table_name']}"); unset($arrNew); ?> LAYER NAME "<?php echo $row['f_table_schema']; ?> .<?php echo $row['f_table_name']; ?> " STATUS off <?php if ($row['filter']) { ?> FILTER "<?php echo $row['filter']; ?> " <?php } ?> <?php if ($layerArr['data'][0]['geotype'] && $layerArr['data'][0]['geotype'] != "Default") { $type = $layerArr['data'][0]['geotype']; } else { switch ($row['type']) { case "POINT": $type = "POINT"; break; case "LINESTRING": $type = "LINE"; break; case "POLYGON": $type = "POLYGON"; break; case "MULTIPOINT": $type = "POINT"; break; case "MULTILINESTRING": $type = "LINE"; break; case "MULTIPOLYGON": $type = "POLYGON"; break; case "GEOMETRY": $type = "LINE"; break; case "RASTER": $type = "RASTER"; break; } } if ($row['wmssource']) { ?> TYPE RASTER CONNECTIONTYPE WMS CONNECTION "<?php echo $row['wmssource']; ?> " PROCESSING "RESAMPLE=AVERAGE" <?php } elseif ($row['bitmapsource']) { ?> TYPE RASTER DATA "<?php echo App::$param['path'] . "/app/tmp/" . Connection::$param["postgisdb"] . "/__bitmaps/" . $row['bitmapsource']; ?> " #PROCESSING "LOAD_WHOLE_IMAGE=YES" PROCESSING "RESAMPLE=AVERAGE" <?php } else { if ($type != "RASTER") { if (!$row['data']) { if (preg_match('/[A-Z]/', $row['f_geometry_column'])) { $dataSql = "SELECT *,\\\"{$row['f_geometry_column']}\\\" as " . strtolower($row['f_geometry_column']) . " FROM \\\"{$row['f_table_schema']}\\\".\\\"{$row['f_table_name']}\\\""; } else { $dataSql = "SELECT * FROM \\\"" . "{$row['f_table_schema']}\\\".\\\"{$row['f_table_name']}\\\""; } if ($versioning || $workflow) { $dataSql .= " WHERE 1=1"; } if ($versioning) { $dataSql .= " AND gc2_version_end_date IS NULL"; } if ($workflow) { //$dataSql .= " AND gc2_status = 3"; } } else { $dataSql = $row['data']; } echo "DATA \"" . strtolower($row['f_geometry_column']) . " FROM ({$dataSql}) as foo USING UNIQUE {$primeryKey['attname']} USING srid={$row['srid']}\"\n"; ?> CONNECTIONTYPE POSTGIS CONNECTION "user=<?php echo Connection::$param['postgisuser']; ?> dbname=<?php echo Connection::$param['postgisdb']; if (Connection::$param['postgishost']) { echo " host=" . Connection::$param['postgishost']; } if (Connection::$param['postgisport']) { echo " port=" . Connection::$param['postgisport']; } if (Connection::$param['postgispw']) { echo " password="******"options='-c client_encoding=UTF8'"; } ?> " <?php } else { echo "DATA \"PG:host=" . (Connection::$param['mapserverhost'] ?: Connection::$param['postgishost']); echo " port=" . (Connection::$param['mapserverport'] ?: Connection::$param['postgisport'] ?: "5432"); echo " dbname='" . Connection::$param['postgisdb'] . "' user='******'postgisuser'] . "' password='******'postgispw'] . "'\n\t\t schema='{$row['f_table_schema']}' table='{$row['f_table_name']}' mode='2'\"\n"; echo "PROCESSING \"CLOSE_CONNECTION=ALWAYS\" \n"; } ?> TYPE <?php echo $type . "\n"; ?> <?php } ?> #OFFSITE <?php if ($layerArr['data'][0]['offsite']) { echo "OFFSITE " . $layerArr['data'][0]['offsite'] . "\n"; } ?> #CLASSITEM <?php if ($layerArr['data'][0]['theme_column']) { echo "CLASSITEM '" . $layerArr['data'][0]['theme_column'] . "'\n"; } ?> #LABELITEM <?php if ($layerArr['data'][0]['label_column']) { echo "LABELITEM '" . $layerArr['data'][0]['label_column'] . "'\n"; } ?> #LABELMAXSCALEDENOM <?php if ($layerArr['data'][0]['label_max_scale']) { echo "LABELMAXSCALEDENOM " . $layerArr['data'][0]['label_max_scale'] . "\n"; } ?> #LABELMINSCALEDENOM <?php if ($layerArr['data'][0]['label_min_scale']) { echo "LABELMINSCALEDENOM " . $layerArr['data'][0]['label_min_scale'] . "\n"; } ?> #OPACITY <?php if ($layerArr['data'][0]['opacity']) { echo "OPACITY " . $layerArr['data'][0]['opacity'] . "\n"; } ?> #MAXSCALEDENOM <?php if ($layerArr['data'][0]['maxscaledenom']) { echo "MAXSCALEDENOM " . $layerArr['data'][0]['maxscaledenom'] . "\n"; } ?> #MINSCALEDENOM <?php if ($layerArr['data'][0]['minscaledenom']) { echo "MINSCALEDENOM " . $layerArr['data'][0]['minscaledenom'] . "\n"; } ?> #MINSCALEDENOM <?php if ($layerArr['data'][0]['cluster']) { echo "CLUSTER\n"; echo "MAXDISTANCE {$layerArr['data'][0]['cluster']}\n"; echo "REGION \"ellipse\"\n"; //echo "PROCESSING \"CLUSTER_GET_ALL_SHAPES=false\"\n"; echo "END\n"; } ?> #LABELMAXSCALE METADATA "wms_title" "<?php if ($row['f_table_title']) { echo $row['f_table_title']; } else { echo $row['f_table_name']; } ?> " "wms_srs" "EPSG:<?php echo $row['srid']; ?> " "wms_name" "<?php echo $row['f_table_name']; ?> " "wms_abstract" "<?php echo $row['f_table_abstract']; ?> " "wms_format" "image/png" #"wms_extent" "-180 -90 180 90" "appformap_group" "<?php if ($row['layergroup']) { echo $row['layergroup']; } else { echo "Default group"; } ?> " "appformap_queryable" "true" "appformap_loader" "true" "wms_enable_request" "*" "gml_include_items" "all" "wms_include_items" "all" "wfs_featureid" "<?php echo $primeryKey['attname']; ?> " "gml_geometries" "<?php echo $row['f_geometry_column']; ?> " "gml_<?php echo $row['f_geometry_column']; ?> _type" "<?php echo (substr($row['type'], 0, 5) == "MULTI" ? "multi" : "") . strtolower($type); ?> " <?php if ($row['wmssource']) { $wmsCon = str_replace(array("layers", "LAYERS"), "LAYER", $row['wmssource']); echo "\"wms_get_legend_url\" \"{$wmsCon}&REQUEST=getlegendgraphic\"\n"; } ?> <?php if ($layerArr['data'][0]['query_buffer']) { echo "\"appformap_query_buffer\" \"" . $layerArr['data'][0]['query_buffer'] . "\"\n"; } ?> END PROJECTION "init=epsg:<?php echo $row['srid']; ?> " END TEMPLATE "test" <?php if (is_array($classArr['data'])) { foreach ($classArr['data'] as $class) { ?> CLASS #NAME <?php if ($class['name']) { echo "NAME '" . $class['name'] . "'\n"; } ?> #EXPRESSION <?php if ($class['expression']) { if ($layerArr['data'][0]['theme_column']) { echo "EXPRESSION \"" . $class['expression'] . "\"\n"; } else { echo "EXPRESSION (" . $class['expression'] . ")\n"; } } elseif (!$class['expression'] and $layerArr['data'][0]['theme_column']) { echo "EXPRESSION ''\n"; } ?> #MAXSCALEDENOM <?php if ($class['class_maxscaledenom']) { echo "MAXSCALEDENOM {$class['class_maxscaledenom']}\n"; } ?> #MINSCALEDENOM <?php if ($class['class_minscaledenom']) { echo "MINSCALEDENOM {$class['class_minscaledenom']}\n"; } ?> STYLE #SYMBOL <?php if ($class['symbol']) { echo "SYMBOL '" . $class['symbol'] . "'\n"; } ?> #PATTERN <?php if ($class['pattern']) { echo "PATTERN " . $class['pattern'] . " END\n"; } ?> #LINECAP <?php if ($class['linecap']) { echo "LINECAP " . $class['linecap'] . "\n"; } ?> #WIDTH <?php if ($class['width']) { echo "WIDTH " . $class['width'] . "\n"; } ?> #COLOR <?php if ($class['color']) { echo "COLOR " . Util::hex2RGB($class['color'], true, " ") . "\n"; } ?> #OUTLINECOLOR <?php if ($class['outlinecolor']) { echo "OUTLINECOLOR " . Util::hex2RGB($class['outlinecolor'], true, " ") . "\n"; } ?> #OPACITY <?php if ($class['style_opacity']) { echo "OPACITY " . $class['style_opacity'] . "\n"; } ?> #SIZE <?php if ($class['size']) { if (is_numeric($class['size'])) { echo "SIZE " . $class['size']; } else { echo "SIZE [{$class['size']}]"; } } echo "\n"; ?> #ANGLE <?php if ($class['angle']) { if (is_numeric($class['angle'])) { echo "ANGLE " . $class['angle']; } else { echo "ANGLE [{$class['angle']}]"; } } echo "\n"; ?> END # style STYLE #SYMBOL <?php if ($class['overlaysymbol']) { echo "SYMBOL '" . $class['overlaysymbol'] . "'\n"; } ?> #PATTERN <?php if ($class['overlaypattern']) { echo "PATTERN " . $class['overlaypattern'] . " END\n"; } ?> #LINECAP <?php if ($class['overlaylinecap']) { echo "LINECAP " . $class['overlaylinecap'] . "\n"; } ?> #WIDTH <?php if ($class['overlaywidth']) { echo "WIDTH " . $class['overlaywidth'] . "\n"; } ?> #COLOR <?php if ($class['overlaycolor']) { echo "COLOR " . Util::hex2RGB($class['overlaycolor'], true, " ") . "\n"; } ?> #OUTLINECOLOR <?php if ($class['overlayoutlinecolor']) { echo "OUTLINECOLOR " . Util::hex2RGB($class['overlayoutlinecolor'], true, " ") . "\n"; } ?> #OPACITY <?php if ($class['overlaystyle_opacity']) { echo "OPACITY " . $class['overlaystyle_opacity'] . "\n"; } ?> #SIZE <?php if ($class['overlaysize']) { if (is_numeric($class['overlaysize'])) { echo "SIZE " . $class['overlaysize']; } else { echo "SIZE [{$class['overlaysize']}]"; } } echo "\n"; ?> #ANGLE <?php if ($class['overlayangle']) { if (is_numeric($class['overlayangle'])) { echo "ANGLE " . $class['overlayangle']; } else { echo "ANGLE [{$class['overlayangle']}]"; } } echo "\n"; ?> END # style #TEMPLATE "ttt" #LABEL <?php if ($class['label']) { ?> LABEL <?php if ($class['label_text']) { echo "TEXT '" . $class['label_text'] . "'\n"; } ?> TYPE truetype FONT <?php echo ($class['label_font'] ?: "arial") . ($class['label_fontweight'] ?: "normal"); ?> SIZE <?php if ($class['label_size']) { if (is_numeric($class['label_size'])) { echo $class['label_size']; } else { echo "[{$class['label_size']}]"; } } else { echo "11"; } echo "\n"; ?> COLOR <?php echo $class['label_color'] ? Util::hex2RGB($class['label_color'], true, " ") : "1 1 1"; echo "\n"; ?> OUTLINECOLOR <?php echo $class['label_outlinecolor'] ? Util::hex2RGB($class['label_outlinecolor'], true, " ") : "255 255 255"; echo "\n"; ?> SHADOWSIZE 2 2 ANTIALIAS true FORCE <?php echo $class['label_force'] ? "true" : "false"; echo "\n"; ?> POSITION <?php echo $class['label_position'] ?: "auto"; echo "\n"; ?> PARTIALS false MINSIZE 6 <?php if ($class['label_maxscaledenom']) { echo "MAXSCALEDENOM {$class['label_maxscaledenom']}\n"; } ?> <?php if ($class['label_minscaledenom']) { echo "MINSCALEDENOM {$class['label_minscaledenom']}\n"; } ?> <?php if ($class['label_buffer']) { echo "BUFFER {$class['label_buffer']}\n"; } ?> <?php if ($class['label_repeatdistance']) { echo "REPEATDISTANCE {$class['label_repeatdistance']}\n"; } ?> <?php if ($class['label_expression']) { echo "EXPRESSION (" . $class['label_expression'] . ")\n"; } ?> #ANGLE <?php if ($class['label_angle']) { if (is_numeric($class['label_angle']) or $class['label_angle'] == 'auto' or $class['label_angle'] == 'auto2' or $class['label_angle'] == 'follow') { echo "ANGLE " . $class['label_angle']; } else { echo "ANGLE [{$class['label_angle']}]"; } } echo "\n"; ?> WRAP "\n" OFFSET <?php echo $class['label_offsetx'] ?: "0"; ?> <?php echo $class['label_offsety'] ?: "0"; ?> STYLE <?php if ($class['label_backgroundcolor']) { $labelBackgroundColor = Util::hex2RGB($class['label_backgroundcolor'], true, " "); echo "GEOMTRANSFORM 'labelpoly'\n" . "COLOR {$labelBackgroundColor}\n"; echo "OUTLINECOLOR {$labelBackgroundColor}\n" . "WIDTH " . ($class['label_backgroundpadding'] ?: "1") . "\n"; } ?> END # STYLE END #Label <?php } ?> #LABEL2 <?php if ($class['label2']) { ?> LABEL <?php if ($class['label2_text']) { echo "TEXT '" . $class['label2_text'] . "'\n"; } ?> TYPE truetype FONT <?php echo ($class['label2_font'] ? $class['label2_font'] : "arial") . $class['label2_fontweight'] ?: "normal"; ?> SIZE <?php if ($class['label2_size']) { if (is_numeric($class['label2_size'])) { echo $class['label2_size']; } else { echo "[{$class['label2_size']}]"; } } else { echo "11"; } echo "\n"; ?> COLOR <?php echo $class['label2_color'] ? Util::hex2RGB($class['label2_color'], true, " ") : "1 1 1"; echo "\n"; ?> OUTLINECOLOR <?php echo $class['label2_outlinecolor'] ? Util::hex2RGB($class['label2_outlinecolor'], true, " ") : "255 255 255"; echo "\n"; ?> SHADOWSIZE 2 2 ANTIALIAS true FORCE <?php echo $class['label2_force'] ? "true" : "false"; echo "\n"; ?> POSITION <?php echo $class['label2_position'] ?: "auto"; echo "\n"; ?> PARTIALS false MINSIZE 6 <?php if ($class['label2_maxscaledenom']) { echo "MAXSCALEDENOM {$class['label2_maxscaledenom']}\n"; } ?> <?php if ($class['label2_minscaledenom']) { echo "MINSCALEDENOM {$class['label2_minscaledenom']}\n"; } ?> <?php if ($class['label2_buffer']) { echo "BUFFER {$class['label2_buffer']}\n"; } ?> <?php if ($class['label2_repeatdistance']) { echo "REPEATDISTANCE {$class['label2_repeatdistance']}\n"; } ?> <?php if ($class['label2_expression']) { echo "EXPRESSION (" . $class['label2_expression'] . ")\n"; } ?> #ANGLE <?php if ($class['label2_angle']) { if (is_numeric($class['label2_angle']) or $class['label2_angle'] == 'auto' or $class['label2_angle'] == 'auto2' or $class['label2_angle'] == 'follow') { echo "ANGLE " . $class['label2_angle']; } else { echo "ANGLE [{$class['label2_angle']}]"; } } echo "\n"; ?> WRAP "\n" OFFSET <?php echo $class['label2_offsetx'] ?: "0"; ?> <?php echo $class['label2_offsety'] ?: "0"; ?> STYLE <?php if ($class['label2_backgroundcolor']) { $labelBackgroundColor = Util::hex2RGB($class['label2_backgroundcolor'], true, " "); echo "GEOMTRANSFORM 'labelpoly'\n" . "COLOR {$labelBackgroundColor}\n"; if ($class['label2_backgroundpadding']) { echo "OUTLINECOLOR {$labelBackgroundColor}\n" . "WIDTH {$class['label2_backgroundpadding']}\n"; } } ?> END # STYLE END #Label <?php } ?> <?php if ($class['leader']) { ?> LEADER GRIDSTEP <?php echo $class['leader_gridstep'] ? $class['leader_gridstep'] : "5"; echo "\n"; ?> MAXDISTANCE <?php echo $class['leader_maxdistance'] ? $class['leader_maxdistance'] : "30"; echo "\n"; ?> STYLE COLOR <?php echo $class['leader_color'] ? Util::hex2RGB($class['leader_color'], true, " ") : "1 1 1"; echo "\n"; ?> WIDTH 1 END END <?php } ?> END # Class <?php } } ?> END #Layer <?php } } ?> END #MapFile <?php $data = ob_get_clean(); $path = App::$param['path'] . "/app/wms/mapfiles/"; $name = Connection::$param['postgisdb'] . "_" . Connection::$param['postgisschema'] . ".map"; @unlink($path . $name); $fh = fopen($path . $name, 'w'); fwrite($fh, $data); fclose($fh); return array("success" => true, "message" => "Mapfile written", "ch" => $path . $name); }
function makeExceptionReport($value) { global $sessionComment; ob_get_clean(); ob_start(); //$postgisObject->rollback(); echo '<ServiceExceptionReport version="1.2.0" xmlns="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/ogc http://wfs.plansystem.dk:80/geoserver/schemas//wfs/1.0.0/OGC-exception.xsd"> <ServiceException>'; if (is_array($value)) { if (sizeof($value) == 1) { print $value[0]; } else { print_r($value); } } else { print $value; } echo '</ServiceException> </ServiceExceptionReport>'; $data = ob_get_clean(); header("HTTP/1.0 400 " . \app\inc\Util::httpCodeText("400")); echo $data; print "\n" . $sessionComment; Log::write($data); die; }
function __construct() { $this->clientIp = Util::clientIp(); $this->host = App::$param['logstashHost'] ?: "http://127.0.0.1:1337"; }