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 | 294 | $nomer = ($img->imagepath)."imgtemp".nomeRand().".png"; |
| 295 | 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 | 316 | ob_clean(); |
| 298 | 317 | $img = imagecreatefrompng($nomer); |
| 299 | 318 | imagealphablending($img, false); |
| ... | ... | @@ -301,6 +320,7 @@ else{ |
| 301 | 320 | ob_clean(); |
| 302 | 321 | echo header("Content-type: image/png \n\n"); |
| 303 | 322 | imagepng($img); |
| 323 | + */ | |
| 304 | 324 | } |
| 305 | 325 | function salvaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ |
| 306 | 326 | global $img,$map_size; | ... | ... |
classesphp/mapa_openlayers.php
| ... | ... | @@ -59,37 +59,41 @@ i3geo/classesphp/mapa_openlayers.php |
| 59 | 59 | |
| 60 | 60 | */ |
| 61 | 61 | error_reporting(0); |
| 62 | +//carrega dados da seção, verifica segurança | |
| 62 | 63 | inicializa(); |
| 63 | 64 | // |
| 64 | 65 | //map_fileX é necessário caso register_globals = On no PHP.INI |
| 65 | 66 | $map_fileX = $_SESSION["map_file"]; |
| 66 | -$postgis_mapa = $_SESSION["postgis_mapa"]; | |
| 67 | -$cachedir = $_SESSION["cachedir"]; | |
| 68 | 67 | if(isset($_GET["tipolayer"]) && $_GET["tipolayer"] == "fundo") |
| 69 | 68 | {$map_fileX = str_replace(".map","fundo.map",$map_fileX);} |
| 69 | +$postgis_mapa = $_SESSION["postgis_mapa"]; | |
| 70 | +$cachedir = $_SESSION["cachedir"]; | |
| 70 | 71 | if(isset($_GET["BBOX"])){ |
| 71 | 72 | $_GET["mapext"] = str_replace(","," ",$_GET["BBOX"]); |
| 72 | 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 | 77 | //resolve o problema da seleção na versão nova do mapserver |
| 77 | 78 | // |
| 78 | 79 | $qyfile = dirname($map_fileX)."/".$_GET["layer"].".php"; |
| 79 | 80 | $qy = file_exists($qyfile); |
| 81 | +// | |
| 82 | +//processa os layers do mapfile | |
| 83 | +// | |
| 80 | 84 | if(!isset($_GET["telaR"])){//no caso de projecoes remotas, o mapfile nao e alterado |
| 81 | 85 | $numlayers = $mapa->numlayers; |
| 82 | 86 | $cache = false; |
| 83 | 87 | for($i = 0;$i < $numlayers;$i++) |
| 84 | 88 | { |
| 85 | 89 | $l = $mapa->getLayer($i); |
| 86 | - $layerName = $l->name; | |
| 87 | 90 | if ($l->getmetadata("classesnome") != "") |
| 88 | 91 | { |
| 89 | 92 | if(!function_exists("autoClasses")) |
| 90 | 93 | {include_once("funcoes_gerais.php");} |
| 91 | 94 | autoClasses($l,$mapa); |
| 92 | 95 | } |
| 96 | + $layerName = $l->name; | |
| 93 | 97 | if($layerName != $_GET["layer"]) |
| 94 | 98 | {$l->set("status",MS_OFF);} |
| 95 | 99 | if($layerName == $_GET["layer"] || $l->group == $_GET["layer"] && $l->group != "") |
| ... | ... | @@ -231,7 +235,6 @@ else |
| 231 | 235 | $l->close(); |
| 232 | 236 | } |
| 233 | 237 | } |
| 234 | - | |
| 235 | 238 | if (!function_exists('imagepng')) |
| 236 | 239 | { |
| 237 | 240 | $s = PHP_SHLIB_SUFFIX; |
| ... | ... | @@ -265,6 +268,25 @@ else{ |
| 265 | 268 | $nomer = ($img->imagepath)."imgtemp".nomeRand().".png"; |
| 266 | 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 | 290 | ob_clean(); |
| 269 | 291 | $img = imagecreatefrompng($nomer); |
| 270 | 292 | imagealphablending($img, false); |
| ... | ... | @@ -273,6 +295,7 @@ else{ |
| 273 | 295 | echo header("Content-type: image/png \n\n"); |
| 274 | 296 | imagepng($img); |
| 275 | 297 | imagedestroy($img); |
| 298 | +*/ | |
| 276 | 299 | } |
| 277 | 300 | function salvaCacheImagem($cachedir,$bbox,$layer,$map,$w,$h){ |
| 278 | 301 | global $img,$map_size; | ... | ... |