diff --git a/ferramentas/salvamapa/forcedownload.php b/ferramentas/salvamapa/forcedownload.php
index e8aa646..1a20b51 100755
--- a/ferramentas/salvamapa/forcedownload.php
+++ b/ferramentas/salvamapa/forcedownload.php
@@ -1,13 +1,103 @@
save($arquivo);
+$mapa = ms_newMapObj($arquivo);
+//
+//modifica os layers
+//
+$c = $mapa->numlayers;
+$remover = array(); //guarda os nomes dos metadados pq removeMetaData nao funciona
+for ($i=0;$i < $c;++$i){
+ $l = $mapa->getlayer($i);
+ //
+ //tratamento para layers que contem dados via base de dados
+ //
+ $ct = $l->connectiontype;
+ if($ct != MS_INLINE && $ct != MS_WMS && $ct != MS_GRATICULE){
+ $l->set("connection","");
+ $l->set("data","");
+ }
+ //
+ //remove os metadata
+ //
+ $hashTable = $l->metadata;
+ $key = null;
+ while ($key = $hashTable->nextkey($key)){
+ if(!in_array(strtolower($key),array("tema","nomeoriginal"))){
+ //echo "Key: ".$key." value: ".$hashTable->get($key)."
";
+ $l->setmetadata($key,"");
+ if($ct != MS_WMS){
+ $remover[] = strtoupper($key);
+ }
+ }
+ }
+}
+$remover = array_unique($remover);
+
+$mapa->save($arquivo);
+$mapa = null;
+removeCabecalho($arquivo,$remover);
header("Content-Type:text/plain");
-header('Content-Disposition: attachment; filename="'.$fName.'"');
-fpassthru($fp);
-?>
+header('Content-Disposition: attachment; filename="'.basename($arquivo).'"');
+readfile($arquivo);
+
+function removeCabecalho($arq,$remover){
+ global $locaplic;
+ //locaplic pode ser um endereco baseado no link simbolico. Por isso utiliza-se apenas o nome da pasta principal
+ $pasta = basename($locaplic);
+ $handle = fopen($arq, "r");
+ if ($handle){
+ $cabeca = array();
+ $cabeca[] = "MAP\n";
+ $grava = false;
+ while (!feof($handle)){
+ $linha = fgets($handle);
+ if(strpos(strtoupper($linha),"SYMBOLSET") !== false){
+ $cabeca[] = '"..'.explode($pasta,$linha)[1];
+ }
+ if(strpos(strtoupper($linha),"FONTSET") !== false){
+ $cabeca[] = '"..'.explode($pasta,$linha)[1];
+ }
+ if(strtoupper(trim($linha)) == "LAYER"){
+ $grava = true;
+ }
+ if($grava){
+ $final[] = rtrim($linha, "\r\n") . PHP_EOL;
+ }
+ }
+ fclose($handle);
+ }
+ $final = array_merge($cabeca,$final);
+ $handle = fopen($arq, "w+");
+ $testar = array("KEYIMAGE","TILEINDEX","TILEITEM","SYMBOL","LABELITEM","FILTERITEM","GROUP","ENCODING","TIP","CLASSE","ITENSDESC","CLASSESNOME","ITENSLINK","ESCALA","CLASSESSIMBOLO","MENSAGEM","EXTENSAO","CLASSESITEM","ESCONDIDO","CLASSESCOR","DOWNLOAD","CLASSESTAMANHO","ITENS","TEMA","APLICAEXTENSAO","IDENTIFICA");
+ $testar = array_merge($testar,$remover);
+ foreach ($final as $f){
+ //
+ //remove resultados em branco
+ //e grava a linha
+ //
+ $teste = strtoupper($f);
+ $teste = trim($teste);
+ $teste = str_replace(" ","",$teste);
+ $teste = str_replace("'","",$teste);
+ $teste = str_replace('"',"",$teste);
+ $teste = preg_replace('/[\n\r\t ]*/', '', $teste);
+ $passou = true;
+ foreach ($testar as $t) {
+ if($teste == $t){
+ $passou = false;
+ }
+ }
+ if($passou){
+ fwrite($handle,$f);
+ }
+ }
+ fclose($handle);
+}
+?>
\ No newline at end of file
diff --git a/ferramentas/salvamapa/geraminiatura.php b/ferramentas/salvamapa/geraminiatura.php
index 9e49fd7..889ce88 100755
--- a/ferramentas/salvamapa/geraminiatura.php
+++ b/ferramentas/salvamapa/geraminiatura.php
@@ -25,27 +25,7 @@ $nomeImagem = str_replace(".","",$nomeImagem).".png";
if(!file_exists($nomeImagem)){
$mapa = ms_newMapObj($base);
- if (isset($postgis_mapa)){
- if ($postgis_mapa != ""){
- $numlayers = $mapa->numlayers;
- for ($i=0;$i < $numlayers;$i++){
- $layern = $mapa->getlayer($i);
- if (!empty($postgis_mapa)){
- if ($layern->connectiontype == MS_POSTGIS){
- $lcon = $layern->connection;
- if (($lcon == " ") || ($lcon == "") || (in_array($lcon,array_keys($postgis_mapa)))){
- if(($lcon == " ") || ($lcon == "")) //para efeitos de compatibilidade
- {$layern->set("connection",$postgis_mapa);
- }
- else{
- $layern->set("connection",$postgis_mapa[$lcon]);
- }
- }
- }
- }
- }
- }
- }
+ substituiConObj($mapa,$postgis_mapa);
$mapa->setsize($_GET["w"],$_GET["h"]);
$sca = $mapa->scalebar;
$sca->set("status",MS_OFF);
@@ -53,10 +33,6 @@ if(!file_exists($nomeImagem)){
$objImagemM->saveImage($nomeImagem);
}
ob_clean();
-header('Content-Length: '.filesize($nomeImagem));
header('Content-Type: image/png');
-header('Cache-Control: public, max-age=22222222');
-header('Expires: ' . gmdate('D, d M Y H:i:s', time()+48*60*60) . ' GMT');
-//fpassthru(fopen($nomeImagem, 'rb'));
readfile($nomeImagem);
?>
\ No newline at end of file
diff --git a/ferramentas/salvamapa/index.js b/ferramentas/salvamapa/index.js
index b337caf..eaf640b 100755
--- a/ferramentas/salvamapa/index.js
+++ b/ferramentas/salvamapa/index.js
@@ -91,14 +91,9 @@ i3GEOF.salvaMapa = {
onde = $i(onde);
if(onde){
try{
- var map_file = i3GEO.parametros.mapfile,
- teste = i3GEO.configura.locaplic+"/testamapfile.php?map="+map_file,
- local = map_file.split("ms_tmp");
- down = i3GEO.configura.locaplic+"/ferramentas/salvamapa/forcedownload.php?file="+map_file;
- local = i3GEO.configura.locaplic+"/../ms_tmp"+local[1];
+ var down = i3GEO.configura.locaplic+"/ferramentas/salvamapa/forcedownload.php?g_sid=" + i3GEO.configura.sid;
onde.innerHTML = "" +
- ""+$trad('baixaArquivo',i3GEOF.salvaMapa.dicionario)+"
" +
- ""+$trad('testaArquivo',i3GEOF.salvaMapa.dicionario)+"";
+ ""+$trad('baixaArquivo',i3GEOF.salvaMapa.dicionario)+"
";
}
catch(erro){i3GEO.janela.tempoMsg(erro);}
}
--
libgit2 0.21.2