Commit 8c65ead9a8b04872d38c8f5b5981962a1b7c7046
1 parent
bc7aa7db
Exists in
master
and in
7 other branches
Correção na opção de salvar e recuperar mapa do banco de dados
Showing
6 changed files
with
49 additions
and
20 deletions
Show diff stats
admin/admin.db
No preview for this file type
admin/php/mapas.php
... | ... | @@ -189,6 +189,8 @@ function salvaMapfile(){ |
189 | 189 | //a string que vai no metadata segue o padrao JSON |
190 | 190 | //o parser para reconstruir os valores e feito em javascript, no cliente |
191 | 191 | // |
192 | + $_GET["arqmapfile"] = str_replace(".map","",$_GET["arqmapfile"]); | |
193 | + $_GET["arqmapfile"] = str_replace(".","",$_GET["arqmapfile"]).".map"; | |
192 | 194 | $customizacoesinit = array(); |
193 | 195 | if(isset($_GET["preferenciasbase64"]) || isset($_GET["geometriasbase64"]) || isset($_GET["graficosbase64"]) || isset($_GET["tabelasbase64"])){ |
194 | 196 | $customizacoesinit[] = '"preferenciasbase64":"'.$_GET["preferenciasbase64"].'"'; |
... | ... | @@ -209,13 +211,15 @@ function salvaMapfile(){ |
209 | 211 | $handle = fopen ($_GET["arqmapfile"], 'r'); |
210 | 212 | $conteudo = fread ($handle, filesize ($_GET["arqmapfile"])); |
211 | 213 | fclose ($handle); |
212 | - $conteudo = base64_encode($conteudo); | |
213 | - if($conteudo == false){ | |
214 | - return array("id"=>"","status"=>"erro"); | |
215 | - } | |
214 | + //$conteudo = base64_encode($conteudo); | |
215 | + $conteudo = str_replace("'","_!_",$conteudo); | |
216 | + $conteudo = str_replace('"',"_!!_",$conteudo); | |
217 | + $conteudo = str_replace(array("<?","?>"),"",$conteudo); | |
218 | + | |
216 | 219 | require_once("conexao.php"); |
217 | 220 | if($convUTF){ |
218 | - $_GET["nome_mapa"] = utf8_encode($_GET["nome_mapa"]); | |
221 | + $_GET["nome_mapa"] = utf8_encode($_GET["nome_mapa"]); | |
222 | + $conteudo = utf8_encode($conteudo); | |
219 | 223 | } |
220 | 224 | $retorna = ""; |
221 | 225 | if(empty($id_mapa)){ |
... | ... | @@ -237,6 +241,9 @@ function salvaMapfile(){ |
237 | 241 | else{ |
238 | 242 | $id = $id_mapa; |
239 | 243 | } |
244 | + if (filter_var($id, FILTER_VALIDATE_INT) === false){ | |
245 | + return array("id"=>"","status"=>"Error!: "); | |
246 | + } | |
240 | 247 | $dataCol = array( |
241 | 248 | "mapfile" => $conteudo, |
242 | 249 | "publicado_mapa" => "sim", |
... | ... | @@ -249,7 +256,7 @@ function salvaMapfile(){ |
249 | 256 | return array("id"=>$id,"status"=>"ok"); |
250 | 257 | } |
251 | 258 | catch (PDOException $e){ |
252 | - return array("id"=>"","status"=>"Error!: " . " "); | |
259 | + return array("id"=>"","status"=>"Error!: "); | |
253 | 260 | } |
254 | 261 | } |
255 | 262 | /* | ... | ... |
classesphp/funcoes_gerais.php
... | ... | @@ -2910,31 +2910,50 @@ function cloneInlineSymbol($layern,$nmapa,$mapa){ |
2910 | 2910 | //recupera um mapfile armazenado no banco de dados de administracao |
2911 | 2911 | //ver admin/php/mapas.php salvaMapfile |
2912 | 2912 | function restauraMapaAdmin($id_mapa,$dir_tmp){ |
2913 | - return; | |
2913 | + if (filter_var($id_mapa, FILTER_VALIDATE_INT) === false){ | |
2914 | + exit; | |
2915 | + } | |
2914 | 2916 | include(dirname(__FILE__)."/../admin/php/conexao.php"); |
2915 | 2917 | if(!empty($esquemaadmin)){ |
2916 | 2918 | $esquemaadmin = str_replace(".","",$esquemaadmin)."."; |
2917 | 2919 | } |
2918 | 2920 | $q = $dbh->query("select * from ".$esquemaadmin."i3geoadmin_mapas where id_mapa=$id_mapa ",PDO::FETCH_ASSOC); |
2919 | 2921 | $mapasalvo = $q->fetchAll(); |
2922 | + $dbh = null; | |
2923 | + $dbhw = null; | |
2920 | 2924 | $mapasalvo = $mapasalvo[0]; |
2921 | 2925 | $base = ""; |
2922 | 2926 | if(strtoupper($mapasalvo["publicado"]) != "NAO"){ |
2923 | - $base = $dir_tmp."/".nomeRandomico().".map"; | |
2927 | + $base = $dir_tmp."/".nomeRandomico()."_restaurado.map"; | |
2924 | 2928 | $baseh = fopen($base,'w'); |
2925 | - $registro = $mapasalvo["mapfile"]; | |
2929 | + $mapfile = $mapasalvo["mapfile"]; | |
2930 | + //$registro = $mapasalvo["mapfile"]; | |
2926 | 2931 | //verifica se existem parametros junto com o registro |
2927 | - $registro = explode(",",$registro); | |
2928 | - $mapfile = $registro[0]; | |
2932 | + //$registro = explode(",",$registro); | |
2933 | + //$mapfile = $registro[0]; | |
2929 | 2934 | //adapta para versoes novas do mapserver |
2930 | - $mapfile = base64_decode($mapfile); | |
2931 | - $mapfile = str_replace("TYPE ANNOTATION","TYPE POINT",$mapfile); | |
2935 | + //verifica se esta em base 64 (versoes antigas) | |
2936 | + if (!preg_match('/MAP/',$mapfile)) { | |
2937 | + $mapfile = base64_decode($mapfile); | |
2938 | + } | |
2939 | + else { | |
2940 | + //substitui strings especiais | |
2941 | + $mapfile = str_replace("_!!_",'"',$mapfile); | |
2942 | + $mapfile = str_replace("_!_","'",$mapfile); | |
2943 | + } | |
2944 | + $mapfile = str_ireplace("TYPE ANNOTATION","TYPE POINT",$mapfile); | |
2945 | + $mapfile = str_replace(array("<?","?>"),"",$mapfile); | |
2932 | 2946 | $s = fwrite($baseh,$mapfile); |
2933 | 2947 | fclose($baseh); |
2934 | 2948 | } |
2935 | - $dbh = null; | |
2936 | - $dbhw = null; | |
2937 | - return $base; | |
2949 | + | |
2950 | + if (@ms_newMapObj($base)){ | |
2951 | + return $base; | |
2952 | + } | |
2953 | + else{ | |
2954 | + unlink($base); | |
2955 | + } | |
2956 | + return false; | |
2938 | 2957 | } |
2939 | 2958 | // |
2940 | 2959 | //converte uma string de conexao do mapserver em um array com os componentes da conexao | ... | ... |
ferramentas/carregamapa/upload.php
... | ... | @@ -95,6 +95,7 @@ if (isset($_FILES['i3GEOcarregamapafilemap']['name']) && strlen(basename($_FILES |
95 | 95 | $layertemp->set("status",MS_DELETE); |
96 | 96 | } |
97 | 97 | } |
98 | + $map->setmetadata("CUSTOMIZACOESINIT",""); | |
98 | 99 | $map->save($map_file); |
99 | 100 | restauraCon($map_file,$postgis_mapa); |
100 | 101 | unlink($dirmap."/".$Arquivo); | ... | ... |
ferramentas/salvamapa/geraminiatura.php
... | ... | @@ -15,8 +15,11 @@ if (filter_var($_GET["restauramapa"], FILTER_VALIDATE_INT) === false){ |
15 | 15 | } |
16 | 16 | |
17 | 17 | $base = restauraMapaAdmin($_GET["restauramapa"],$dir_tmp); |
18 | - | |
18 | + | |
19 | 19 | $nomeImagem = dirname($base)."/".str_replace(".map","","restauramapa".$_GET["restauramapa"])."_miniatura.png"; |
20 | +//por seguranca | |
21 | +$nomeImagem = str_replace(".png","",$nomeImagem); | |
22 | +$nomeImagem = str_replace(".","",$nomeImagem).".png"; | |
20 | 23 | |
21 | 24 | if(!file_exists($nomeImagem)){ |
22 | 25 | $mapa = ms_newMapObj($base); |
... | ... | @@ -45,8 +48,7 @@ if(!file_exists($nomeImagem)){ |
45 | 48 | $sca = $mapa->scalebar; |
46 | 49 | $sca->set("status",MS_OFF); |
47 | 50 | $objImagemM = @$mapa->draw(); |
48 | - $objImagemM->saveImage($nomeImagem); | |
49 | - | |
51 | + $objImagemM->saveImage($nomeImagem); | |
50 | 52 | } |
51 | 53 | ob_clean(); |
52 | 54 | header('Content-Length: '.filesize($nomeImagem)); | ... | ... |
mapas/index.js