Commit 3f1b5b0c33f53ea755028cdfbc744458fd0aea87
1 parent
67480b9f
Exists in
master
and in
7 other branches
Reformulação da ferramenta que faz o download do mapfile em uso para aumentar a segurança
Showing
3 changed files
with
75 additions
and
3 deletions
Show diff stats
admin/admin.db
No preview for this file type
ferramentas/salvamapa/forcedownload.php
1 | <?php | 1 | <?php |
2 | -exit; | ||
3 | include(dirname(__FILE__)."/../safe.php"); | 2 | include(dirname(__FILE__)."/../safe.php"); |
4 | verificaBlFerramentas(basename(dirname(__FILE__)),$i3geoBlFerramentas,false); | 3 | verificaBlFerramentas(basename(dirname(__FILE__)),$i3geoBlFerramentas,false); |
5 | // | 4 | // |
@@ -13,6 +12,7 @@ $mapa = ms_newMapObj($arquivo); | @@ -13,6 +12,7 @@ $mapa = ms_newMapObj($arquivo); | ||
13 | //modifica os layers | 12 | //modifica os layers |
14 | // | 13 | // |
15 | $c = $mapa->numlayers; | 14 | $c = $mapa->numlayers; |
15 | +$remover = array(); //guarda os nomes dos metadados pq removeMetaData nao funciona | ||
16 | for ($i=0;$i < $c;++$i){ | 16 | for ($i=0;$i < $c;++$i){ |
17 | $l = $mapa->getlayer($i); | 17 | $l = $mapa->getlayer($i); |
18 | // | 18 | // |
@@ -23,9 +23,81 @@ for ($i=0;$i < $c;++$i){ | @@ -23,9 +23,81 @@ for ($i=0;$i < $c;++$i){ | ||
23 | $l->set("connection",""); | 23 | $l->set("connection",""); |
24 | $l->set("data",""); | 24 | $l->set("data",""); |
25 | } | 25 | } |
26 | + // | ||
27 | + //remove os metadata | ||
28 | + // | ||
29 | + $hashTable = $l->metadata; | ||
30 | + $key = null; | ||
31 | + while ($key = $hashTable->nextkey($key)){ | ||
32 | + if(!in_array(strtolower($key),array("tema","nomeoriginal"))){ | ||
33 | + //echo "Key: ".$key." value: ".$hashTable->get($key)."<br/>"; | ||
34 | + $l->setmetadata($key,""); | ||
35 | + if($ct != MS_WMS){ | ||
36 | + $remover[] = strtoupper($key); | ||
37 | + } | ||
38 | + } | ||
39 | + } | ||
26 | } | 40 | } |
41 | +$remover = array_unique($remover); | ||
42 | + | ||
27 | $mapa->save($arquivo); | 43 | $mapa->save($arquivo); |
44 | +$mapa = null; | ||
45 | +removeCabecalho($arquivo,$remover); | ||
28 | header("Content-Type:text/plain"); | 46 | header("Content-Type:text/plain"); |
29 | -header('Content-Disposition: attachment; filename="'.$arquivo.'"'); | 47 | +header('Content-Disposition: attachment; filename="'.basename($arquivo).'"'); |
30 | readfile($arquivo); | 48 | readfile($arquivo); |
49 | + | ||
50 | +function removeCabecalho($arq,$remover){ | ||
51 | + global $locaplic; | ||
52 | + //locaplic pode ser um endereco baseado no link simbolico. Por isso utiliza-se apenas o nome da pasta principal | ||
53 | + $pasta = basename($locaplic); | ||
54 | + $handle = fopen($arq, "r"); | ||
55 | + if ($handle){ | ||
56 | + $cabeca = array(); | ||
57 | + $cabeca[] = "MAP\n"; | ||
58 | + $grava = false; | ||
59 | + while (!feof($handle)){ | ||
60 | + $linha = fgets($handle); | ||
61 | + if(strpos(strtoupper($linha),"SYMBOLSET") !== false){ | ||
62 | + $cabeca[] = '"..'.explode($pasta,$linha)[1]; | ||
63 | + } | ||
64 | + if(strpos(strtoupper($linha),"FONTSET") !== false){ | ||
65 | + $cabeca[] = '"..'.explode($pasta,$linha)[1]; | ||
66 | + } | ||
67 | + if(strtoupper(trim($linha)) == "LAYER"){ | ||
68 | + $grava = true; | ||
69 | + } | ||
70 | + if($grava){ | ||
71 | + $final[] = rtrim($linha, "\r\n") . PHP_EOL; | ||
72 | + } | ||
73 | + } | ||
74 | + fclose($handle); | ||
75 | + } | ||
76 | + $final = array_merge($cabeca,$final); | ||
77 | + $handle = fopen($arq, "w+"); | ||
78 | + $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"); | ||
79 | + $testar = array_merge($testar,$remover); | ||
80 | + foreach ($final as $f){ | ||
81 | + // | ||
82 | + //remove resultados em branco | ||
83 | + //e grava a linha | ||
84 | + // | ||
85 | + $teste = strtoupper($f); | ||
86 | + $teste = trim($teste); | ||
87 | + $teste = str_replace(" ","",$teste); | ||
88 | + $teste = str_replace("'","",$teste); | ||
89 | + $teste = str_replace('"',"",$teste); | ||
90 | + $teste = preg_replace('/[\n\r\t ]*/', '', $teste); | ||
91 | + $passou = true; | ||
92 | + foreach ($testar as $t) { | ||
93 | + if($teste == $t){ | ||
94 | + $passou = false; | ||
95 | + } | ||
96 | + } | ||
97 | + if($passou){ | ||
98 | + fwrite($handle,$f); | ||
99 | + } | ||
100 | + } | ||
101 | + fclose($handle); | ||
102 | +} | ||
31 | ?> | 103 | ?> |
32 | \ No newline at end of file | 104 | \ No newline at end of file |
ferramentas/salvamapa/index.js
@@ -93,7 +93,7 @@ i3GEOF.salvaMapa = { | @@ -93,7 +93,7 @@ i3GEOF.salvaMapa = { | ||
93 | try{ | 93 | try{ |
94 | var down = i3GEO.configura.locaplic+"/ferramentas/salvamapa/forcedownload.php?g_sid=" + i3GEO.configura.sid; | 94 | var down = i3GEO.configura.locaplic+"/ferramentas/salvamapa/forcedownload.php?g_sid=" + i3GEO.configura.sid; |
95 | onde.innerHTML = "" + | 95 | onde.innerHTML = "" + |
96 | - "<a style='line-height:20px;font-size:12px;' href='"+down+"' target='_blank' >"+$trad('baixaArquivo',i3GEOF.salvaMapa.dicionario)+"</a><br>" + | 96 | + "<a style='line-height:20px;font-size:12px;' href='"+down+"' target='_blank' >"+$trad('baixaArquivo',i3GEOF.salvaMapa.dicionario)+"</a><br>"; |
97 | } | 97 | } |
98 | catch(erro){i3GEO.janela.tempoMsg(erro);} | 98 | catch(erro){i3GEO.janela.tempoMsg(erro);} |
99 | } | 99 | } |