Commit 3198b432b78aea41dca53c314059b660735d35ba
1 parent
64824b26
Exists in
master
and in
7 other branches
--no commit message
Showing
2 changed files
with
48 additions
and
5 deletions
Show diff stats
classesphp/mapa_googlemaps.php
| @@ -294,6 +294,25 @@ else{ | @@ -294,6 +294,25 @@ else{ | ||
| 294 | $nomer = ($img->imagepath)."imgtemp".nomeRand().".png"; | 294 | $nomer = ($img->imagepath)."imgtemp".nomeRand().".png"; |
| 295 | $img->saveImage($nomer); | 295 | $img->saveImage($nomer); |
| 296 | } | 296 | } |
| 297 | + ob_start(); | ||
| 298 | + // assuming you have image data in $imagedata | ||
| 299 | + $img = file_get_contents($nomer); | ||
| 300 | + $length = strlen($img); | ||
| 301 | + $ft = filemtime($nomer); | ||
| 302 | + if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && (strtotime($_SERVER["HTTP_IF_MODIFIED_SINCE"]) == $ft)) { | ||
| 303 | + // Client's cache IS current, so we just respond '304 Not Modified'. | ||
| 304 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', $ft).' GMT', true, 304); | ||
| 305 | + } else { | ||
| 306 | + // Image not cached or cache outdated, we respond '200 OK' and output the image. | ||
| 307 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', $ft).' GMT', true, 200); | ||
| 308 | + } | ||
| 309 | + header('Accept-Ranges: bytes'); | ||
| 310 | + header('Content-Length: '.$length); | ||
| 311 | + header('Content-Type: image/png'); | ||
| 312 | + print($img); | ||
| 313 | + ob_end_flush(); | ||
| 314 | + exit; | ||
| 315 | + /* | ||
| 297 | ob_clean(); | 316 | ob_clean(); |
| 298 | $img = imagecreatefrompng($nomer); | 317 | $img = imagecreatefrompng($nomer); |
| 299 | imagealphablending($img, false); | 318 | imagealphablending($img, false); |
| @@ -301,6 +320,7 @@ else{ | @@ -301,6 +320,7 @@ else{ | ||
| 301 | ob_clean(); | 320 | ob_clean(); |
| 302 | echo header("Content-type: image/png \n\n"); | 321 | echo header("Content-type: image/png \n\n"); |
| 303 | imagepng($img); | 322 | imagepng($img); |
| 323 | + */ | ||
| 304 | } | 324 | } |
| 305 | function salvaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ | 325 | function salvaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ |
| 306 | global $img,$map_size; | 326 | global $img,$map_size; |
classesphp/mapa_openlayers.php
| @@ -59,37 +59,41 @@ i3geo/classesphp/mapa_openlayers.php | @@ -59,37 +59,41 @@ i3geo/classesphp/mapa_openlayers.php | ||
| 59 | 59 | ||
| 60 | */ | 60 | */ |
| 61 | error_reporting(0); | 61 | error_reporting(0); |
| 62 | +//carrega dados da seção, verifica segurança | ||
| 62 | inicializa(); | 63 | inicializa(); |
| 63 | // | 64 | // |
| 64 | //map_fileX é necessário caso register_globals = On no PHP.INI | 65 | //map_fileX é necessário caso register_globals = On no PHP.INI |
| 65 | $map_fileX = $_SESSION["map_file"]; | 66 | $map_fileX = $_SESSION["map_file"]; |
| 66 | -$postgis_mapa = $_SESSION["postgis_mapa"]; | ||
| 67 | -$cachedir = $_SESSION["cachedir"]; | ||
| 68 | if(isset($_GET["tipolayer"]) && $_GET["tipolayer"] == "fundo") | 67 | if(isset($_GET["tipolayer"]) && $_GET["tipolayer"] == "fundo") |
| 69 | {$map_fileX = str_replace(".map","fundo.map",$map_fileX);} | 68 | {$map_fileX = str_replace(".map","fundo.map",$map_fileX);} |
| 69 | +$postgis_mapa = $_SESSION["postgis_mapa"]; | ||
| 70 | +$cachedir = $_SESSION["cachedir"]; | ||
| 70 | if(isset($_GET["BBOX"])){ | 71 | if(isset($_GET["BBOX"])){ |
| 71 | $_GET["mapext"] = str_replace(","," ",$_GET["BBOX"]); | 72 | $_GET["mapext"] = str_replace(","," ",$_GET["BBOX"]); |
| 72 | $_GET["map_size"] = $_GET["WIDTH"]." ".$_GET["HEIGHT"]; | 73 | $_GET["map_size"] = $_GET["WIDTH"]." ".$_GET["HEIGHT"]; |
| 73 | } | 74 | } |
| 74 | -$mapa = ms_newMapObj($map_fileX); //map_file vem de section | 75 | +$mapa = ms_newMapObj($map_fileX); |
| 75 | // | 76 | // |
| 76 | //resolve o problema da seleção na versão nova do mapserver | 77 | //resolve o problema da seleção na versão nova do mapserver |
| 77 | // | 78 | // |
| 78 | $qyfile = dirname($map_fileX)."/".$_GET["layer"].".php"; | 79 | $qyfile = dirname($map_fileX)."/".$_GET["layer"].".php"; |
| 79 | $qy = file_exists($qyfile); | 80 | $qy = file_exists($qyfile); |
| 81 | +// | ||
| 82 | +//processa os layers do mapfile | ||
| 83 | +// | ||
| 80 | if(!isset($_GET["telaR"])){//no caso de projecoes remotas, o mapfile nao e alterado | 84 | if(!isset($_GET["telaR"])){//no caso de projecoes remotas, o mapfile nao e alterado |
| 81 | $numlayers = $mapa->numlayers; | 85 | $numlayers = $mapa->numlayers; |
| 82 | $cache = false; | 86 | $cache = false; |
| 83 | for($i = 0;$i < $numlayers;$i++) | 87 | for($i = 0;$i < $numlayers;$i++) |
| 84 | { | 88 | { |
| 85 | $l = $mapa->getLayer($i); | 89 | $l = $mapa->getLayer($i); |
| 86 | - $layerName = $l->name; | ||
| 87 | if ($l->getmetadata("classesnome") != "") | 90 | if ($l->getmetadata("classesnome") != "") |
| 88 | { | 91 | { |
| 89 | if(!function_exists("autoClasses")) | 92 | if(!function_exists("autoClasses")) |
| 90 | {include_once("funcoes_gerais.php");} | 93 | {include_once("funcoes_gerais.php");} |
| 91 | autoClasses($l,$mapa); | 94 | autoClasses($l,$mapa); |
| 92 | } | 95 | } |
| 96 | + $layerName = $l->name; | ||
| 93 | if($layerName != $_GET["layer"]) | 97 | if($layerName != $_GET["layer"]) |
| 94 | {$l->set("status",MS_OFF);} | 98 | {$l->set("status",MS_OFF);} |
| 95 | if($layerName == $_GET["layer"] || $l->group == $_GET["layer"] && $l->group != "") | 99 | if($layerName == $_GET["layer"] || $l->group == $_GET["layer"] && $l->group != "") |
| @@ -231,7 +235,6 @@ else | @@ -231,7 +235,6 @@ else | ||
| 231 | $l->close(); | 235 | $l->close(); |
| 232 | } | 236 | } |
| 233 | } | 237 | } |
| 234 | - | ||
| 235 | if (!function_exists('imagepng')) | 238 | if (!function_exists('imagepng')) |
| 236 | { | 239 | { |
| 237 | $s = PHP_SHLIB_SUFFIX; | 240 | $s = PHP_SHLIB_SUFFIX; |
| @@ -265,6 +268,25 @@ else{ | @@ -265,6 +268,25 @@ else{ | ||
| 265 | $nomer = ($img->imagepath)."imgtemp".nomeRand().".png"; | 268 | $nomer = ($img->imagepath)."imgtemp".nomeRand().".png"; |
| 266 | $img->saveImage($nomer); | 269 | $img->saveImage($nomer); |
| 267 | } | 270 | } |
| 271 | + ob_start(); | ||
| 272 | + // assuming you have image data in $imagedata | ||
| 273 | + $img = file_get_contents($nomer); | ||
| 274 | + $length = strlen($img); | ||
| 275 | + $ft = filemtime($nomer); | ||
| 276 | + if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) && (strtotime($_SERVER["HTTP_IF_MODIFIED_SINCE"]) == $ft)) { | ||
| 277 | + // Client's cache IS current, so we just respond '304 Not Modified'. | ||
| 278 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', $ft).' GMT', true, 304); | ||
| 279 | + } else { | ||
| 280 | + // Image not cached or cache outdated, we respond '200 OK' and output the image. | ||
| 281 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', $ft).' GMT', true, 200); | ||
| 282 | + } | ||
| 283 | + header('Accept-Ranges: bytes'); | ||
| 284 | + header('Content-Length: '.$length); | ||
| 285 | + header('Content-Type: image/png'); | ||
| 286 | + print($img); | ||
| 287 | + ob_end_flush(); | ||
| 288 | + exit; | ||
| 289 | +/* | ||
| 268 | ob_clean(); | 290 | ob_clean(); |
| 269 | $img = imagecreatefrompng($nomer); | 291 | $img = imagecreatefrompng($nomer); |
| 270 | imagealphablending($img, false); | 292 | imagealphablending($img, false); |
| @@ -273,6 +295,7 @@ else{ | @@ -273,6 +295,7 @@ else{ | ||
| 273 | echo header("Content-type: image/png \n\n"); | 295 | echo header("Content-type: image/png \n\n"); |
| 274 | imagepng($img); | 296 | imagepng($img); |
| 275 | imagedestroy($img); | 297 | imagedestroy($img); |
| 298 | +*/ | ||
| 276 | } | 299 | } |
| 277 | function salvaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ | 300 | function salvaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ |
| 278 | global $img,$map_size; | 301 | global $img,$map_size; |