Commit e53ad9f4ab51d088c958125406dcf5c939eccaf6
1 parent
2c8f444c
Exists in
master
correcao no cache de imagens
Showing
5 changed files
with
11 additions
and
882 deletions
Show diff stats
classesphp/mapa_googleearth.php
| ... | ... | @@ -35,6 +35,7 @@ Arquivo: |
| 35 | 35 | i3geo/classesphp/mapa_googleearth.php |
| 36 | 36 | |
| 37 | 37 | */ |
| 38 | +include("sani_request.php"); | |
| 38 | 39 | //error_reporting(0); |
| 39 | 40 | error_reporting(0); |
| 40 | 41 | //para efeitos de compatibilidade |
| ... | ... | @@ -245,7 +246,7 @@ function retornaWms($map_fileX,$postgis_mapa){ |
| 245 | 246 | { |
| 246 | 247 | if($img->imagepath == "") |
| 247 | 248 | {echo "Erro IMAGEPATH vazio";exit;} |
| 248 | - $nomer = ($img->imagepath)."filtroimgtemp".nomeRandomico(); | |
| 249 | + $nomer = ($img->imagepath)."filtroimgtemp".nomeRandomico().".png"; | |
| 249 | 250 | $img->saveImage($nomer); |
| 250 | 251 | filtraImagem($nomer,$_GET["TIPOIMAGEM"]); |
| 251 | 252 | $img = imagecreatefrompng($nomer); |
| ... | ... | @@ -259,7 +260,7 @@ function retornaWms($map_fileX,$postgis_mapa){ |
| 259 | 260 | ob_clean(); |
| 260 | 261 | if($img->imagepath == "") |
| 261 | 262 | {echo "Erro IMAGEPATH vazio";exit;} |
| 262 | - $nomer = ($img->imagepath)."imgtemp".nomeRandomico(); | |
| 263 | + $nomer = ($img->imagepath)."imgtemp".nomeRandomico().".png"; | |
| 263 | 264 | $img->saveImage($nomer); |
| 264 | 265 | $img = imagecreatefrompng($nomer); |
| 265 | 266 | imagealphablending($img, false); | ... | ... |
classesphp/mapa_googlemaps.php
| ... | ... | @@ -61,6 +61,7 @@ i3geo/classesphp/mapa_googlemaps.php |
| 61 | 61 | */ |
| 62 | 62 | //error_reporting(0); |
| 63 | 63 | error_reporting(0); |
| 64 | +include("sani_request.php"); | |
| 64 | 65 | //para efeitos de compatibilidade |
| 65 | 66 | if (!function_exists('ms_GetVersion')){ |
| 66 | 67 | include_once ("carrega_ext.php"); |
| ... | ... | @@ -482,7 +483,7 @@ function salvaCacheImagem(){ |
| 482 | 483 | } |
| 483 | 484 | $c = $cachedir."/googlemaps/$layer/$z/$x"; |
| 484 | 485 | if(!file_exists($c."/$y.png")){ |
| 485 | - mkdir($cachedir."/googlemaps/$layer/$z/$x",0774,true); | |
| 486 | + mkdir($cachedir."/googlemaps/$layer/$z/$x",0777,true); | |
| 486 | 487 | $img->saveImage($c."/$y.png"); |
| 487 | 488 | // |
| 488 | 489 | //corta a imagem gerada para voltar ao tamanho normal |
| ... | ... | @@ -491,8 +492,8 @@ function salvaCacheImagem(){ |
| 491 | 492 | $img = cortaImagemDisco($c."/$y.png",$cortePixels,256); |
| 492 | 493 | } |
| 493 | 494 | |
| 494 | - chmod($cachedir."/googlemaps/$layer/$z/$x",0774); | |
| 495 | - chmod($c."/$y.png",0774); | |
| 495 | + chmod($cachedir."/googlemaps/$layer/$z/$x",0777); | |
| 496 | + chmod($c."/$y.png",0777); | |
| 496 | 497 | } |
| 497 | 498 | return $c."/$y.png"; |
| 498 | 499 | } | ... | ... |
classesphp/mapa_googlemaps_alternativo.php
| ... | ... | @@ -1,447 +0,0 @@ |
| 1 | -<?php | |
| 2 | -/* | |
| 3 | -Title: mapa_googlemaps.php | |
| 4 | - | |
| 5 | -Faz o processamento de um mapfile segundo as necessidades do i3geo, como por exemplo, fazendo a substituição | |
| 6 | -das variáveis de conexão com banco e outras operações específicas do i3Geo. | |
| 7 | - | |
| 8 | -É utilizado especificamente nas interfaces que utilizam a biblioteca Googlemaps. | |
| 9 | - | |
| 10 | -Precisa do codigo da "section" PHP aberta pelo i3Geo ou o codigo para acesso especial indicado no parâmetro telaR | |
| 11 | -(veja a ferramenta TELAREMOTA). | |
| 12 | - | |
| 13 | -Parametros: | |
| 14 | - | |
| 15 | -g_sid {string} - codigo da "section" PHP | |
| 16 | - | |
| 17 | -telaR {string} - (opcional) utilizado para autorizar o uso do mapfile aberto (deve estar registrado em $fingerprint (variável de seção) | |
| 18 | - | |
| 19 | -tipolayer {fundo|} - (opcional) indica que a imagem a ser produzida compõe o fundo do mapa | |
| 20 | - | |
| 21 | -BBOX {xmin xmax ymin ymax} - extensão geográfica a ser utilizada no desenho do mapa | |
| 22 | - | |
| 23 | -WIDTH {numeric} - largura do mapa | |
| 24 | - | |
| 25 | -HEIGHT {numeric} - altura do mapa | |
| 26 | - | |
| 27 | -layer {string} - codigo do layer existente no mapa que será desenhado (ignorado quando telaR for definido) | |
| 28 | - | |
| 29 | -DESLIGACACHE {sim|nao} - força a não usar o cache de imagens qd definido como "sim", do contrário, o uso ou não do cache será definido automaticamente | |
| 30 | - | |
| 31 | -TIPOIMAGEM {cinza|sepiaclara|sepianormal|negativo|detectaBordas|embassa|gaussian_blur|selective_blur|mean_removal|pixelate | |
| 32 | -} - filtro de imagem que será aplicado na imagem | |
| 33 | - | |
| 34 | - | |
| 35 | -Licenca: | |
| 36 | - | |
| 37 | -GPL2 | |
| 38 | - | |
| 39 | -i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet | |
| 40 | - | |
| 41 | -Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil | |
| 42 | -Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com | |
| 43 | - | |
| 44 | -Este programa é software livre; você pode redistribuí-lo | |
| 45 | -e/ou modificá-lo sob os termos da Licença Pública Geral | |
| 46 | -GNU conforme publicada pela Free Software Foundation; | |
| 47 | - | |
| 48 | -Este programa é distribuído na expectativa de que seja útil, | |
| 49 | -porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita | |
| 50 | -de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. | |
| 51 | -Consulte a Licença Pública Geral do GNU para mais detalhes. | |
| 52 | -Você deve ter recebido uma copia da Licença Pública Geral do | |
| 53 | -GNU junto com este programa; se não, escreva para a | |
| 54 | -Free Software Foundation, Inc., no endereço | |
| 55 | -59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
| 56 | - | |
| 57 | -Arquivo: | |
| 58 | - | |
| 59 | -i3geo/classesphp/mapa_googlemaps.php | |
| 60 | - | |
| 61 | -*/ | |
| 62 | -//error_reporting(0); | |
| 63 | -error_reporting(0); | |
| 64 | -clearstatcache(); | |
| 65 | -//verificação de segurança | |
| 66 | -$_SESSION = array(); | |
| 67 | -session_name("i3GeoPHP"); | |
| 68 | -if(@$_GET["g_sid"]){ | |
| 69 | - session_id($_GET["g_sid"]); | |
| 70 | -} | |
| 71 | -else{ | |
| 72 | - ilegal(); | |
| 73 | -} | |
| 74 | -session_start(); | |
| 75 | -if(@$_SESSION["fingerprint"]){ | |
| 76 | - $f = explode(",",$_SESSION["fingerprint"]); | |
| 77 | - if (md5('I3GEOSEC' . $_SERVER['HTTP_USER_AGENT'] . session_id()) != $f[0] && !in_array($_GET["telaR"],$f) ){ | |
| 78 | - ilegal(); | |
| 79 | - } | |
| 80 | -} | |
| 81 | -else{ | |
| 82 | - exit; | |
| 83 | -} | |
| 84 | -if(!isset($_SESSION["map_file"])){ | |
| 85 | - exit; | |
| 86 | -} | |
| 87 | -// | |
| 88 | -$map_fileX = $_SESSION["map_file"]; | |
| 89 | -$postgis_mapa = $_SESSION["postgis_mapa"]; | |
| 90 | -$cachedir = $_SESSION["cachedir"]; | |
| 91 | -// | |
| 92 | -//converte a requisição do tile em coordenadas geo | |
| 93 | -//http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#tile_numbers_to_lon.2Flat_2 | |
| 94 | -// | |
| 95 | -$x = $_GET["X"]; | |
| 96 | -$y = $_GET["Y"]; | |
| 97 | -$z = $_GET["Z"]; | |
| 98 | - | |
| 99 | -$qyfile = dirname($map_fileX)."/".$_GET["layer"].".php"; | |
| 100 | -$qy = file_exists($qyfile); | |
| 101 | - | |
| 102 | -if($qy == false && $_GET["cache"] == "sim" && $_GET["DESLIGACACHE"] != "sim"){ | |
| 103 | - carregaCacheImagem($_SESSION["cachedir"],$_SESSION["map_file"],$_GET["tms"]); | |
| 104 | -} | |
| 105 | - | |
| 106 | -$n = pow(2,$z); | |
| 107 | -$lon1 = $x / $n * 360.0 - 180.0; | |
| 108 | -$lat2 = rad2deg(atan(sinh(pi() * (1 - 2 * $y / $n)))); | |
| 109 | -$x++; | |
| 110 | -$y++; | |
| 111 | -$lon2 = $x / $n * 360.0 - 180.0; | |
| 112 | -$lat1 = rad2deg(atan(sinh(pi() * (1 - 2 * $y / $n)))); | |
| 113 | -$x--; | |
| 114 | -$y--; | |
| 115 | - | |
| 116 | -$projInObj = ms_newprojectionobj("proj=latlong,a=6378137,b=6378137"); | |
| 117 | -$projOutObj = ms_newprojectionobj("proj=merc,a=6378137,b=6378137,lat_ts=0.0,lon_0=0.0,x_0=0.0,y_0=0,k=1.0,units=m"); | |
| 118 | - | |
| 119 | -$poPoint1 = ms_newpointobj(); | |
| 120 | -$poPoint1->setXY($lon1, $lat1); | |
| 121 | -$poPoint1->project($projInObj, $projOutObj); | |
| 122 | -$poPoint2 = ms_newpointobj(); | |
| 123 | -$poPoint2->setXY($lon2, $lat2); | |
| 124 | -$poPoint2->project($projInObj, $projOutObj); | |
| 125 | -$_GET["BBOX"] = $poPoint1->x." ".$poPoint1->y." ".$poPoint2->x." ".$poPoint2->y; | |
| 126 | -$_GET["mapext"] = str_replace(","," ",$_GET["BBOX"]); | |
| 127 | - | |
| 128 | -$mapa = ms_newMapObj($map_fileX); | |
| 129 | -$ret = $mapa->extent; | |
| 130 | - | |
| 131 | -$cache = false; | |
| 132 | -if(!isset($_GET["telaR"])){ | |
| 133 | - //no caso de projecoes remotas, o mapfile nao e alterado | |
| 134 | - $numlayers = $mapa->numlayers; | |
| 135 | - for ($i=0;$i < $numlayers;++$i){ | |
| 136 | - $l = $mapa->getlayer($i); | |
| 137 | - $layerName = $l->name; | |
| 138 | - $l->set("status",MS_OFF); | |
| 139 | - if($layerName == $_GET["layer"] || $l->group == $_GET["layer"] && $l->group != ""){ | |
| 140 | - $l->set("template","none.htm"); | |
| 141 | - $l->set("status",MS_DEFAULT); | |
| 142 | - //corrige um bug do mapserver que nao calcula a escala direito | |
| 143 | - $l->set("maxscaledenom",$l->maxscaledenom * 100000); | |
| 144 | - $l->set("minscaledenom",$l->minscaledenom * 100000); | |
| 145 | - if ($l->getmetadata("classesnome") != ""){ | |
| 146 | - if(!function_exists("autoClasses")){ | |
| 147 | - include_once("funcoes_gerais.php"); | |
| 148 | - } | |
| 149 | - autoClasses($l,$mapa); | |
| 150 | - } | |
| 151 | - if(!empty($postgis_mapa)){ | |
| 152 | - if($l->connectiontype == MS_POSTGIS){ | |
| 153 | - $lcon = $l->connection; | |
| 154 | - if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){ | |
| 155 | - if(($lcon == " ") || ($lcon == "")){ | |
| 156 | - $l->set("connection",$postgis_mapa); | |
| 157 | - } | |
| 158 | - else{ | |
| 159 | - $l->set("connection",$postgis_mapa[$lcon]); | |
| 160 | - } | |
| 161 | - } | |
| 162 | - } | |
| 163 | - } | |
| 164 | - if($l->getProjection() == "" ){ | |
| 165 | - $l->setProjection("proj=latlong,a=6378137,b=6378137"); | |
| 166 | - } | |
| 167 | - } | |
| 168 | - if($layerName == $_GET["layer"]){ | |
| 169 | - if(strtolower($l->getmetadata("cache")) == "sim"){ | |
| 170 | - $cache = true; | |
| 171 | - } | |
| 172 | - } | |
| 173 | - } | |
| 174 | -} | |
| 175 | -else{ | |
| 176 | - $mapa->setProjection("proj=merc,a=6378137,b=6378137,lat_ts=0.0,lon_0=0.0,x_0=0.0,y_0=0,k=1.0,units=m"); | |
| 177 | - $numlayers = $mapa->numlayers; | |
| 178 | - for ($i=0;$i < $numlayers;++$i){ | |
| 179 | - $l = $mapa->getlayer($i); | |
| 180 | - if($l->getProjection() == "" ) | |
| 181 | - {$l->setProjection("proj=latlong,a=6378137,b=6378137");} | |
| 182 | - } | |
| 183 | -} | |
| 184 | -if($_GET["layer"] == "") | |
| 185 | -{$cache = true;} | |
| 186 | - | |
| 187 | -if(($_GET == false) || ($qy) || (strtolower($_GET["DESLIGACACHE"]) == "sim")) | |
| 188 | -{$cache = false;} | |
| 189 | -elseif(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum") | |
| 190 | -{$cache = false;} | |
| 191 | - | |
| 192 | -if($cache == true){ | |
| 193 | - carregaCacheImagem(); | |
| 194 | -} | |
| 195 | -$mapa->setsize(256,256); | |
| 196 | -$mapext = explode(" ",$_GET["mapext"]); | |
| 197 | -$mapa->setExtent($mapext[0],$mapext[1],$mapext[2],$mapext[3]); | |
| 198 | - | |
| 199 | -$o = $mapa->outputformat; | |
| 200 | -$o->set("imagemode",MS_IMAGEMODE_RGBA); | |
| 201 | - | |
| 202 | -if(!isset($_GET["telaR"])){ | |
| 203 | - $legenda = $mapa->legend; | |
| 204 | - $legenda->set("status",MS_OFF); | |
| 205 | - $escala = $mapa->scalebar; | |
| 206 | - $escala->set("status",MS_OFF); | |
| 207 | -} | |
| 208 | -// | |
| 209 | -//se o layer nao for do tipo fundo | |
| 210 | -// | |
| 211 | -if($_GET["tipolayer"] != "fundo") | |
| 212 | -{$o->set("transparent",MS_TRUE);} | |
| 213 | -if(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum") | |
| 214 | -{$o->setOption("QUANTIZE_FORCE","OFF");} | |
| 215 | -if($qy != true){ | |
| 216 | - $img = $mapa->draw(); | |
| 217 | -} | |
| 218 | -else{ | |
| 219 | - $handle = fopen ($qyfile, "r"); | |
| 220 | - $conteudo = fread ($handle, filesize ($qyfile)); | |
| 221 | - fclose ($handle); | |
| 222 | - $shp = unserialize($conteudo); | |
| 223 | - $l = $mapa->getLayerByname($_GET["layer"]); | |
| 224 | - $indxlayer = $l->index; | |
| 225 | - if ($l->connectiontype !== MS_POSTGIS){ | |
| 226 | - foreach ($shp as $indx) | |
| 227 | - {$mapa->querybyindex($indxlayer,-1,$indx,MS_TRUE);} | |
| 228 | - $qm = $mapa->querymap; | |
| 229 | - $qm->set("width",255); | |
| 230 | - $qm->set("height",255); | |
| 231 | - $img = $mapa->drawQuery(); | |
| 232 | - } | |
| 233 | - else{ | |
| 234 | - $img = $mapa->draw(); | |
| 235 | - $c = $mapa->querymap->color; | |
| 236 | - $numclasses = $l->numclasses; | |
| 237 | - if ($numclasses > 0) | |
| 238 | - { | |
| 239 | - $classe0 = $l->getClass(0); | |
| 240 | - $classe0->setexpression(""); | |
| 241 | - $classe0->set("name"," "); | |
| 242 | - for ($i=1; $i < $numclasses; ++$i) | |
| 243 | - { | |
| 244 | - $classe = $l->getClass($i); | |
| 245 | - $classe->set("status",MS_DELETE); | |
| 246 | - } | |
| 247 | - } | |
| 248 | - $cor = $classe0->getstyle(0)->color; | |
| 249 | - $cor->setrgb($c->red,$c->green,$c->blue); | |
| 250 | - $cor = $classe0->getstyle(0)->outlinecolor; | |
| 251 | - $cor->setrgb($c->red,$c->green,$c->blue); | |
| 252 | - $v = versaoMS(); | |
| 253 | - if($v["principal"] == 6){ | |
| 254 | - $l->open(); | |
| 255 | - foreach ($shp as $indx){ | |
| 256 | - $shape = $l->getShape(new resultObj($indx)); | |
| 257 | - $shape->draw($mapa,$l,$img); | |
| 258 | - } | |
| 259 | - $l->close(); | |
| 260 | - } | |
| 261 | - else{ | |
| 262 | - $l->open(); | |
| 263 | - foreach ($shp as $indx){ | |
| 264 | - $shape = $l->getfeature($indx,-1); | |
| 265 | - $shape->draw($mapa,$l,$img); | |
| 266 | - } | |
| 267 | - $l->close(); | |
| 268 | - } | |
| 269 | - } | |
| 270 | -} | |
| 271 | -if (!function_exists('imagepng')){ | |
| 272 | - $s = PHP_SHLIB_SUFFIX; | |
| 273 | - @dl( 'php_gd.'.$s ); | |
| 274 | - if (!function_exists('imagepng')) | |
| 275 | - {@dl( 'php_gd2.'.$s );} | |
| 276 | - if (!function_exists('imagepng')) | |
| 277 | - {$_GET["TIPOIMAGEM"] = "";} | |
| 278 | -} | |
| 279 | -if(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum"){ | |
| 280 | - if($img->imagepath == "") | |
| 281 | - {echo "Erro IMAGEPATH vazio";exit;} | |
| 282 | - $nomer = ($img->imagepath)."filtroimgtemp".nomeRand().".png"; | |
| 283 | - $img->saveImage($nomer); | |
| 284 | - filtraImg($nomer,trim($_GET["TIPOIMAGEM"])); | |
| 285 | - $img = imagecreatefrompng($nomer); | |
| 286 | - imagealphablending($img, false); | |
| 287 | - imagesavealpha($img, true); | |
| 288 | - ob_clean(); | |
| 289 | - echo header("Content-type: image/png \n\n"); | |
| 290 | - imagepng($img); | |
| 291 | -} | |
| 292 | -else{ | |
| 293 | - if($cache == true){ | |
| 294 | - $nomer = salvaCacheImagem(); | |
| 295 | - header('Content-Length: '.filesize($nomer)); | |
| 296 | - header('Content-Type: image/png'); | |
| 297 | - header('Cache-Control: max-age=3600, must-revalidate'); | |
| 298 | - header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); | |
| 299 | - header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nomer)).' GMT', true, 200); | |
| 300 | - fpassthru(fopen($nomer, 'rb')); | |
| 301 | - } | |
| 302 | - else{ | |
| 303 | - $nomer = ($img->imagepath)."temp".nomeRand().".png"; | |
| 304 | - $img->saveImage($nomer); | |
| 305 | - $img = imagecreatefrompng($nomer); | |
| 306 | - imagealphablending($img, false); | |
| 307 | - imagesavealpha($img, true); | |
| 308 | - ob_clean(); | |
| 309 | - echo header("Content-type: image/png \n\n"); | |
| 310 | - imagepng($img); | |
| 311 | - imagedestroy($img); | |
| 312 | - } | |
| 313 | - exit; | |
| 314 | -} | |
| 315 | -//$cachedir e definido no ms_configura.php | |
| 316 | -function salvaCacheImagem(){ | |
| 317 | - global $img,$cachedir,$x,$y,$z,$map_fileX; | |
| 318 | - $layer = $_GET["layer"]; | |
| 319 | - if($layer == "") | |
| 320 | - {$layer = "fundo";} | |
| 321 | - if($cachedir == ""){ | |
| 322 | - $cachedir = dirname(dirname($map_fileX))."/cache"; | |
| 323 | - } | |
| 324 | - $c = $cachedir."/googlemaps/$layer/$z/$x"; | |
| 325 | - if(!file_exists($c."/$y.png")){ | |
| 326 | - mkdir($cachedir."/googlemaps/$layer/$z/$x",0774,true); | |
| 327 | - $img->saveImage($c."/$y.png"); | |
| 328 | - chmod($c."/$y.png",0774); | |
| 329 | - } | |
| 330 | - return $nome; | |
| 331 | -} | |
| 332 | -function carregaCacheImagem(){ | |
| 333 | - global $img,$cachedir,$x,$y,$z,$map_fileX; | |
| 334 | - $layer = $_GET["layer"]; | |
| 335 | - if($layer == "") | |
| 336 | - {$layer = "fundo";} | |
| 337 | - if($cachedir == ""){ | |
| 338 | - $cachedir = dirname(dirname($map_fileX))."/cache"; | |
| 339 | - } | |
| 340 | - $c = $cachedir."/googlemaps/$layer/$z/$x"; | |
| 341 | - if(file_exists($c."/$y.png")){ | |
| 342 | - header('Content-Length: '.filesize($c."/$y.png")); | |
| 343 | - header('Content-Type: image/png'); | |
| 344 | - fpassthru(fopen($c."/$y.png", 'rb')); | |
| 345 | - exit; | |
| 346 | - } | |
| 347 | -} | |
| 348 | -/* | |
| 349 | -function salvaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ | |
| 350 | - global $img,$map_size; | |
| 351 | - //layers que são sempre iguais | |
| 352 | - //error_reporting(0); | |
| 353 | - if($layer == "copyright" || $layer == "") | |
| 354 | - {$bbox = "";} | |
| 355 | - if($layer == "") | |
| 356 | - {$layer = "fundo";} | |
| 357 | - if($cachedir == "") | |
| 358 | - {$cachedir = dirname(dirname($map))."/cache/googlemaps/".$layer;} | |
| 359 | - else | |
| 360 | - {$cachedir = $cachedir."/googlemaps/".$layer;} | |
| 361 | - @mkdir($cachedir,0777); | |
| 362 | - $nome = $cachedir."/".$w.$h.$bbox.".png"; | |
| 363 | - if(!file_exists($nome)) | |
| 364 | - {$img->saveImage($nome);} | |
| 365 | - return $nome; | |
| 366 | -} | |
| 367 | -function carregaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ | |
| 368 | - if($layer == "copyright" || $layer == "") | |
| 369 | - {$bbox = "";} | |
| 370 | - if($layer == "") | |
| 371 | - {$layer = "fundo";} | |
| 372 | - $nome = $w.$h.$bbox.".png"; | |
| 373 | - if($cachedir == "") | |
| 374 | - {$nome = dirname(dirname($map))."/cache/googlemaps/".$layer."/".$nome;} | |
| 375 | - else | |
| 376 | - {$nome = $cachedir."/googlemaps/".$layer."/".$nome;} | |
| 377 | - if(file_exists($nome)){ | |
| 378 | - header('Content-Length: '.filesize($nome)); | |
| 379 | - header('Content-Type: image/png'); | |
| 380 | - fpassthru(fopen($nome, 'rb')); | |
| 381 | - exit; | |
| 382 | - } | |
| 383 | -} | |
| 384 | -*/ | |
| 385 | -function nomeRand($n=10) | |
| 386 | -{ | |
| 387 | - $nomes = ""; | |
| 388 | - $a = 'azertyuiopqsdfghjklmwxcvbnABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
| 389 | - $max = 51; | |
| 390 | - for($i=0; $i < $n; ++$i) | |
| 391 | - {$nomes .= $a{mt_rand(0, $max)};} | |
| 392 | - return $nomes; | |
| 393 | -} | |
| 394 | -function filtraImg($nomer,$tipoimagem){ | |
| 395 | - include_once("classe_imagem.php"); | |
| 396 | - $tiposImagem = explode(" ",$tipoimagem); | |
| 397 | - foreach ($tiposImagem as $tipoimagem){ | |
| 398 | - $m = new Imagem($nomer); | |
| 399 | - if ($tipoimagem == "cinza") | |
| 400 | - {imagepng($m->cinzaNormal(),str_replace("\\","/",$nomer));} | |
| 401 | - if ($tipoimagem == "sepiaclara") | |
| 402 | - {imagepng($m->sepiaClara(),str_replace("\\","/",$nomer));} | |
| 403 | - if ($tipoimagem == "sepianormal") | |
| 404 | - {imagepng($m->sepiaNormal(),str_replace("\\","/",$nomer));} | |
| 405 | - if ($tipoimagem == "negativo") | |
| 406 | - {imagepng($m->negativo(),str_replace("\\","/",$nomer));} | |
| 407 | - if ($tipoimagem == "detectaBordas") | |
| 408 | - {imagepng($m->detectaBordas(),str_replace("\\","/",$nomer));} | |
| 409 | - if ($tipoimagem == "embassa") | |
| 410 | - {imagepng($m->embassa(),str_replace("\\","/",$nomer));} | |
| 411 | - if ($tipoimagem == "gaussian_blur") | |
| 412 | - {imagepng($m->gaussian_blur(),str_replace("\\","/",$nomer));} | |
| 413 | - if ($tipoimagem == "selective_blur") | |
| 414 | - {imagepng($m->selective_blur(),str_replace("\\","/",$nomer));} | |
| 415 | - if ($tipoimagem == "mean_removal") | |
| 416 | - {imagepng($m->mean_removal(),str_replace("\\","/",$nomer));} | |
| 417 | - if ($tipoimagem == "pixelate") | |
| 418 | - {imagepng($m->pixelate(),str_replace("\\","/",$nomer));} | |
| 419 | - } | |
| 420 | -} | |
| 421 | -function ilegal(){ | |
| 422 | - $img = imagecreatefrompng("../imagens/ilegal.png"); | |
| 423 | - imagealphablending($img, false); | |
| 424 | - imagesavealpha($img, true); | |
| 425 | - ob_clean(); | |
| 426 | - echo header("Content-type: image/png \n\n"); | |
| 427 | - imagepng($img); | |
| 428 | - exit; | |
| 429 | -} | |
| 430 | -function versaoMS() | |
| 431 | -{ | |
| 432 | - $v = "5.0.0"; | |
| 433 | - $vs = explode(" ",ms_GetVersion()); | |
| 434 | - $cvs = count($vs); | |
| 435 | - for ($i=0;$i<$cvs;++$i) | |
| 436 | - { | |
| 437 | - if(trim(strtolower($vs[$i])) == "version") | |
| 438 | - { | |
| 439 | - $v = $vs[$i+1]; | |
| 440 | - } | |
| 441 | - } | |
| 442 | - $versao["completa"] = $v; | |
| 443 | - $v = explode(".",$v); | |
| 444 | - $versao["principal"] = $v[0]; | |
| 445 | - return $versao; | |
| 446 | -} | |
| 447 | -?> |
classesphp/mapa_openlayers.php
| ... | ... | @@ -59,6 +59,7 @@ Arquivo: |
| 59 | 59 | i3geo/classesphp/mapa_openlayers.php |
| 60 | 60 | |
| 61 | 61 | */ |
| 62 | +include("sani_request.php"); | |
| 62 | 63 | //para efeitos de compatibilidade |
| 63 | 64 | if (!function_exists('ms_GetVersion')){ |
| 64 | 65 | include_once ("carrega_ext.php"); |
| ... | ... | @@ -145,7 +146,7 @@ if(!empty($_GET["request"])){ |
| 145 | 146 | // |
| 146 | 147 | //resolve o problema da selecao nas versoes mais recentes nova do mapserver |
| 147 | 148 | // |
| 148 | -$qyfile = dirname($map_fileX)."/".$_GET["layer"].".php"; | |
| 149 | +$qyfile = dirname($map_fileX)."/".$_GET["layer"]; | |
| 149 | 150 | $qy = file_exists($qyfile); |
| 150 | 151 | |
| 151 | 152 | if($_GET["REQUEST"] == "getlegendgraphic" || $_GET["REQUEST"] == "getfeatureinfo" || $_GET["REQUEST"] == "GetFeatureInfo" || strtolower($_GET["REQUEST"]) == "getfeature"){ |
| ... | ... | @@ -493,6 +494,7 @@ function salvaCacheImagem($cachedir,$map,$tms){ |
| 493 | 494 | else{ |
| 494 | 495 | $nome = $cachedir.$tms; |
| 495 | 496 | } |
| 497 | + $nome = $nome.".png"; | |
| 496 | 498 | if(!file_exists($nome)){ |
| 497 | 499 | @mkdir(dirname($nome),0774,true); |
| 498 | 500 | chmod(dirname($nome),0774); |
| ... | ... | @@ -514,6 +516,7 @@ function carregaCacheImagem($cachedir,$map,$tms,$i3georendermode=0){ |
| 514 | 516 | else{ |
| 515 | 517 | $nome = $cachedir.$tms; |
| 516 | 518 | } |
| 519 | + $nome = $nome.".png"; | |
| 517 | 520 | if(file_exists($nome)){ |
| 518 | 521 | if($i3georendermode = 0 || $i3georendermode = 1 || empty($i3georendermode)){ |
| 519 | 522 | header('Content-Length: '.filesize($nome)); | ... | ... |
classesphp/mapa_openlayers_alternativo.php
| ... | ... | @@ -1,429 +0,0 @@ |
| 1 | -<?php | |
| 2 | -/* | |
| 3 | -Title: mapa_openlayers.php | |
| 4 | - | |
| 5 | -Faz o processamento de um mapfile segundo as necessidades do i3geo, como por exemplo, fazendo a substituição | |
| 6 | -das variáveis de conexão com banco e outras operações específicas do i3Geo. | |
| 7 | - | |
| 8 | -É utilizado especificamente nas interfaces que utilizam a biblioteca OpenLayers em LAYERS do tipo WMS. | |
| 9 | - | |
| 10 | -Precisa do codigo da "section" PHP aberta pelo i3Geo ou o codigo para acesso especial indicado no parâmetro telaR | |
| 11 | -(veja a ferramenta TELAREMOTA). | |
| 12 | - | |
| 13 | -Parametros: | |
| 14 | - | |
| 15 | -g_sid {string} - codigo da "section" PHP | |
| 16 | - | |
| 17 | -telaR {string} - (opcional) utilizado para autorizar o uso do mapfile aberto (deve estar registrado em $fingerprint (variável de seção) | |
| 18 | - | |
| 19 | -tipolayer {fundo|} - (opcional) indica que a imagem a ser produzida compõe o fundo do mapa | |
| 20 | - | |
| 21 | -BBOX {xmin xmax ymin ymax} - extensão geográfica a ser utilizada no desenho do mapa | |
| 22 | - | |
| 23 | -WIDTH {numeric} - largura do mapa | |
| 24 | - | |
| 25 | -HEIGHT {numeric} - altura do mapa | |
| 26 | - | |
| 27 | -layer {string} - codigo do layer existente no mapa que será desenhado (ignorado quando telaR for definido) | |
| 28 | - | |
| 29 | -DESLIGACACHE {sim|nao} - força a não usar o cache de imagens qd definido como "sim", do contrário, o uso ou não do cache será definido automaticamente | |
| 30 | - | |
| 31 | -TIPOIMAGEM {cinza|sepiaclara|sepianormal|negativo|detectaBordas|embassa|gaussian_blur|selective_blur|mean_removal|pixelate | |
| 32 | -} - filtro de imagem que será aplicado na imagem | |
| 33 | - | |
| 34 | -Licenca: | |
| 35 | - | |
| 36 | -GPL2 | |
| 37 | - | |
| 38 | -i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet | |
| 39 | - | |
| 40 | -Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil | |
| 41 | -Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com | |
| 42 | - | |
| 43 | -Este programa é software livre; você pode redistribuí-lo | |
| 44 | -e/ou modificá-lo sob os termos da Licença Pública Geral | |
| 45 | -GNU conforme publicada pela Free Software Foundation; | |
| 46 | - | |
| 47 | -Este programa é distribuído na expectativa de que seja útil, | |
| 48 | -porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita | |
| 49 | -de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. | |
| 50 | -Consulte a Licença Pública Geral do GNU para mais detalhes. | |
| 51 | -Você deve ter recebido uma cópia da Licença Pública Geral do | |
| 52 | -GNU junto com este programa; se não, escreva para a | |
| 53 | -Free Software Foundation, Inc., no endereço | |
| 54 | -59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
| 55 | - | |
| 56 | -Arquivo: | |
| 57 | - | |
| 58 | -i3geo/classesphp/mapa_openlayers.php | |
| 59 | - | |
| 60 | -*/ | |
| 61 | -error_reporting(0); | |
| 62 | -//para efeitos de compatibilidade | |
| 63 | -if (!function_exists('ms_GetVersion')){ | |
| 64 | - include_once ("carrega_ext.php"); | |
| 65 | -} | |
| 66 | -//carrega dados da seção, verifica segurança | |
| 67 | -inicializa(); | |
| 68 | -// | |
| 69 | -//calcula a extensao geografica com base no x,y,z | |
| 70 | -//nos casos do modo notile, a requisicao e feita como se fosse um wms | |
| 71 | -//quando for do tipo tms $_GET["tms"] contem os parametros do tile | |
| 72 | -if(isset($_GET["tms"])){ | |
| 73 | - $_GET["WIDTH"] = 256; | |
| 74 | - $_GET["HEIGHT"] = 256; | |
| 75 | - $temp = explode("/",$_GET["tms"]); | |
| 76 | - $z = $temp[2]; | |
| 77 | - $x = $temp[3]; | |
| 78 | - $y = str_replace(".png","",$temp[4]); | |
| 79 | - | |
| 80 | - $n = pow(2,$z+1); | |
| 81 | - $lon1 = $x / $n * 360.0 - 180.0; | |
| 82 | - $lon2 = ($x+1) / $n * 360.0 - 180.0; | |
| 83 | - $n = pow(2,$z); | |
| 84 | - $lat1 = $y / $n * 180.0 - 90.0; | |
| 85 | - $lat2 = ($y+1) / $n * 180.0 - 90.0; | |
| 86 | - $_GET["BBOX"] = $lon1." ".$lat1." ".$lon2." ".$lat2; | |
| 87 | -} | |
| 88 | -$map_fileX = $_SESSION["map_file"]; | |
| 89 | -// | |
| 90 | -//resolve o problema da seleção na versão nova do mapserver | |
| 91 | -// | |
| 92 | -$qyfile = dirname($map_fileX)."/".$_GET["layer"].".php"; | |
| 93 | -$qy = file_exists($qyfile); | |
| 94 | - | |
| 95 | -if($qy == false && $_GET["cache"] == "sim" && $_GET["DESLIGACACHE"] != "sim"){ | |
| 96 | - carregaCacheImagem($_SESSION["cachedir"],$_SESSION["map_file"],$_GET["tms"]); | |
| 97 | -} | |
| 98 | -// | |
| 99 | -//map_fileX e para o caso register_globals = On no PHP.INI | |
| 100 | - | |
| 101 | -if(isset($_GET["tipolayer"]) && $_GET["tipolayer"] == "fundo"){ | |
| 102 | - $map_fileX = str_replace(".map","fundo.map",$map_fileX); | |
| 103 | -} | |
| 104 | -$postgis_mapa = $_SESSION["postgis_mapa"]; | |
| 105 | -$cachedir = $_SESSION["cachedir"]; | |
| 106 | -if(isset($_GET["BBOX"])){ | |
| 107 | - $_GET["mapext"] = str_replace(","," ",$_GET["BBOX"]); | |
| 108 | - $_GET["map_size"] = $_GET["WIDTH"]." ".$_GET["HEIGHT"]; | |
| 109 | -} | |
| 110 | -$_GET["TIPOIMAGEM"] = trim($_GET["TIPOIMAGEM"]); | |
| 111 | -$mapa = ms_newMapObj($map_fileX); | |
| 112 | - | |
| 113 | -// | |
| 114 | -//processa os layers do mapfile | |
| 115 | -// | |
| 116 | -if(!isset($_GET["telaR"])){//no caso de projecoes remotas, o mapfile nao e alterado | |
| 117 | - $numlayers = $mapa->numlayers; | |
| 118 | - $cache = false; | |
| 119 | - for($i = 0;$i < $numlayers;++$i){ | |
| 120 | - $l = $mapa->getLayer($i); | |
| 121 | - $layerName = $l->name; | |
| 122 | - if($layerName != $_GET["layer"]){ | |
| 123 | - $l->set("status",MS_OFF); | |
| 124 | - } | |
| 125 | - if($layerName == $_GET["layer"] || $l->group == $_GET["layer"] && $l->group != ""){ | |
| 126 | - if ($l->getmetadata("classesnome") != ""){ | |
| 127 | - if(!function_exists("autoClasses")) | |
| 128 | - {include_once("funcoes_gerais.php");} | |
| 129 | - autoClasses($l,$mapa); | |
| 130 | - } | |
| 131 | - $l->set("status",MS_DEFAULT); | |
| 132 | - $l->set("template","none.htm"); | |
| 133 | - if (!empty($postgis_mapa)){ | |
| 134 | - if ($l->connectiontype == MS_POSTGIS){ | |
| 135 | - $lcon = $l->connection; | |
| 136 | - if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){ | |
| 137 | - if(($lcon == " ") || ($lcon == "")) | |
| 138 | - {$l->set("connection",$postgis_mapa);} | |
| 139 | - else | |
| 140 | - {$l->set("connection",$postgis_mapa[$lcon]);} | |
| 141 | - } | |
| 142 | - } | |
| 143 | - } | |
| 144 | - } | |
| 145 | - if($layerName == $_GET["layer"]){ | |
| 146 | - if(strtolower($l->getmetadata("cache")) == "sim"){ | |
| 147 | - $cache = true; | |
| 148 | - $nomecache = $l->getmetadata("nomeoriginal"); | |
| 149 | - if($nomecache == ""){ | |
| 150 | - $nomecache = $layerName; | |
| 151 | - } | |
| 152 | - } | |
| 153 | - } | |
| 154 | - if($_GET["REQUEST"] == "GetFeatureInfo" || $_GET["REQUEST"] == "getfeature"){ | |
| 155 | - $l->setmetadata("gml_include_items","all"); | |
| 156 | - $l->setmetadata("WMS_INCLUDE_ITEMS","all"); | |
| 157 | - $l->setmetadata("WFS_INCLUDE_ITEMS","all"); | |
| 158 | - $l->setmetadata("ows_enable_request","*"); | |
| 159 | - $l->set("dump",MS_TRUE); | |
| 160 | - $l->setmetadata("ows_srs","AUTO"); | |
| 161 | - } | |
| 162 | - } | |
| 163 | -} | |
| 164 | -if (!function_exists('imagepng')) | |
| 165 | -{$_GET["TIPOIMAGEM"] = "";} | |
| 166 | - | |
| 167 | -if($_GET["layer"] == "") | |
| 168 | -{$cache = true;} | |
| 169 | - | |
| 170 | -if(($_GET == false) || ($qy) || (strtolower($_GET["DESLIGACACHE"]) == "sim")){ | |
| 171 | - $cache = false; | |
| 172 | -} | |
| 173 | -elseif($_GET["TIPOIMAGEM"] != "" && $_GET["TIPOIMAGEM"] != "nenhum") | |
| 174 | -{$cache = false;} | |
| 175 | - | |
| 176 | -if($cache == true && $_GET["cache"] != "nao"){ | |
| 177 | - //carregaCacheImagem($cachedir,$_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]); | |
| 178 | - carregaCacheImagem($cachedir,$map,$_GET["tms"]); | |
| 179 | -} | |
| 180 | -$map_size = explode(" ",$_GET["map_size"]); | |
| 181 | -$mapa->setsize($map_size[0],$map_size[1]); | |
| 182 | -if(isset($_GET["mapext"])){ | |
| 183 | - $mapext = explode(" ",$_GET["mapext"]); | |
| 184 | - $mapa->setExtent($mapext[0],$mapext[1],$mapext[2],$mapext[3]); | |
| 185 | -} | |
| 186 | -// | |
| 187 | -//qd a cahamda e para um WMS, redireciona para ogc.php | |
| 188 | -// | |
| 189 | -if($_GET["REQUEST"] == "GetFeatureInfo" || $_GET["request"] == "getfeature"){ | |
| 190 | - $req = ms_newowsrequestobj(); | |
| 191 | - $_GET = array_merge($_GET,$_POST); | |
| 192 | - foreach ($_GET as $k=>$v){ | |
| 193 | - $req->setParameter($k, $v); | |
| 194 | - } | |
| 195 | - $proto = "http" . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "s" : "") . "://"; | |
| 196 | - $server = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']; | |
| 197 | - $or = $proto.$server.$_SERVER['PHP_SELF']; | |
| 198 | - $mapa->setmetadata("wfs_onlineresource",$or."?".$_SERVER["QUERY_STRING"]); | |
| 199 | - | |
| 200 | - ms_ioinstallstdouttobuffer(); | |
| 201 | - $mapa->owsdispatch($req); | |
| 202 | - $contenttype = ms_iostripstdoutbuffercontenttype(); | |
| 203 | - header("Content-type: $contenttype"); | |
| 204 | - ms_iogetStdoutBufferBytes(); | |
| 205 | - ms_ioresethandlers(); | |
| 206 | - exit; | |
| 207 | -} | |
| 208 | - | |
| 209 | -$o = $mapa->outputformat; | |
| 210 | -$o->set("imagemode",MS_IMAGEMODE_RGBA); | |
| 211 | -if(!isset($_GET["telaR"])){ | |
| 212 | - $legenda = $mapa->legend; | |
| 213 | - $legenda->set("status",MS_OFF); | |
| 214 | - $escala = $mapa->scalebar; | |
| 215 | - $escala->set("status",MS_OFF); | |
| 216 | -} | |
| 217 | -// | |
| 218 | -//se o layer não for do tipo fundo | |
| 219 | -// | |
| 220 | -if($_GET["tipolayer"] != "fundo") | |
| 221 | -{$o->set("transparent",MS_TRUE);} | |
| 222 | -if($qy != true) | |
| 223 | -{$img = $mapa->draw();} | |
| 224 | -else{ | |
| 225 | - $handle = fopen ($qyfile, "r"); | |
| 226 | - $conteudo = fread ($handle, filesize ($qyfile)); | |
| 227 | - fclose ($handle); | |
| 228 | - $shp = unserialize($conteudo); | |
| 229 | - $l = $mapa->getLayerByname($_GET["layer"]); | |
| 230 | - if ($l->connectiontype != MS_POSTGIS){ | |
| 231 | - $indxlayer = $l->index; | |
| 232 | - foreach ($shp as $indx) | |
| 233 | - {$mapa->querybyindex($indxlayer,-1,$indx,MS_TRUE);} | |
| 234 | - $qm = $mapa->querymap; | |
| 235 | - $qm->set("width",$map_size[0]); | |
| 236 | - $qm->set("height",$map_size[1]); | |
| 237 | - $img = $mapa->drawQuery(); | |
| 238 | - } | |
| 239 | - else{ | |
| 240 | - $img = $mapa->draw(); | |
| 241 | - $c = $mapa->querymap->color; | |
| 242 | - $numclasses = $l->numclasses; | |
| 243 | - if ($numclasses > 0) | |
| 244 | - { | |
| 245 | - $classe0 = $l->getClass(0); | |
| 246 | - $classe0->setexpression(""); | |
| 247 | - $classe0->set("name"," "); | |
| 248 | - for ($i=1; $i < $numclasses; ++$i) | |
| 249 | - { | |
| 250 | - $classe = $l->getClass($i); | |
| 251 | - $classe->set("status",MS_DELETE); | |
| 252 | - } | |
| 253 | - } | |
| 254 | - $cor = $classe0->getstyle(0)->color; | |
| 255 | - $cor->setrgb($c->red,$c->green,$c->blue); | |
| 256 | - $cor = $classe0->getstyle(0)->outlinecolor; | |
| 257 | - $cor->setrgb($c->red,$c->green,$c->blue); | |
| 258 | - $status = $l->open(); | |
| 259 | - $status = $l->whichShapes($mapa->extent); | |
| 260 | - while ($shape = $l->nextShape()) | |
| 261 | - { | |
| 262 | - if(in_array($shape->index,$shp)) | |
| 263 | - $shape->draw($mapa,$l,$img); | |
| 264 | - } | |
| 265 | - $l->close(); | |
| 266 | - } | |
| 267 | - $cache = false; | |
| 268 | -} | |
| 269 | -if($_GET["TIPOIMAGEM"] != "" && $_GET["TIPOIMAGEM"] != "nenhum"){ | |
| 270 | - if($img->imagepath == "") | |
| 271 | - {echo "Erro IMAGEPATH vazio";exit;} | |
| 272 | - $nomer = ($img->imagepath)."filtroimgtemp".nomeRand().".png"; | |
| 273 | - $img->saveImage($nomer); | |
| 274 | - filtraImg($nomer,$_GET["TIPOIMAGEM"]); | |
| 275 | - $img = imagecreatefrompng($nomer); | |
| 276 | - imagealphablending($img, false); | |
| 277 | - imagesavealpha($img, true); | |
| 278 | - ob_clean(); | |
| 279 | - echo header("Content-type: image/png \n\n"); | |
| 280 | - imagepng($img); | |
| 281 | - imagedestroy($img); | |
| 282 | -} | |
| 283 | -else{ | |
| 284 | - if($cache == true && $_GET["cache"] != "nao"){ | |
| 285 | - //$nomer = salvaCacheImagem($cachedir,$_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]); | |
| 286 | - $nomer = salvaCacheImagem($cachedir,$map_fileX,$_GET["tms"]); | |
| 287 | - header('Content-Length: '.filesize($nomer)); | |
| 288 | - header('Content-Type: image/png'); | |
| 289 | - header('Cache-Control: max-age=3600, must-revalidate'); | |
| 290 | - header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); | |
| 291 | - header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nomer)).' GMT', true, 200); | |
| 292 | - fpassthru(fopen($nomer, 'rb')); | |
| 293 | - } | |
| 294 | - else{ | |
| 295 | - if($img->imagepath == "") | |
| 296 | - {echo "Erro IMAGEPATH vazio";exit;} | |
| 297 | - $nomer = ($img->imagepath)."temp".nomeRand().".png"; | |
| 298 | - $img->saveImage($nomer); | |
| 299 | - $img = imagecreatefrompng($nomer); | |
| 300 | - imagealphablending($img, false); | |
| 301 | - imagesavealpha($img, true); | |
| 302 | - ob_clean(); | |
| 303 | - echo header("Content-type: image/png \n\n"); | |
| 304 | - imagepng($img); | |
| 305 | - imagedestroy($img); | |
| 306 | - } | |
| 307 | -} | |
| 308 | -function salvaCacheImagem($cachedir,$map,$tms){ | |
| 309 | - global $img; | |
| 310 | - if($cachedir == ""){ | |
| 311 | - $nome = dirname(dirname($map))."/cache".$tms; | |
| 312 | - } | |
| 313 | - else{ | |
| 314 | - $nome = $cachedir.$tms; | |
| 315 | - } | |
| 316 | - if(!file_exists($nome)){ | |
| 317 | - @mkdir(dirname($nome),0777,true); | |
| 318 | - $img->saveImage($nome); | |
| 319 | - chmod($nome,0777); | |
| 320 | - } | |
| 321 | - return $nome; | |
| 322 | -} | |
| 323 | -function carregaCacheImagem($cachedir,$map,$tms){ | |
| 324 | - if($cachedir == ""){ | |
| 325 | - $nome = dirname(dirname($map))."/cache".$tms; | |
| 326 | - } | |
| 327 | - else{ | |
| 328 | - $nome = $cachedir.$tms; | |
| 329 | - } | |
| 330 | - if(file_exists($nome)){ | |
| 331 | - header('Content-Length: '.filesize($nome)); | |
| 332 | - header('Content-Type: image/png'); | |
| 333 | - header('Cache-Control: max-age=3600, must-revalidate'); | |
| 334 | - header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); | |
| 335 | - header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200); | |
| 336 | - $etag = md5_file($nome); | |
| 337 | - header('Etag: '.$etag); | |
| 338 | - fpassthru(fopen($nome, 'rb')); | |
| 339 | - exit; | |
| 340 | - } | |
| 341 | -} | |
| 342 | -function XcarregaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ | |
| 343 | - if($layer == "copyright" || $layer == "") | |
| 344 | - {$bbox = "";} | |
| 345 | - if($layer == "") | |
| 346 | - {$layer = "fundo";} | |
| 347 | - $nome = $w.$h.$bbox.".png"; | |
| 348 | - if($cachedir == "") | |
| 349 | - {$nome = dirname(dirname($map))."/cache/".$layer."/".$nome;} | |
| 350 | - else | |
| 351 | - {$nome = $cachedir."/".$layer."/".$nome;} | |
| 352 | - if(file_exists($nome)){ | |
| 353 | - header('Content-Length: '.filesize($nome)); | |
| 354 | - header('Content-Type: image/png'); | |
| 355 | - header('Cache-Control: max-age=3600, must-revalidate'); | |
| 356 | - header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); | |
| 357 | - header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200); | |
| 358 | - $etag = md5_file($nome); | |
| 359 | - header('Etag: '.$etag); | |
| 360 | - fpassthru(fopen($nome, 'rb')); | |
| 361 | - exit; | |
| 362 | - } | |
| 363 | -} | |
| 364 | -function nomeRand($n=10) | |
| 365 | -{ | |
| 366 | - $nomes = ""; | |
| 367 | - $a = 'azertyuiopqsdfghjklmwxcvbnABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
| 368 | - $max = 51; | |
| 369 | - for($i=0; $i < $n; ++$i) | |
| 370 | - {$nomes .= $a{mt_rand(0, $max)};} | |
| 371 | - return $nomes; | |
| 372 | -} | |
| 373 | -function filtraImg($nomer,$tipoimagem){ | |
| 374 | - include_once("classe_imagem.php"); | |
| 375 | - $tiposImagem = explode(" ",$tipoimagem); | |
| 376 | - foreach ($tiposImagem as $tipoimagem){ | |
| 377 | - $m = new Imagem($nomer); | |
| 378 | - if ($tipoimagem == "cinza") | |
| 379 | - {imagepng($m->cinzaNormal(),str_replace("\\","/",$nomer));} | |
| 380 | - if ($tipoimagem == "sepiaclara") | |
| 381 | - {imagepng($m->sepiaClara(),str_replace("\\","/",$nomer));} | |
| 382 | - if ($tipoimagem == "sepianormal") | |
| 383 | - {imagepng($m->sepiaNormal(),str_replace("\\","/",$nomer));} | |
| 384 | - if ($tipoimagem == "negativo") | |
| 385 | - {imagepng($m->negativo(),str_replace("\\","/",$nomer));} | |
| 386 | - if ($tipoimagem == "detectaBordas") | |
| 387 | - {imagepng($m->detectaBordas(),str_replace("\\","/",$nomer));} | |
| 388 | - if ($tipoimagem == "embassa") | |
| 389 | - {imagepng($m->embassa(),str_replace("\\","/",$nomer));} | |
| 390 | - if ($tipoimagem == "gaussian_blur") | |
| 391 | - {imagepng($m->gaussian_blur(),str_replace("\\","/",$nomer));} | |
| 392 | - if ($tipoimagem == "selective_blur") | |
| 393 | - {imagepng($m->selective_blur(),str_replace("\\","/",$nomer));} | |
| 394 | - if ($tipoimagem == "mean_removal") | |
| 395 | - {imagepng($m->mean_removal(),str_replace("\\","/",$nomer));} | |
| 396 | - if ($tipoimagem == "pixelate") | |
| 397 | - {imagepng($m->pixelate(),str_replace("\\","/",$nomer));} | |
| 398 | - } | |
| 399 | -} | |
| 400 | -function inicializa(){ | |
| 401 | - clearstatcache(); | |
| 402 | - session_name("i3GeoPHP"); | |
| 403 | - if(@$_GET["g_sid"]){ | |
| 404 | - session_id($_GET["g_sid"]); | |
| 405 | - } | |
| 406 | - else{ | |
| 407 | - ilegal(); | |
| 408 | - } | |
| 409 | - session_start(); | |
| 410 | - if(@$_SESSION["fingerprint"]){ | |
| 411 | - $f = explode(",",$_SESSION["fingerprint"]); | |
| 412 | - if (md5('I3GEOSEC' . $_SERVER['HTTP_USER_AGENT'] . session_id()) != $f[0] && !in_array($_GET["telaR"],$f) ) | |
| 413 | - {ilegal();} | |
| 414 | - } | |
| 415 | - else | |
| 416 | - {exit;} | |
| 417 | - if(!isset($_SESSION["map_file"])) | |
| 418 | - {exit;} | |
| 419 | -} | |
| 420 | -function ilegal(){ | |
| 421 | - $img = imagecreatefrompng("../imagens/ilegal.png"); | |
| 422 | - imagealphablending($img, false); | |
| 423 | - imagesavealpha($img, true); | |
| 424 | - ob_clean(); | |
| 425 | - echo header("Content-type: image/png \n\n"); | |
| 426 | - imagepng($img); | |
| 427 | - exit; | |
| 428 | -} | |
| 429 | -?> | |
| 430 | 0 | \ No newline at end of file |