From 2ae9201fa5873760a4cd497c4a2010627066c487 Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Thu, 4 Aug 2016 00:24:49 -0300 Subject: [PATCH] correcao no cache de imagens --- admin/admin.db | Bin 340992 -> 0 bytes classesphp/mapa_googleearth.php | 5 +++-- classesphp/mapa_googlemaps.php | 1 + classesphp/mapa_googlemaps_alternativo.php | 447 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- classesphp/mapa_openlayers.php | 5 ++++- classesphp/mapa_openlayers_alternativo.php | 429 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- temas/_lbiomashp.map | 2 +- 7 files changed, 9 insertions(+), 880 deletions(-) delete mode 100755 classesphp/mapa_googlemaps_alternativo.php delete mode 100755 classesphp/mapa_openlayers_alternativo.php diff --git a/admin/admin.db b/admin/admin.db index 93aea72..4f3ce36 100755 Binary files a/admin/admin.db and b/admin/admin.db differ diff --git a/classesphp/mapa_googleearth.php b/classesphp/mapa_googleearth.php index 057d2b7..dbf55b7 100755 --- a/classesphp/mapa_googleearth.php +++ b/classesphp/mapa_googleearth.php @@ -35,6 +35,7 @@ Arquivo: i3geo/classesphp/mapa_googleearth.php */ +include("sani_request.php"); //error_reporting(0); error_reporting(0); //para efeitos de compatibilidade @@ -245,7 +246,7 @@ function retornaWms($map_fileX,$postgis_mapa){ { if($img->imagepath == "") {echo "Erro IMAGEPATH vazio";exit;} - $nomer = ($img->imagepath)."filtroimgtemp".nomeRandomico(); + $nomer = ($img->imagepath)."filtroimgtemp".nomeRandomico().".png"; $img->saveImage($nomer); filtraImagem($nomer,$_GET["TIPOIMAGEM"]); $img = imagecreatefrompng($nomer); @@ -259,7 +260,7 @@ function retornaWms($map_fileX,$postgis_mapa){ ob_clean(); if($img->imagepath == "") {echo "Erro IMAGEPATH vazio";exit;} - $nomer = ($img->imagepath)."imgtemp".nomeRandomico(); + $nomer = ($img->imagepath)."imgtemp".nomeRandomico().".png"; $img->saveImage($nomer); $img = imagecreatefrompng($nomer); imagealphablending($img, false); diff --git a/classesphp/mapa_googlemaps.php b/classesphp/mapa_googlemaps.php index 99ddf47..c46451b 100755 --- a/classesphp/mapa_googlemaps.php +++ b/classesphp/mapa_googlemaps.php @@ -61,6 +61,7 @@ i3geo/classesphp/mapa_googlemaps.php */ //error_reporting(0); error_reporting(0); +include("sani_request.php"); //para efeitos de compatibilidade if (!function_exists('ms_GetVersion')){ include_once ("carrega_ext.php"); diff --git a/classesphp/mapa_googlemaps_alternativo.php b/classesphp/mapa_googlemaps_alternativo.php deleted file mode 100755 index b438292..0000000 --- a/classesphp/mapa_googlemaps_alternativo.php +++ /dev/null @@ -1,447 +0,0 @@ -setXY($lon1, $lat1); -$poPoint1->project($projInObj, $projOutObj); -$poPoint2 = ms_newpointobj(); -$poPoint2->setXY($lon2, $lat2); -$poPoint2->project($projInObj, $projOutObj); -$_GET["BBOX"] = $poPoint1->x." ".$poPoint1->y." ".$poPoint2->x." ".$poPoint2->y; -$_GET["mapext"] = str_replace(","," ",$_GET["BBOX"]); - -$mapa = ms_newMapObj($map_fileX); -$ret = $mapa->extent; - -$cache = false; -if(!isset($_GET["telaR"])){ - //no caso de projecoes remotas, o mapfile nao e alterado - $numlayers = $mapa->numlayers; - for ($i=0;$i < $numlayers;++$i){ - $l = $mapa->getlayer($i); - $layerName = $l->name; - $l->set("status",MS_OFF); - if($layerName == $_GET["layer"] || $l->group == $_GET["layer"] && $l->group != ""){ - $l->set("template","none.htm"); - $l->set("status",MS_DEFAULT); - //corrige um bug do mapserver que nao calcula a escala direito - $l->set("maxscaledenom",$l->maxscaledenom * 100000); - $l->set("minscaledenom",$l->minscaledenom * 100000); - if ($l->getmetadata("classesnome") != ""){ - if(!function_exists("autoClasses")){ - include_once("funcoes_gerais.php"); - } - autoClasses($l,$mapa); - } - if(!empty($postgis_mapa)){ - if($l->connectiontype == MS_POSTGIS){ - $lcon = $l->connection; - if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){ - if(($lcon == " ") || ($lcon == "")){ - $l->set("connection",$postgis_mapa); - } - else{ - $l->set("connection",$postgis_mapa[$lcon]); - } - } - } - } - if($l->getProjection() == "" ){ - $l->setProjection("proj=latlong,a=6378137,b=6378137"); - } - } - if($layerName == $_GET["layer"]){ - if(strtolower($l->getmetadata("cache")) == "sim"){ - $cache = true; - } - } - } -} -else{ - $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"); - $numlayers = $mapa->numlayers; - for ($i=0;$i < $numlayers;++$i){ - $l = $mapa->getlayer($i); - if($l->getProjection() == "" ) - {$l->setProjection("proj=latlong,a=6378137,b=6378137");} - } -} -if($_GET["layer"] == "") -{$cache = true;} - -if(($_GET == false) || ($qy) || (strtolower($_GET["DESLIGACACHE"]) == "sim")) -{$cache = false;} -elseif(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum") -{$cache = false;} - -if($cache == true){ - carregaCacheImagem(); -} -$mapa->setsize(256,256); -$mapext = explode(" ",$_GET["mapext"]); -$mapa->setExtent($mapext[0],$mapext[1],$mapext[2],$mapext[3]); - -$o = $mapa->outputformat; -$o->set("imagemode",MS_IMAGEMODE_RGBA); - -if(!isset($_GET["telaR"])){ - $legenda = $mapa->legend; - $legenda->set("status",MS_OFF); - $escala = $mapa->scalebar; - $escala->set("status",MS_OFF); -} -// -//se o layer nao for do tipo fundo -// -if($_GET["tipolayer"] != "fundo") -{$o->set("transparent",MS_TRUE);} -if(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum") -{$o->setOption("QUANTIZE_FORCE","OFF");} -if($qy != true){ - $img = $mapa->draw(); -} -else{ - $handle = fopen ($qyfile, "r"); - $conteudo = fread ($handle, filesize ($qyfile)); - fclose ($handle); - $shp = unserialize($conteudo); - $l = $mapa->getLayerByname($_GET["layer"]); - $indxlayer = $l->index; - if ($l->connectiontype !== MS_POSTGIS){ - foreach ($shp as $indx) - {$mapa->querybyindex($indxlayer,-1,$indx,MS_TRUE);} - $qm = $mapa->querymap; - $qm->set("width",255); - $qm->set("height",255); - $img = $mapa->drawQuery(); - } - else{ - $img = $mapa->draw(); - $c = $mapa->querymap->color; - $numclasses = $l->numclasses; - if ($numclasses > 0) - { - $classe0 = $l->getClass(0); - $classe0->setexpression(""); - $classe0->set("name"," "); - for ($i=1; $i < $numclasses; ++$i) - { - $classe = $l->getClass($i); - $classe->set("status",MS_DELETE); - } - } - $cor = $classe0->getstyle(0)->color; - $cor->setrgb($c->red,$c->green,$c->blue); - $cor = $classe0->getstyle(0)->outlinecolor; - $cor->setrgb($c->red,$c->green,$c->blue); - $v = versaoMS(); - if($v["principal"] == 6){ - $l->open(); - foreach ($shp as $indx){ - $shape = $l->getShape(new resultObj($indx)); - $shape->draw($mapa,$l,$img); - } - $l->close(); - } - else{ - $l->open(); - foreach ($shp as $indx){ - $shape = $l->getfeature($indx,-1); - $shape->draw($mapa,$l,$img); - } - $l->close(); - } - } -} -if (!function_exists('imagepng')){ - $s = PHP_SHLIB_SUFFIX; - @dl( 'php_gd.'.$s ); - if (!function_exists('imagepng')) - {@dl( 'php_gd2.'.$s );} - if (!function_exists('imagepng')) - {$_GET["TIPOIMAGEM"] = "";} -} -if(trim($_GET["TIPOIMAGEM"]) != "" && trim($_GET["TIPOIMAGEM"]) != "nenhum"){ - if($img->imagepath == "") - {echo "Erro IMAGEPATH vazio";exit;} - $nomer = ($img->imagepath)."filtroimgtemp".nomeRand().".png"; - $img->saveImage($nomer); - filtraImg($nomer,trim($_GET["TIPOIMAGEM"])); - $img = imagecreatefrompng($nomer); - imagealphablending($img, false); - imagesavealpha($img, true); - ob_clean(); - echo header("Content-type: image/png \n\n"); - imagepng($img); -} -else{ - if($cache == true){ - $nomer = salvaCacheImagem(); - header('Content-Length: '.filesize($nomer)); - header('Content-Type: image/png'); - header('Cache-Control: max-age=3600, must-revalidate'); - header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); - header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nomer)).' GMT', true, 200); - fpassthru(fopen($nomer, 'rb')); - } - else{ - $nomer = ($img->imagepath)."temp".nomeRand().".png"; - $img->saveImage($nomer); - $img = imagecreatefrompng($nomer); - imagealphablending($img, false); - imagesavealpha($img, true); - ob_clean(); - echo header("Content-type: image/png \n\n"); - imagepng($img); - imagedestroy($img); - } - exit; -} -//$cachedir e definido no ms_configura.php -function salvaCacheImagem(){ - global $img,$cachedir,$x,$y,$z,$map_fileX; - $layer = $_GET["layer"]; - if($layer == "") - {$layer = "fundo";} - if($cachedir == ""){ - $cachedir = dirname(dirname($map_fileX))."/cache"; - } - $c = $cachedir."/googlemaps/$layer/$z/$x"; - if(!file_exists($c."/$y.png")){ - mkdir($cachedir."/googlemaps/$layer/$z/$x",0777,true); - $img->saveImage($c."/$y.png"); - chmod($c."/$y.png",0777); - } - return $nome; -} -function carregaCacheImagem(){ - global $img,$cachedir,$x,$y,$z,$map_fileX; - $layer = $_GET["layer"]; - if($layer == "") - {$layer = "fundo";} - if($cachedir == ""){ - $cachedir = dirname(dirname($map_fileX))."/cache"; - } - $c = $cachedir."/googlemaps/$layer/$z/$x"; - if(file_exists($c."/$y.png")){ - header('Content-Length: '.filesize($c."/$y.png")); - header('Content-Type: image/png'); - fpassthru(fopen($c."/$y.png", 'rb')); - exit; - } -} -/* -function salvaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ - global $img,$map_size; - //layers que são sempre iguais - //error_reporting(0); - if($layer == "copyright" || $layer == "") - {$bbox = "";} - if($layer == "") - {$layer = "fundo";} - if($cachedir == "") - {$cachedir = dirname(dirname($map))."/cache/googlemaps/".$layer;} - else - {$cachedir = $cachedir."/googlemaps/".$layer;} - @mkdir($cachedir,0777); - $nome = $cachedir."/".$w.$h.$bbox.".png"; - if(!file_exists($nome)) - {$img->saveImage($nome);} - return $nome; -} -function carregaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ - if($layer == "copyright" || $layer == "") - {$bbox = "";} - if($layer == "") - {$layer = "fundo";} - $nome = $w.$h.$bbox.".png"; - if($cachedir == "") - {$nome = dirname(dirname($map))."/cache/googlemaps/".$layer."/".$nome;} - else - {$nome = $cachedir."/googlemaps/".$layer."/".$nome;} - if(file_exists($nome)){ - header('Content-Length: '.filesize($nome)); - header('Content-Type: image/png'); - fpassthru(fopen($nome, 'rb')); - exit; - } -} -*/ -function nomeRand($n=10) -{ - $nomes = ""; - $a = 'azertyuiopqsdfghjklmwxcvbnABCDEFGHIJKLMNOPQRSTUVWXYZ'; - $max = 51; - for($i=0; $i < $n; ++$i) - {$nomes .= $a{mt_rand(0, $max)};} - return $nomes; -} -function filtraImg($nomer,$tipoimagem){ - include_once("classe_imagem.php"); - $tiposImagem = explode(" ",$tipoimagem); - foreach ($tiposImagem as $tipoimagem){ - $m = new Imagem($nomer); - if ($tipoimagem == "cinza") - {imagepng($m->cinzaNormal(),str_replace("\\","/",$nomer));} - if ($tipoimagem == "sepiaclara") - {imagepng($m->sepiaClara(),str_replace("\\","/",$nomer));} - if ($tipoimagem == "sepianormal") - {imagepng($m->sepiaNormal(),str_replace("\\","/",$nomer));} - if ($tipoimagem == "negativo") - {imagepng($m->negativo(),str_replace("\\","/",$nomer));} - if ($tipoimagem == "detectaBordas") - {imagepng($m->detectaBordas(),str_replace("\\","/",$nomer));} - if ($tipoimagem == "embassa") - {imagepng($m->embassa(),str_replace("\\","/",$nomer));} - if ($tipoimagem == "gaussian_blur") - {imagepng($m->gaussian_blur(),str_replace("\\","/",$nomer));} - if ($tipoimagem == "selective_blur") - {imagepng($m->selective_blur(),str_replace("\\","/",$nomer));} - if ($tipoimagem == "mean_removal") - {imagepng($m->mean_removal(),str_replace("\\","/",$nomer));} - if ($tipoimagem == "pixelate") - {imagepng($m->pixelate(),str_replace("\\","/",$nomer));} - } -} -function ilegal(){ - $img = imagecreatefrompng("../imagens/ilegal.png"); - imagealphablending($img, false); - imagesavealpha($img, true); - ob_clean(); - echo header("Content-type: image/png \n\n"); - imagepng($img); - exit; -} -function versaoMS() -{ - $v = "5.0.0"; - $vs = explode(" ",ms_GetVersion()); - $cvs = count($vs); - for ($i=0;$i<$cvs;++$i) - { - if(trim(strtolower($vs[$i])) == "version") - { - $v = $vs[$i+1]; - } - } - $versao["completa"] = $v; - $v = explode(".",$v); - $versao["principal"] = $v[0]; - return $versao; -} -?> \ No newline at end of file diff --git a/classesphp/mapa_openlayers.php b/classesphp/mapa_openlayers.php index 3908aaf..dd51b8a 100755 --- a/classesphp/mapa_openlayers.php +++ b/classesphp/mapa_openlayers.php @@ -59,6 +59,7 @@ Arquivo: i3geo/classesphp/mapa_openlayers.php */ +include("sani_request.php"); //para efeitos de compatibilidade if (!function_exists('ms_GetVersion')){ include_once ("carrega_ext.php"); @@ -145,7 +146,7 @@ if(!empty($_GET["request"])){ // //resolve o problema da selecao nas versoes mais recentes nova do mapserver // -$qyfile = dirname($map_fileX)."/".$_GET["layer"].".php"; +$qyfile = dirname($map_fileX)."/".$_GET["layer"]; $qy = file_exists($qyfile); if($_GET["REQUEST"] == "getlegendgraphic" || $_GET["REQUEST"] == "getfeatureinfo" || $_GET["REQUEST"] == "GetFeatureInfo" || strtolower($_GET["REQUEST"]) == "getfeature"){ @@ -493,6 +494,7 @@ function salvaCacheImagem($cachedir,$map,$tms){ else{ $nome = $cachedir.$tms; } + $nome = $nome.".png"; if(!file_exists($nome)){ @mkdir(dirname($nome),0774,true); chmod(dirname($nome),0774); @@ -514,6 +516,7 @@ function carregaCacheImagem($cachedir,$map,$tms,$i3georendermode=0){ else{ $nome = $cachedir.$tms; } + $nome = $nome.".png"; if(file_exists($nome)){ if($i3georendermode = 0 || $i3georendermode = 1 || empty($i3georendermode)){ header('Content-Length: '.filesize($nome)); diff --git a/classesphp/mapa_openlayers_alternativo.php b/classesphp/mapa_openlayers_alternativo.php deleted file mode 100755 index 5c530ef..0000000 --- a/classesphp/mapa_openlayers_alternativo.php +++ /dev/null @@ -1,429 +0,0 @@ -numlayers; - $cache = false; - for($i = 0;$i < $numlayers;++$i){ - $l = $mapa->getLayer($i); - $layerName = $l->name; - if($layerName != $_GET["layer"]){ - $l->set("status",MS_OFF); - } - if($layerName == $_GET["layer"] || $l->group == $_GET["layer"] && $l->group != ""){ - if ($l->getmetadata("classesnome") != ""){ - if(!function_exists("autoClasses")) - {include_once("funcoes_gerais.php");} - autoClasses($l,$mapa); - } - $l->set("status",MS_DEFAULT); - $l->set("template","none.htm"); - if (!empty($postgis_mapa)){ - if ($l->connectiontype == MS_POSTGIS){ - $lcon = $l->connection; - if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){ - if(($lcon == " ") || ($lcon == "")) - {$l->set("connection",$postgis_mapa);} - else - {$l->set("connection",$postgis_mapa[$lcon]);} - } - } - } - } - if($layerName == $_GET["layer"]){ - if(strtolower($l->getmetadata("cache")) == "sim"){ - $cache = true; - $nomecache = $l->getmetadata("nomeoriginal"); - if($nomecache == ""){ - $nomecache = $layerName; - } - } - } - if($_GET["REQUEST"] == "GetFeatureInfo" || $_GET["REQUEST"] == "getfeature"){ - $l->setmetadata("gml_include_items","all"); - $l->setmetadata("WMS_INCLUDE_ITEMS","all"); - $l->setmetadata("WFS_INCLUDE_ITEMS","all"); - $l->setmetadata("ows_enable_request","*"); - $l->set("dump",MS_TRUE); - $l->setmetadata("ows_srs","AUTO"); - } - } -} -if (!function_exists('imagepng')) -{$_GET["TIPOIMAGEM"] = "";} - -if($_GET["layer"] == "") -{$cache = true;} - -if(($_GET == false) || ($qy) || (strtolower($_GET["DESLIGACACHE"]) == "sim")){ - $cache = false; -} -elseif($_GET["TIPOIMAGEM"] != "" && $_GET["TIPOIMAGEM"] != "nenhum") -{$cache = false;} - -if($cache == true && $_GET["cache"] != "nao"){ - //carregaCacheImagem($cachedir,$_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]); - carregaCacheImagem($cachedir,$map,$_GET["tms"]); -} -$map_size = explode(" ",$_GET["map_size"]); -$mapa->setsize($map_size[0],$map_size[1]); -if(isset($_GET["mapext"])){ - $mapext = explode(" ",$_GET["mapext"]); - $mapa->setExtent($mapext[0],$mapext[1],$mapext[2],$mapext[3]); -} -// -//qd a cahamda e para um WMS, redireciona para ogc.php -// -if($_GET["REQUEST"] == "GetFeatureInfo" || $_GET["request"] == "getfeature"){ - $req = ms_newowsrequestobj(); - $_GET = array_merge($_GET,$_POST); - foreach ($_GET as $k=>$v){ - $req->setParameter($k, $v); - } - $proto = "http" . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "s" : "") . "://"; - $server = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']; - $or = $proto.$server.$_SERVER['PHP_SELF']; - $mapa->setmetadata("wfs_onlineresource",$or."?".$_SERVER["QUERY_STRING"]); - - ms_ioinstallstdouttobuffer(); - $mapa->owsdispatch($req); - $contenttype = ms_iostripstdoutbuffercontenttype(); - header("Content-type: $contenttype"); - ms_iogetStdoutBufferBytes(); - ms_ioresethandlers(); - exit; -} - -$o = $mapa->outputformat; -$o->set("imagemode",MS_IMAGEMODE_RGBA); -if(!isset($_GET["telaR"])){ - $legenda = $mapa->legend; - $legenda->set("status",MS_OFF); - $escala = $mapa->scalebar; - $escala->set("status",MS_OFF); -} -// -//se o layer não for do tipo fundo -// -if($_GET["tipolayer"] != "fundo") -{$o->set("transparent",MS_TRUE);} -if($qy != true) -{$img = $mapa->draw();} -else{ - $handle = fopen ($qyfile, "r"); - $conteudo = fread ($handle, filesize ($qyfile)); - fclose ($handle); - $shp = unserialize($conteudo); - $l = $mapa->getLayerByname($_GET["layer"]); - if ($l->connectiontype != MS_POSTGIS){ - $indxlayer = $l->index; - foreach ($shp as $indx) - {$mapa->querybyindex($indxlayer,-1,$indx,MS_TRUE);} - $qm = $mapa->querymap; - $qm->set("width",$map_size[0]); - $qm->set("height",$map_size[1]); - $img = $mapa->drawQuery(); - } - else{ - $img = $mapa->draw(); - $c = $mapa->querymap->color; - $numclasses = $l->numclasses; - if ($numclasses > 0) - { - $classe0 = $l->getClass(0); - $classe0->setexpression(""); - $classe0->set("name"," "); - for ($i=1; $i < $numclasses; ++$i) - { - $classe = $l->getClass($i); - $classe->set("status",MS_DELETE); - } - } - $cor = $classe0->getstyle(0)->color; - $cor->setrgb($c->red,$c->green,$c->blue); - $cor = $classe0->getstyle(0)->outlinecolor; - $cor->setrgb($c->red,$c->green,$c->blue); - $status = $l->open(); - $status = $l->whichShapes($mapa->extent); - while ($shape = $l->nextShape()) - { - if(in_array($shape->index,$shp)) - $shape->draw($mapa,$l,$img); - } - $l->close(); - } - $cache = false; -} -if($_GET["TIPOIMAGEM"] != "" && $_GET["TIPOIMAGEM"] != "nenhum"){ - if($img->imagepath == "") - {echo "Erro IMAGEPATH vazio";exit;} - $nomer = ($img->imagepath)."filtroimgtemp".nomeRand().".png"; - $img->saveImage($nomer); - filtraImg($nomer,$_GET["TIPOIMAGEM"]); - $img = imagecreatefrompng($nomer); - imagealphablending($img, false); - imagesavealpha($img, true); - ob_clean(); - echo header("Content-type: image/png \n\n"); - imagepng($img); - imagedestroy($img); -} -else{ - if($cache == true && $_GET["cache"] != "nao"){ - //$nomer = salvaCacheImagem($cachedir,$_GET["BBOX"],$nomecache,$map_fileX,$_GET["WIDTH"],$_GET["HEIGHT"]); - $nomer = salvaCacheImagem($cachedir,$map_fileX,$_GET["tms"]); - header('Content-Length: '.filesize($nomer)); - header('Content-Type: image/png'); - header('Cache-Control: max-age=3600, must-revalidate'); - header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); - header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nomer)).' GMT', true, 200); - fpassthru(fopen($nomer, 'rb')); - } - else{ - if($img->imagepath == "") - {echo "Erro IMAGEPATH vazio";exit;} - $nomer = ($img->imagepath)."temp".nomeRand().".png"; - $img->saveImage($nomer); - $img = imagecreatefrompng($nomer); - imagealphablending($img, false); - imagesavealpha($img, true); - ob_clean(); - echo header("Content-type: image/png \n\n"); - imagepng($img); - imagedestroy($img); - } -} -function salvaCacheImagem($cachedir,$map,$tms){ - global $img; - if($cachedir == ""){ - $nome = dirname(dirname($map))."/cache".$tms; - } - else{ - $nome = $cachedir.$tms; - } - if(!file_exists($nome)){ - @mkdir(dirname($nome),0777,true); - $img->saveImage($nome); - chmod($nome,0777); - } - return $nome; -} -function carregaCacheImagem($cachedir,$map,$tms){ - if($cachedir == ""){ - $nome = dirname(dirname($map))."/cache".$tms; - } - else{ - $nome = $cachedir.$tms; - } - if(file_exists($nome)){ - header('Content-Length: '.filesize($nome)); - header('Content-Type: image/png'); - header('Cache-Control: max-age=3600, must-revalidate'); - header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); - header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200); - $etag = md5_file($nome); - header('Etag: '.$etag); - fpassthru(fopen($nome, 'rb')); - exit; - } -} -function XcarregaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ - if($layer == "copyright" || $layer == "") - {$bbox = "";} - if($layer == "") - {$layer = "fundo";} - $nome = $w.$h.$bbox.".png"; - if($cachedir == "") - {$nome = dirname(dirname($map))."/cache/".$layer."/".$nome;} - else - {$nome = $cachedir."/".$layer."/".$nome;} - if(file_exists($nome)){ - header('Content-Length: '.filesize($nome)); - header('Content-Type: image/png'); - header('Cache-Control: max-age=3600, must-revalidate'); - header('Expires: ' . gmdate('D, d M Y H:i:s', time()+24*60*60) . ' GMT'); - header('Last-Modified: '.gmdate('D, d M Y H:i:s', filemtime($nome)).' GMT', true, 200); - $etag = md5_file($nome); - header('Etag: '.$etag); - fpassthru(fopen($nome, 'rb')); - exit; - } -} -function nomeRand($n=10) -{ - $nomes = ""; - $a = 'azertyuiopqsdfghjklmwxcvbnABCDEFGHIJKLMNOPQRSTUVWXYZ'; - $max = 51; - for($i=0; $i < $n; ++$i) - {$nomes .= $a{mt_rand(0, $max)};} - return $nomes; -} -function filtraImg($nomer,$tipoimagem){ - include_once("classe_imagem.php"); - $tiposImagem = explode(" ",$tipoimagem); - foreach ($tiposImagem as $tipoimagem){ - $m = new Imagem($nomer); - if ($tipoimagem == "cinza") - {imagepng($m->cinzaNormal(),str_replace("\\","/",$nomer));} - if ($tipoimagem == "sepiaclara") - {imagepng($m->sepiaClara(),str_replace("\\","/",$nomer));} - if ($tipoimagem == "sepianormal") - {imagepng($m->sepiaNormal(),str_replace("\\","/",$nomer));} - if ($tipoimagem == "negativo") - {imagepng($m->negativo(),str_replace("\\","/",$nomer));} - if ($tipoimagem == "detectaBordas") - {imagepng($m->detectaBordas(),str_replace("\\","/",$nomer));} - if ($tipoimagem == "embassa") - {imagepng($m->embassa(),str_replace("\\","/",$nomer));} - if ($tipoimagem == "gaussian_blur") - {imagepng($m->gaussian_blur(),str_replace("\\","/",$nomer));} - if ($tipoimagem == "selective_blur") - {imagepng($m->selective_blur(),str_replace("\\","/",$nomer));} - if ($tipoimagem == "mean_removal") - {imagepng($m->mean_removal(),str_replace("\\","/",$nomer));} - if ($tipoimagem == "pixelate") - {imagepng($m->pixelate(),str_replace("\\","/",$nomer));} - } -} -function inicializa(){ - clearstatcache(); - session_name("i3GeoPHP"); - if(@$_GET["g_sid"]){ - session_id($_GET["g_sid"]); - } - else{ - ilegal(); - } - session_start(); - if(@$_SESSION["fingerprint"]){ - $f = explode(",",$_SESSION["fingerprint"]); - if (md5('I3GEOSEC' . $_SERVER['HTTP_USER_AGENT'] . session_id()) != $f[0] && !in_array($_GET["telaR"],$f) ) - {ilegal();} - } - else - {exit;} - if(!isset($_SESSION["map_file"])) - {exit;} -} -function ilegal(){ - $img = imagecreatefrompng("../imagens/ilegal.png"); - imagealphablending($img, false); - imagesavealpha($img, true); - ob_clean(); - echo header("Content-type: image/png \n\n"); - imagepng($img); - exit; -} -?> \ No newline at end of file diff --git a/temas/_lbiomashp.map b/temas/_lbiomashp.map index 44458ef..8341c70 100755 --- a/temas/_lbiomashp.map +++ b/temas/_lbiomashp.map @@ -7,7 +7,7 @@ MAP METADATA "METAESTAT_ID_MEDIDA_VARIAVEL" "" "TIP" "CD_LEGENDA" - "CACHE" "nao" + "CACHE" "sim" "CLASSE" "SIM" "permitekmz" "sim" "ITENSDESC" "Bioma Teste de acentuação" -- libgit2 0.21.2