Commit ebaf80fdfbd315df7ca1b42c6a34ca5e83b24ba6
1 parent
67585339
Exists in
master
and in
7 other branches
Criação do formulário para upload de arquivos shapefile para o servidor de banco…
… de dados e criação automática do respectivo arquivo de configuração mapfile.
Showing
19 changed files
with
1113 additions
and
271 deletions
Show diff stats
admin/admin.db
No preview for this file type
admin/php/metaestat_uploadshp_submit.php
@@ -113,6 +113,7 @@ if (isset($_FILES['i3GEOuploadshp']['name'])){ | @@ -113,6 +113,7 @@ if (isset($_FILES['i3GEOuploadshp']['name'])){ | ||
113 | //pega os parametros de conexao | 113 | //pega os parametros de conexao |
114 | include("classe_metaestat.php"); | 114 | include("classe_metaestat.php"); |
115 | $m = new Metaestat(); | 115 | $m = new Metaestat(); |
116 | + | ||
116 | $conexao = $m->listaConexao($_POST["i3GEOuploadcodigoconexao"],true); | 117 | $conexao = $m->listaConexao($_POST["i3GEOuploadcodigoconexao"],true); |
117 | //array(5) { ["codigo_estat_conexao"]=> string(1) "1" ["bancodedados"]=> string(8) "geosaude" ["host"]=> string(9) "localhost" ["porta"]=> string(4) "5432" ["usuario"]=> string(8) "postgres" } | 118 | //array(5) { ["codigo_estat_conexao"]=> string(1) "1" ["bancodedados"]=> string(8) "geosaude" ["host"]=> string(9) "localhost" ["porta"]=> string(4) "5432" ["usuario"]=> string(8) "postgres" } |
118 | //pega as colunas do shapefile | 119 | //pega as colunas do shapefile |
@@ -218,6 +219,10 @@ if (isset($_FILES['i3GEOuploadshp']['name'])){ | @@ -218,6 +219,10 @@ if (isset($_FILES['i3GEOuploadshp']['name'])){ | ||
218 | flush(); | 219 | flush(); |
219 | sleep(1); | 220 | sleep(1); |
220 | } | 221 | } |
222 | + | ||
223 | + | ||
224 | + | ||
225 | + | ||
221 | if($tabelaExiste == true && $_POST["tipoOperacao"] == "criar"){ | 226 | if($tabelaExiste == true && $_POST["tipoOperacao"] == "criar"){ |
222 | echo "<span style=color:red >A tabela existe. Não pode ser criada.</span>"; | 227 | echo "<span style=color:red >A tabela existe. Não pode ser criada.</span>"; |
223 | exit; | 228 | exit; |
@@ -237,6 +242,12 @@ if (isset($_FILES['i3GEOuploadshp']['name'])){ | @@ -237,6 +242,12 @@ if (isset($_FILES['i3GEOuploadshp']['name'])){ | ||
237 | ob_flush(); | 242 | ob_flush(); |
238 | flush(); | 243 | flush(); |
239 | sleep(1); | 244 | sleep(1); |
245 | + | ||
246 | + | ||
247 | + | ||
248 | + | ||
249 | + | ||
250 | + | ||
240 | $srid = 4326; | 251 | $srid = 4326; |
241 | $escapar = "'"; | 252 | $escapar = "'"; |
242 | $projOutObj = ""; | 253 | $projOutObj = ""; |
admin1/catalogo/mapfile/editor/funcoes.php
@@ -217,5 +217,6 @@ function salvaMapfile() { | @@ -217,5 +217,6 @@ function salvaMapfile() { | ||
217 | } | 217 | } |
218 | $resultado = \admin\php\funcoesAdmin\i3GeoAdminUpdate ( $dbhw, "i3geoadmin_temas", $dataCol, "WHERE codigo_tema = '$codigo'" ); | 218 | $resultado = \admin\php\funcoesAdmin\i3GeoAdminUpdate ( $dbhw, "i3geoadmin_temas", $dataCol, "WHERE codigo_tema = '$codigo'" ); |
219 | } | 219 | } |
220 | + \admin\php\funcoesAdmin\removeCabecalhoMapfile ( $mapfile ); | ||
220 | } | 221 | } |
221 | ?> | 222 | ?> |
222 | \ No newline at end of file | 223 | \ No newline at end of file |
admin1/catalogo/mapfile/editor/index.php
@@ -77,7 +77,7 @@ $textoMapfile = \admin\catalogo\mapfile\editor\textoMapfile ( $codigo ); | @@ -77,7 +77,7 @@ $textoMapfile = \admin\catalogo\mapfile\editor\textoMapfile ( $codigo ); | ||
77 | </div> | 77 | </div> |
78 | <div class="container-fluid"> | 78 | <div class="container-fluid"> |
79 | <div class="row center-block"> | 79 | <div class="row center-block"> |
80 | - <div class="col-md-12 well" id="titulo"> | 80 | + <div class="col-md-12 well hidden" id="titulo"> |
81 | 81 | ||
82 | <blockquote> | 82 | <blockquote> |
83 | {{{ajudaEditor}}} | 83 | {{{ajudaEditor}}} |
admin1/dicionario/menup.js
@@ -107,7 +107,7 @@ i3GEOadmin.menup.dicionario = { | @@ -107,7 +107,7 @@ i3GEOadmin.menup.dicionario = { | ||
107 | es : "" | 107 | es : "" |
108 | } ], | 108 | } ], |
109 | 'enviarShp' : [ { | 109 | 'enviarShp' : [ { |
110 | - pt : "Shape file", | 110 | + pt : "Upload de shapefile", |
111 | en : "", | 111 | en : "", |
112 | es : "" | 112 | es : "" |
113 | } ], | 113 | } ], |
@@ -325,5 +325,10 @@ i3GEOadmin.menup.dicionario = { | @@ -325,5 +325,10 @@ i3GEOadmin.menup.dicionario = { | ||
325 | pt : "Lista de nomes de subgrupos", | 325 | pt : "Lista de nomes de subgrupos", |
326 | en : "", | 326 | en : "", |
327 | es : "" | 327 | es : "" |
328 | + } ], | ||
329 | + 'shp2pg' : [ { | ||
330 | + pt : "Importar shapefile para Postgis", | ||
331 | + en : "", | ||
332 | + es : "" | ||
328 | } ] | 333 | } ] |
329 | }; | 334 | }; |
admin1/dicionario/uploadshp.js
1 | +if(typeof i3GEOadmin.uploadshp == "undefined" ){ | ||
2 | + i3GEOadmin.uploadshp = {}; | ||
3 | +} | ||
1 | i3GEOadmin.uploadshp.dicionario = { | 4 | i3GEOadmin.uploadshp.dicionario = { |
2 | 'pastaArmazenamento' : [ { | 5 | 'pastaArmazenamento' : [ { |
3 | pt : "Pasta no servidor onde os dados serão armazenados.", | 6 | pt : "Pasta no servidor onde os dados serão armazenados.", |
@@ -65,7 +68,82 @@ i3GEOadmin.uploadshp.dicionario = { | @@ -65,7 +68,82 @@ i3GEOadmin.uploadshp.dicionario = { | ||
65 | es : "" | 68 | es : "" |
66 | } ], | 69 | } ], |
67 | 'txtArquivos' : [ { | 70 | 'txtArquivos' : [ { |
68 | - pt : "Escolha os arquivos que formam o shapefile (shp, shx, dbf, prj)", | 71 | + pt : "Escolha os arquivos que formam o shapefile", |
72 | + en : "", | ||
73 | + es : "" | ||
74 | + } ], | ||
75 | + 'txtTituloShp2Pg' : [ { | ||
76 | + pt : "Importação de arquivo shapefile para Postgis", | ||
77 | + en : "", | ||
78 | + es : "" | ||
79 | + } ], | ||
80 | + 'txtDescShp2Pg' : [ { | ||
81 | + pt : "Faz o upload de um arquivo shapefile e converte para o banco de dados Postgis existente no servidor web.", | ||
82 | + en : "", | ||
83 | + es : "" | ||
84 | + } ], | ||
85 | + 'txtAjudaShp2Pg' : [ { | ||
86 | + pt : "No formulário deve-se indicar os arquivos nos formatos SHP, SHX e DBF que formam o SHAPEFILE. O arquivo é enviado ao servidor e armazenado temporariamente para que a conversão para Postgis seja possível. O resultado do processo será uma tabela no banco de dados no esquema escolhido pelo usuário. O acesso ao banco é feito por meio do usuário administrativo da aplicação i3Geo (o mesmo que gerencia o sistema de administração, veja em ms_configura.php). Esse usuário, definido pelo administrador do servidor, deve ter os direitos de escrita no esquema do banco de dados escolhido para importar os dados.", | ||
87 | + en : "", | ||
88 | + es : "" | ||
89 | + } ], | ||
90 | + 'esquemaArmazenamento' : [ { | ||
91 | + pt : "Esquema no banco de dados onde a tabela será criada", | ||
92 | + en : "", | ||
93 | + es : "" | ||
94 | + } ], | ||
95 | + 'sridOrigem' : [ { | ||
96 | + pt : "Código numérico SRID (projeção cartográfica) referente ao arquivo shapefile", | ||
97 | + en : "", | ||
98 | + es : "" | ||
99 | + } ], | ||
100 | + 'sridDestino' : [ { | ||
101 | + pt : "Código numérico SRID (projeção cartográfica) que será utilizado para armazenar os dados no banco", | ||
102 | + en : "", | ||
103 | + es : "" | ||
104 | + } ], | ||
105 | + 'tipoOperacao' : [ { | ||
106 | + pt : "Tipo de operação. Sempre é criado um backup no banco caso a tabela já exista.", | ||
107 | + en : "", | ||
108 | + es : "" | ||
109 | + } ], | ||
110 | + 'tabelaNova' : [ { | ||
111 | + pt : "Tabela nova", | ||
112 | + en : "", | ||
113 | + es : "" | ||
114 | + } ], | ||
115 | + 'tabelaUpdate' : [ { | ||
116 | + pt : "Apagar registros e inserir novos", | ||
117 | + en : "", | ||
118 | + es : "" | ||
119 | + } ], | ||
120 | + 'tabelaInsert' : [ { | ||
121 | + pt : "Inserir registros novos", | ||
122 | + en : "", | ||
123 | + es : "" | ||
124 | + } ], | ||
125 | + 'nomeTabela' : [ { | ||
126 | + pt : "Nome da nova tabela ou de uma tabela já existente", | ||
127 | + en : "", | ||
128 | + es : "" | ||
129 | + } ], | ||
130 | + 'apenasScript' : [ { | ||
131 | + pt : "Não cria ou modifica a tabela, apenas mostra nos resultados o script SQL", | ||
132 | + en : "", | ||
133 | + es : "" | ||
134 | + } ], | ||
135 | + 'comentarioTabela' : [ { | ||
136 | + pt : "Comentário que será inserido nas propriedades da tabela caso seja uma nova tabela", | ||
137 | + en : "", | ||
138 | + es : "" | ||
139 | + } ], | ||
140 | + 'colunaGid' : [ { | ||
141 | + pt : "Nome de uma nova coluna, ou de uma existente no shapefile, que será considerada como identificadores únicos de cada registro. Caso a coluna não exista, será criada.", | ||
142 | + en : "", | ||
143 | + es : "" | ||
144 | + } ], | ||
145 | + 'comboAliasConexao' : [ { | ||
146 | + pt : "Alias da conexão com o banco de dados. Será utilizado apenas para o caso de construção do arquivo mapfile.", | ||
69 | en : "", | 147 | en : "", |
70 | es : "" | 148 | es : "" |
71 | } ] | 149 | } ] |
admin1/index.php
@@ -45,6 +45,10 @@ $_SESSION["i3geoPermiteLogin"] = $i3geoPermiteLogin; | @@ -45,6 +45,10 @@ $_SESSION["i3geoPermiteLogin"] = $i3geoPermiteLogin; | ||
45 | unset($i3geoPermiteLogin); | 45 | unset($i3geoPermiteLogin); |
46 | $_SESSION["i3geoUploadDataWL"] = $i3geoUploadDataWL; | 46 | $_SESSION["i3geoUploadDataWL"] = $i3geoUploadDataWL; |
47 | unset($i3geoUploadDataWL); | 47 | unset($i3geoUploadDataWL); |
48 | +$_SESSION["i3geoEsquemasWL"] = $i3geoEsquemasWL; | ||
49 | +unset($i3geoEsquemasWL); | ||
50 | +$_SESSION["i3GeoProjDefault"] = $i3GeoProjDefault; | ||
51 | +unset($i3GeoProjDefault); | ||
48 | include "head.php"; | 52 | include "head.php"; |
49 | ?> | 53 | ?> |
50 | <div class="container-fluid migalha" > | 54 | <div class="container-fluid migalha" > |
admin1/js/bdexplorer.js
@@ -6,7 +6,13 @@ i3GEOadmin.bdExplorer = { | @@ -6,7 +6,13 @@ i3GEOadmin.bdExplorer = { | ||
6 | templateListaPopOver: '<a href="javascript:void(0)" data-name="{{{destino}}}" data-value="{{{valor}}}" class="list-group-item">{{{valor}}}</a>', | 6 | templateListaPopOver: '<a href="javascript:void(0)" data-name="{{{destino}}}" data-value="{{{valor}}}" class="list-group-item">{{{valor}}}</a>', |
7 | templateListaPopOver1: '<a href="javascript:void(0)" data-name="{{{destino}}}" data-value="{{{valor}}}" class="list-group-item">{{{chave}}}</a>', | 7 | templateListaPopOver1: '<a href="javascript:void(0)" data-name="{{{destino}}}" data-value="{{{valor}}}" class="list-group-item">{{{chave}}}</a>', |
8 | popOver: function(destino, conteudo){ | 8 | popOver: function(destino, conteudo){ |
9 | - var pop = $("#modalGeral input[name='" + destino + "']").popover({ | 9 | + if($("#modalGeral input[name='" + destino + "']").length > 0 ){ |
10 | + var onde = "#modalGeral input[name='" + destino + "']"; | ||
11 | + } else { | ||
12 | + var onde = "input[name='" + destino + "']"; | ||
13 | + } | ||
14 | + | ||
15 | + var pop = $(onde).popover({ | ||
10 | "content": conteudo, | 16 | "content": conteudo, |
11 | "placement": function(a){a.style.left = "0px";}, | 17 | "placement": function(a){a.style.left = "0px";}, |
12 | "title": "", | 18 | "title": "", |
@@ -18,7 +24,11 @@ i3GEOadmin.bdExplorer = { | @@ -18,7 +24,11 @@ i3GEOadmin.bdExplorer = { | ||
18 | $(".popover").css("left","0px"); | 24 | $(".popover").css("left","0px"); |
19 | $(".popover").css("top","45px") | 25 | $(".popover").css("top","45px") |
20 | $(".popover").on('click', function (e) { | 26 | $(".popover").on('click', function (e) { |
21 | - $("#modalGeral input[name='" + e.target.getAttribute('data-name') + "']").val(e.target.getAttribute('data-value')); | 27 | + if($("#modalGeral input[name='" + e.target.getAttribute('data-name') + "']").length > 0){ |
28 | + $("#modalGeral input[name='" + e.target.getAttribute('data-name') + "']").val(e.target.getAttribute('data-value')); | ||
29 | + } else { | ||
30 | + $("input[name='" + e.target.getAttribute('data-name') + "']").val(e.target.getAttribute('data-value')); | ||
31 | + } | ||
22 | $(".popover").popover("destroy"); | 32 | $(".popover").popover("destroy"); |
23 | }) | 33 | }) |
24 | }, | 34 | }, |
@@ -52,6 +62,36 @@ i3GEOadmin.bdExplorer = { | @@ -52,6 +62,36 @@ i3GEOadmin.bdExplorer = { | ||
52 | $(".popover").popover("destroy"); | 62 | $(".popover").popover("destroy"); |
53 | } | 63 | } |
54 | }, | 64 | }, |
65 | + listaEsquemasUpload: function(destino){ | ||
66 | + if($(".popover").length == 0){ | ||
67 | + $.post( | ||
68 | + i3GEO.configura.locaplic + "/admin1/php/bdexplorer.php?funcao=listarEsquemasUpload" | ||
69 | + ) | ||
70 | + .done( | ||
71 | + function(data, status){ | ||
72 | + var c = "", json = jQuery.parseJSON(data); | ||
73 | + c = Mustache.to_html( | ||
74 | + "{{#data}}" + i3GEOadmin.bdExplorer.templateListaPopOver + "{{/data}}", | ||
75 | + { | ||
76 | + "data":json, | ||
77 | + "destino": destino, | ||
78 | + "valor": function() { | ||
79 | + return this; | ||
80 | + } | ||
81 | + } | ||
82 | + ); | ||
83 | + i3GEOadmin.bdExplorer.popOver(destino,c); | ||
84 | + } | ||
85 | + ) | ||
86 | + .fail( | ||
87 | + function(data){ | ||
88 | + i3GEOadmin.core.mostraErro(data.status + " " +data.statusText); | ||
89 | + } | ||
90 | + ); | ||
91 | + } else { | ||
92 | + $(".popover").popover("destroy"); | ||
93 | + } | ||
94 | + }, | ||
55 | listaTabelas: function(codigo_estat_conexao,esquema,destino){ | 95 | listaTabelas: function(codigo_estat_conexao,esquema,destino){ |
56 | if($(".popover").length == 0){ | 96 | if($(".popover").length == 0){ |
57 | $.post( | 97 | $.post( |
@@ -71,6 +111,38 @@ i3GEOadmin.bdExplorer = { | @@ -71,6 +111,38 @@ i3GEOadmin.bdExplorer = { | ||
71 | } | 111 | } |
72 | } | 112 | } |
73 | ); | 113 | ); |
114 | + | ||
115 | + i3GEOadmin.bdExplorer.popOver(destino,c); | ||
116 | + } | ||
117 | + ) | ||
118 | + .fail( | ||
119 | + function(data){ | ||
120 | + i3GEOadmin.core.mostraErro(data.status + " " +data.statusText); | ||
121 | + } | ||
122 | + ); | ||
123 | + } else { | ||
124 | + $(".popover").popover("destroy"); | ||
125 | + } | ||
126 | + }, | ||
127 | + listaTabelasUpload: function(esquema,destino){ | ||
128 | + if($(".popover").length == 0){ | ||
129 | + $.post( | ||
130 | + i3GEO.configura.locaplic + "/admin1/php/bdexplorer.php?funcao=listarTabelasUpload", | ||
131 | + "esquema=" + esquema | ||
132 | + ) | ||
133 | + .done( | ||
134 | + function(data, status){ | ||
135 | + var c = "", json = jQuery.parseJSON(data); | ||
136 | + c = Mustache.to_html( | ||
137 | + "{{#data}}" + i3GEOadmin.bdExplorer.templateListaPopOver + "{{/data}}", | ||
138 | + { | ||
139 | + "data":json, | ||
140 | + "destino": destino, | ||
141 | + "valor": function() { | ||
142 | + return this; | ||
143 | + } | ||
144 | + } | ||
145 | + ); | ||
74 | i3GEOadmin.bdExplorer.popOver(destino,c); | 146 | i3GEOadmin.bdExplorer.popOver(destino,c); |
75 | } | 147 | } |
76 | ) | 148 | ) |
admin1/menu.js
@@ -64,7 +64,7 @@ menuPrincipal = [ | @@ -64,7 +64,7 @@ menuPrincipal = [ | ||
64 | { | 64 | { |
65 | html: "<a href='" + i3GEO.configura.locaplic + "/admin1/upload/arquivo/index.php' >"+$trad("enviarShp",i3GEOadmin.menup.dicionario)+"</a>" | 65 | html: "<a href='" + i3GEO.configura.locaplic + "/admin1/upload/arquivo/index.php' >"+$trad("enviarShp",i3GEOadmin.menup.dicionario)+"</a>" |
66 | },{ | 66 | },{ |
67 | - html: "<a href='" + i3GEO.configura.locaplic + "/admin1/upload/banco/index.php' >"+$trad("gerenciaBd",i3GEOadmin.menup.dicionario)+"</a>" | 67 | + html: "<a href='" + i3GEO.configura.locaplic + "/admin1/upload/shp2pg/index.php' >"+$trad("shp2pg",i3GEOadmin.menup.dicionario)+"</a>" |
68 | },{ | 68 | },{ |
69 | html: "<a href='" + i3GEO.configura.locaplic + "/admin1/upload/simbolo/index.php' >"+$trad("uploadSimbolo",i3GEOadmin.menup.dicionario)+"</a>" | 69 | html: "<a href='" + i3GEO.configura.locaplic + "/admin1/upload/simbolo/index.php' >"+$trad("uploadSimbolo",i3GEOadmin.menup.dicionario)+"</a>" |
70 | } | 70 | } |
admin1/php/bdexplorer.php
1 | <?php | 1 | <?php |
2 | /****************************************************************/ | 2 | /****************************************************************/ |
3 | // | 3 | // |
4 | -//checa login | ||
5 | -//valida _GET e _POST, juntando em _GET | ||
6 | -//pega algumas variaveis de uso mais comum | ||
7 | -//session_start | 4 | +// checa login |
5 | +// valida _GET e _POST, juntando em _GET | ||
6 | +// pega algumas variaveis de uso mais comum | ||
7 | +// session_start | ||
8 | // | 8 | // |
9 | include ("checaLogin.php"); | 9 | include ("checaLogin.php"); |
10 | -\admin\php\login\checaLogin(); | ||
11 | -//funcoes de administracao | 10 | +\admin\php\login\checaLogin (); |
11 | +// funcoes de administracao | ||
12 | include ("funcoesAdmin.php"); | 12 | include ("funcoesAdmin.php"); |
13 | // | 13 | // |
14 | -//carrega outras funcoes e extensoes do PHP | 14 | +// carrega outras funcoes e extensoes do PHP |
15 | // | 15 | // |
16 | -include ($_SESSION["locaplic"]."/classesphp/carrega_ext.php"); | ||
17 | -include ($_SESSION["locaplic"]."/classesphp/classe_bdexplorer.php"); | ||
18 | -include ($_SESSION["locaplic"]."/classesphp/classe_metaestat.php"); | ||
19 | -/***************************************************************/ | 16 | +include ($_SESSION ["locaplic"] . "/classesphp/carrega_ext.php"); |
17 | +include ($_SESSION ["locaplic"] . "/classesphp/classe_bdexplorer.php"); | ||
18 | +include ($_SESSION ["locaplic"] . "/classesphp/classe_metaestat.php"); | ||
19 | +/** | ||
20 | + * ************************************************************ | ||
21 | + */ | ||
20 | if (\admin\php\funcoesAdmin\verificaOperacaoSessao ( "admin/metaestat/geral" ) === false) { | 22 | if (\admin\php\funcoesAdmin\verificaOperacaoSessao ( "admin/metaestat/geral" ) === false) { |
21 | header ( "HTTP/1.1 403 Vc nao pode realizar essa operacao" ); | 23 | header ( "HTTP/1.1 403 Vc nao pode realizar essa operacao" ); |
22 | exit (); | 24 | exit (); |
@@ -24,8 +26,17 @@ if (\admin\php\funcoesAdmin\verificaOperacaoSessao ( "admin/metaestat/geral" ) = | @@ -24,8 +26,17 @@ if (\admin\php\funcoesAdmin\verificaOperacaoSessao ( "admin/metaestat/geral" ) = | ||
24 | $funcao = strtoupper ( $funcao ); | 26 | $funcao = strtoupper ( $funcao ); |
25 | switch ($funcao) { | 27 | switch ($funcao) { |
26 | case "LISTARESQUEMAS" : | 28 | case "LISTARESQUEMAS" : |
27 | - $bd = new \i3geo\classesphp\bdexplorer\Bdexplorer($_SESSION["locaplic"]); | ||
28 | - $dados = $bd->listaDeEsquemas(); | 29 | + $bd = new \i3geo\classesphp\bdexplorer\Bdexplorer ( $_SESSION ["locaplic"] ); |
30 | + $dados = $bd->listaDeEsquemas (); | ||
31 | + if ($dados === false) { | ||
32 | + header ( "HTTP/1.1 500 erro ao consultar banco de dados" ); | ||
33 | + } else { | ||
34 | + \admin\php\funcoesAdmin\retornaJSON ( $dados ); | ||
35 | + } | ||
36 | + break; | ||
37 | + case "LISTARESQUEMASUPLOAD" : | ||
38 | + $bd = new \i3geo\classesphp\bdexplorer\Bdexplorer ( $_SESSION ["locaplic"] ); | ||
39 | + $dados = $bd->listaDeEsquemasUpload (); | ||
29 | if ($dados === false) { | 40 | if ($dados === false) { |
30 | header ( "HTTP/1.1 500 erro ao consultar banco de dados" ); | 41 | header ( "HTTP/1.1 500 erro ao consultar banco de dados" ); |
31 | } else { | 42 | } else { |
@@ -33,11 +44,28 @@ switch ($funcao) { | @@ -33,11 +44,28 @@ switch ($funcao) { | ||
33 | } | 44 | } |
34 | break; | 45 | break; |
35 | case "LISTARTABELAS" : | 46 | case "LISTARTABELAS" : |
36 | - //pega os parametros de conexao | ||
37 | - $mt = new \i3geo\classesphp\metaestat\Metaestat(); | ||
38 | - $parametros = $mt->listaConexao((int) $_POST["codigo_estat_conexao"],true,false); | ||
39 | - $bd = new \i3geo\classesphp\bdexplorer\Bdexplorer($_SESSION["locaplic"],$parametros); | ||
40 | - $dados = $bd->listaDeTabelas($_POST["esquema"]); | 47 | + // pega os parametros de conexao |
48 | + if (empty ( $_POST ["codigo_estat_conexao"] )) { | ||
49 | + $parametros = $dbh; | ||
50 | + } else { | ||
51 | + $mt = new \i3geo\classesphp\metaestat\Metaestat (); | ||
52 | + $parametros = $mt->listaConexao ( ( int ) $_POST ["codigo_estat_conexao"], true, false ); | ||
53 | + } | ||
54 | + $bd = new \i3geo\classesphp\bdexplorer\Bdexplorer ( $_SESSION ["locaplic"], $parametros ); | ||
55 | + $dados = $bd->listaDeTabelas ( $_POST ["esquema"] ); | ||
56 | + if ($dados === false) { | ||
57 | + header ( "HTTP/1.1 500 erro ao consultar banco de dados" ); | ||
58 | + } else { | ||
59 | + \admin\php\funcoesAdmin\retornaJSON ( $dados ); | ||
60 | + } | ||
61 | + break; | ||
62 | + case "LISTARTABELASUPLOAD" : | ||
63 | + // pega os parametros de conexao da variavel com os parametros para upload de shapefile | ||
64 | + $c = $_SESSION ["i3geoUploadDataWL"]["postgis"]["conexao"]; | ||
65 | + //var_dump ($c);exit; | ||
66 | + $dbh = new PDO('pgsql:dbname='.$c["dbname"].';user='.$c["user"].';password='.$c["password"].';host='.$c["host"].';port='.$c["port"]); | ||
67 | + $bd = new \i3geo\classesphp\bdexplorer\Bdexplorer ( $_SESSION ["locaplic"], $dbh ); | ||
68 | + $dados = $bd->listaDeTabelasUpload ( $_POST ["esquema"] ); | ||
41 | if ($dados === false) { | 69 | if ($dados === false) { |
42 | header ( "HTTP/1.1 500 erro ao consultar banco de dados" ); | 70 | header ( "HTTP/1.1 500 erro ao consultar banco de dados" ); |
43 | } else { | 71 | } else { |
@@ -45,11 +73,11 @@ switch ($funcao) { | @@ -45,11 +73,11 @@ switch ($funcao) { | ||
45 | } | 73 | } |
46 | break; | 74 | break; |
47 | case "LISTARCOLUNAS" : | 75 | case "LISTARCOLUNAS" : |
48 | - //pega os parametros de conexao | ||
49 | - $mt = new \i3geo\classesphp\metaestat\Metaestat(); | ||
50 | - $parametros = $mt->listaConexao((int) $_POST["codigo_estat_conexao"],true,false); | ||
51 | - $bd = new \i3geo\classesphp\bdexplorer\Bdexplorer($_SESSION["locaplic"],$parametros); | ||
52 | - $dados = $bd->listaDeColunas($_POST["esquema"],$_POST["tabela"]); | 76 | + // pega os parametros de conexao |
77 | + $mt = new \i3geo\classesphp\metaestat\Metaestat (); | ||
78 | + $parametros = $mt->listaConexao ( ( int ) $_POST ["codigo_estat_conexao"], true, false ); | ||
79 | + $bd = new \i3geo\classesphp\bdexplorer\Bdexplorer ( $_SESSION ["locaplic"], $parametros ); | ||
80 | + $dados = $bd->listaDeColunas ( $_POST ["esquema"], $_POST ["tabela"] ); | ||
53 | if ($dados === false) { | 81 | if ($dados === false) { |
54 | header ( "HTTP/1.1 500 erro ao consultar banco de dados" ); | 82 | header ( "HTTP/1.1 500 erro ao consultar banco de dados" ); |
55 | } else { | 83 | } else { |
@@ -57,21 +85,25 @@ switch ($funcao) { | @@ -57,21 +85,25 @@ switch ($funcao) { | ||
57 | } | 85 | } |
58 | break; | 86 | break; |
59 | case "LISTARCODIGOSCONEXAO" : | 87 | case "LISTARCODIGOSCONEXAO" : |
60 | - //pega os parametros de conexao | ||
61 | - $mt = new \i3geo\classesphp\metaestat\Metaestat(); | ||
62 | - $dados = $mt->listaConexao("",false,false); | 88 | + // pega os parametros de conexao |
89 | + $mt = new \i3geo\classesphp\metaestat\Metaestat (); | ||
90 | + $dados = $mt->listaConexao ( "", false, false ); | ||
63 | if ($dados === false) { | 91 | if ($dados === false) { |
64 | header ( "HTTP/1.1 500 erro ao consultar banco de dados" ); | 92 | header ( "HTTP/1.1 500 erro ao consultar banco de dados" ); |
65 | } else { | 93 | } else { |
66 | - $kv = array(); | ||
67 | - foreach($dados as $d){ | ||
68 | - $kv[] = array("chave"=>$d["bancodedados"],"valor"=>$d["codigo_estat_conexao"]); | 94 | + $kv = array (); |
95 | + foreach ( $dados as $d ) { | ||
96 | + $kv [] = array ( | ||
97 | + "chave" => $d ["bancodedados"], | ||
98 | + "valor" => $d ["codigo_estat_conexao"] | ||
99 | + ); | ||
69 | } | 100 | } |
70 | \admin\php\funcoesAdmin\retornaJSON ( $kv ); | 101 | \admin\php\funcoesAdmin\retornaJSON ( $kv ); |
71 | } | 102 | } |
72 | break; | 103 | break; |
73 | - default: | ||
74 | - if(!empty ($funcao)) header ( "HTTP/1.1 500 erro funcao nao existe" ); | 104 | + default : |
105 | + if (! empty ( $funcao )) | ||
106 | + header ( "HTTP/1.1 500 erro funcao nao existe" ); | ||
75 | break; | 107 | break; |
76 | } | 108 | } |
77 | ?> | 109 | ?> |
78 | \ No newline at end of file | 110 | \ No newline at end of file |
admin1/upload/arquivo/exec.php
@@ -64,9 +64,10 @@ if (! isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { | @@ -64,9 +64,10 @@ if (! isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { | ||
64 | <body bgcolor="white" style="background-color: white; text-align: left;"> | 64 | <body bgcolor="white" style="background-color: white; text-align: left;"> |
65 | <p> | 65 | <p> |
66 | <?php | 66 | <?php |
67 | +ob_flush ();flush (); sleep ( 2 ); | ||
67 | if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { | 68 | if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { |
68 | $i3GEOuploadCriaMapfile = $_POST ["i3GEOuploadCriaMapfile"]; | 69 | $i3GEOuploadCriaMapfile = $_POST ["i3GEOuploadCriaMapfile"]; |
69 | - $dirDestino = $_SESSION ["i3geoUploadDataWL"] [$_POST ["dirDestino"]]; | 70 | + $dirDestino = $_SESSION ["i3geoUploadDataWL"] ["arquivos"] [$_POST ["dirDestino"]]; |
70 | $dirDestino = str_replace ( ".", "", $dirDestino ); | 71 | $dirDestino = str_replace ( ".", "", $dirDestino ); |
71 | if (empty ( $dirDestino )) { | 72 | if (empty ( $dirDestino )) { |
72 | echo "<div class='alert alert-danger' role='alert'>Pasta não encontrada</div>"; | 73 | echo "<div class='alert alert-danger' role='alert'>Pasta não encontrada</div>"; |
@@ -81,9 +82,9 @@ if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { | @@ -81,9 +82,9 @@ if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { | ||
81 | } | 82 | } |
82 | 83 | ||
83 | echo "<div class='alert alert-success' role='alert'>Carregando o arquivo...</div>"; | 84 | echo "<div class='alert alert-success' role='alert'>Carregando o arquivo...</div>"; |
84 | - ob_flush (); | ||
85 | - flush (); | ||
86 | - sleep ( 1 ); | 85 | + |
86 | + ob_flush ();flush (); sleep ( 2 ); | ||
87 | + | ||
87 | $dirmap = $dirDestino; | 88 | $dirmap = $dirDestino; |
88 | if (! file_exists ( $dirmap ) || $dirmap == dirname ( $_SESSION ["locaplic"] ) || $dirmap == dirname ( $_SESSION ["locaplic"] ) . "/") { | 89 | if (! file_exists ( $dirmap ) || $dirmap == dirname ( $_SESSION ["locaplic"] ) || $dirmap == dirname ( $_SESSION ["locaplic"] ) . "/") { |
89 | echo "<div class='alert alert-danger' role='alert'>Pasta não existe no servidor ou o local não é permitido</div>"; | 90 | echo "<div class='alert alert-danger' role='alert'>Pasta não existe no servidor ou o local não é permitido</div>"; |
@@ -145,7 +146,7 @@ if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { | @@ -145,7 +146,7 @@ if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { | ||
145 | exit (); | 146 | exit (); |
146 | } | 147 | } |
147 | 148 | ||
148 | - $checkphp = \admin\php\funcoesAdmin\fileContemString ( $dirmap . "/" . $nomePrefixo . ".prj", "<?" ); | 149 | + $checkphp = \admin\php\funcoesAdmin\fileContemString ( $dirmap . "/" . $nomePrefixo . ".prj", "<?php" ); |
149 | if ($checkphp == true) { | 150 | if ($checkphp == true) { |
150 | echo "<div class='alert alert-danger' role='alert'>Arquivo prj invalido</div>"; | 151 | echo "<div class='alert alert-danger' role='alert'>Arquivo prj invalido</div>"; |
151 | unlink ( $dirmap . "/" . $nomePrefixo . ".shp" ); | 152 | unlink ( $dirmap . "/" . $nomePrefixo . ".shp" ); |
@@ -154,7 +155,7 @@ if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { | @@ -154,7 +155,7 @@ if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { | ||
154 | unlink ( $dirmap . "/" . $nomePrefixo . ".prj" ); | 155 | unlink ( $dirmap . "/" . $nomePrefixo . ".prj" ); |
155 | exit (); | 156 | exit (); |
156 | } | 157 | } |
157 | - $checkphp = \admin\php\funcoesAdmin\fileContemString ( $dirmap . "/" . $nomePrefixo . ".shx", "<?" ); | 158 | + $checkphp = \admin\php\funcoesAdmin\fileContemString ( $dirmap . "/" . $nomePrefixo . ".shx", "<?php" ); |
158 | if ($checkphp == true) { | 159 | if ($checkphp == true) { |
159 | echo "<div class='alert alert-danger' role='alert'>Arquivo shx invalido</div>"; | 160 | echo "<div class='alert alert-danger' role='alert'>Arquivo shx invalido</div>"; |
160 | unlink ( $dirmap . "/" . $nomePrefixo . ".shp" ); | 161 | unlink ( $dirmap . "/" . $nomePrefixo . ".shp" ); |
@@ -163,7 +164,7 @@ if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { | @@ -163,7 +164,7 @@ if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { | ||
163 | unlink ( $dirmap . "/" . $nomePrefixo . ".prj" ); | 164 | unlink ( $dirmap . "/" . $nomePrefixo . ".prj" ); |
164 | exit (); | 165 | exit (); |
165 | } | 166 | } |
166 | - $checkphp = \admin\php\funcoesAdmin\fileContemString ( $dirmap . "/" . $nomePrefixo . ".dbf", "<?" ); | 167 | + $checkphp = \admin\php\funcoesAdmin\fileContemString ( $dirmap . "/" . $nomePrefixo . ".dbf", "<?php" ); |
167 | if ($checkphp == true) { | 168 | if ($checkphp == true) { |
168 | echo "<div class='alert alert-danger' role='alert'>Arquivo dbf invalido</div>"; | 169 | echo "<div class='alert alert-danger' role='alert'>Arquivo dbf invalido</div>"; |
169 | unlink ( $dirmap . "/" . $nomePrefixo . ".shp" ); | 170 | unlink ( $dirmap . "/" . $nomePrefixo . ".shp" ); |
@@ -173,11 +174,14 @@ if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { | @@ -173,11 +174,14 @@ if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { | ||
173 | exit (); | 174 | exit (); |
174 | } | 175 | } |
175 | echo "<div class='alert alert-success' role='alert'>Arquivo enviado.</div>"; | 176 | echo "<div class='alert alert-success' role='alert'>Arquivo enviado.</div>"; |
177 | + ob_flush ();flush (); sleep ( 2 ); | ||
176 | if ($i3GEOuploadCriaMapfile == "on" && file_exists ( $_SESSION ["locaplic"] . "/temas/" . $nomePrefixo . ".map" )) { | 178 | if ($i3GEOuploadCriaMapfile == "on" && file_exists ( $_SESSION ["locaplic"] . "/temas/" . $nomePrefixo . ".map" )) { |
177 | echo "<div class='alert alert-danger' role='alert'>Arquivo mapfile com esse nome já existe.</div>"; | 179 | echo "<div class='alert alert-danger' role='alert'>Arquivo mapfile com esse nome já existe.</div>"; |
178 | $i3GEOuploadCriaMapfile = ""; | 180 | $i3GEOuploadCriaMapfile = ""; |
179 | } | 181 | } |
180 | if ($i3GEOuploadCriaMapfile == "on") { | 182 | if ($i3GEOuploadCriaMapfile == "on") { |
183 | + echo "<div class='alert alert-success' role='alert'>Criando mapfile...</div>"; | ||
184 | + ob_flush ();flush (); sleep ( 2 ); | ||
181 | // verifica se o usuario marcou a opcao de cria mapfile | 185 | // verifica se o usuario marcou a opcao de cria mapfile |
182 | // nesse caso o aplicativo de upload esta sendo executado de dentro do sistema de administracao, e o mapfile devera | 186 | // nesse caso o aplicativo de upload esta sendo executado de dentro do sistema de administracao, e o mapfile devera |
183 | // ser criado e registrado no sistema | 187 | // ser criado e registrado no sistema |
@@ -187,9 +191,7 @@ if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { | @@ -187,9 +191,7 @@ if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { | ||
187 | $en = $nomePrefixo; | 191 | $en = $nomePrefixo; |
188 | $es = $nomePrefixo; | 192 | $es = $nomePrefixo; |
189 | $sfileObj = ms_newShapefileObj ( $dirmap . "/" . $nomePrefixo . ".shp", - 1 ); | 193 | $sfileObj = ms_newShapefileObj ( $dirmap . "/" . $nomePrefixo . ".shp", - 1 ); |
190 | - if (! isset ( $tipo ) || $tipo == "") { | ||
191 | - $tipo = $sfileObj->type; | ||
192 | - } | 194 | + $tipo = $sfileObj->type; |
193 | if ($tipo == 1) { | 195 | if ($tipo == 1) { |
194 | $tipoLayer = MS_LAYER_POINT; | 196 | $tipoLayer = MS_LAYER_POINT; |
195 | } | 197 | } |
@@ -207,6 +209,9 @@ if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { | @@ -207,6 +209,9 @@ if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { | ||
207 | $layer = $mapa->getLayerByName ( $codigo ); | 209 | $layer = $mapa->getLayerByName ( $codigo ); |
208 | $layer->set ( "data", $data ); | 210 | $layer->set ( "data", $data ); |
209 | $layer->set ( "type", $tipoLayer ); | 211 | $layer->set ( "type", $tipoLayer ); |
212 | + if(file_exists($dirmap . "/" . $nomePrefixo . ".prj")){ | ||
213 | + $layer->setprojection("AUTO"); | ||
214 | + } | ||
210 | $mapa->save ( $_SESSION ["locaplic"] . "/temas/" . $codigo . ".map" ); | 215 | $mapa->save ( $_SESSION ["locaplic"] . "/temas/" . $codigo . ".map" ); |
211 | echo "<div class='alert alert-success' role='alert'>Mapfile $nomePrefixo criado!!!</div>"; | 216 | echo "<div class='alert alert-success' role='alert'>Mapfile $nomePrefixo criado!!!</div>"; |
212 | } else { | 217 | } else { |
@@ -229,7 +234,6 @@ function verificaNome($nome) { | @@ -229,7 +234,6 @@ function verificaNome($nome) { | ||
229 | $extensao = $lista [count ( $lista ) - 1]; | 234 | $extensao = $lista [count ( $lista ) - 1]; |
230 | if (($extensao != "dbf") && ($extensao != "shx") && ($extensao != "shp") && ($extensao != "prj")) { | 235 | if (($extensao != "dbf") && ($extensao != "shx") && ($extensao != "shp") && ($extensao != "prj")) { |
231 | echo "Nome de arquivo inválido. $nome"; | 236 | echo "Nome de arquivo inválido. $nome"; |
232 | - paraAguarde (); | ||
233 | exit (); | 237 | exit (); |
234 | } | 238 | } |
235 | } | 239 | } |
admin1/upload/arquivo/index.php
@@ -3,7 +3,7 @@ define ( "ONDEI3GEO", "../../.." ); | @@ -3,7 +3,7 @@ define ( "ONDEI3GEO", "../../.." ); | ||
3 | include ("exec.php"); | 3 | include ("exec.php"); |
4 | include "../../head.php"; | 4 | include "../../head.php"; |
5 | // monta o combo com a lista de pastas para armazenar os arquivos | 5 | // monta o combo com a lista de pastas para armazenar os arquivos |
6 | -$chaves = array_keys ( $_SESSION ["i3geoUploadDataWL"] ); | 6 | +$chaves = array_keys ( $_SESSION ["i3geoUploadDataWL"]["arquivos"] ); |
7 | $comboPastas = '<select name="dirDestino" class="form-control" required><option value=""></option>'; | 7 | $comboPastas = '<select name="dirDestino" class="form-control" required><option value=""></option>'; |
8 | foreach ( $chaves as $c ) { | 8 | foreach ( $chaves as $c ) { |
9 | $comboPastas .= "<option value='$c'>$c</option>"; | 9 | $comboPastas .= "<option value='$c'>$c</option>"; |
@@ -50,108 +50,101 @@ $comboPastas .= "</select>"; | @@ -50,108 +50,101 @@ $comboPastas .= "</select>"; | ||
50 | </div> | 50 | </div> |
51 | </div> | 51 | </div> |
52 | </div> | 52 | </div> |
53 | - </div> | ||
54 | - </div> | ||
55 | -</div> | ||
56 | -<div class="container hidden" id="corpo"> | ||
57 | - <form style="" target="i3GEOuploadiframe" action="exec.php" method="post" ENCTYPE="multipart/form-data" onsubmit="javascript:$('#modalUpload').modal('show');" class="form-horizontal" role="form" | ||
58 | - method="post"> | ||
59 | - <div class="row center-block well"> | ||
60 | - <div class="col-md-12"> | ||
61 | - <h4>{{{txtArquivos}}}</h4> | ||
62 | - <div class="form-group form-group-lg col-md-6"> | ||
63 | - <div class="input-group-btn"> | ||
64 | - <button type="button" class="btn btn-primary pull-left" onclick="$(this).parent().find('input[type=file]').click();">SHP</button> | ||
65 | - <input name="i3GEOuploadshp" onchange="$(this).parent().parent().find('.form-control').html($(this).val().split(/[\\|/]/).pop());" style="display: none;" type="file"> | ||
66 | - <span class="form-control"></span> | ||
67 | - </div> | ||
68 | - </div> | ||
69 | - <div class="form-group form-group-lg col-md-6"> | ||
70 | - <div class="input-group-btn"> | ||
71 | - <button type="button" class="btn btn-primary pull-left" onclick="$(this).parent().find('input[type=file]').click();">SHX</button> | ||
72 | - <input name="i3GEOuploadshx" onchange="$(this).parent().parent().find('.form-control').html($(this).val().split(/[\\|/]/).pop());" style="display: none;" type="file"> | ||
73 | - <span class="form-control"></span> | ||
74 | - </div> | ||
75 | - </div> | ||
76 | - <div class="form-group form-group-lg col-md-6"> | ||
77 | - <div class="input-group-btn"> | ||
78 | - <button type="button" class="btn btn-primary pull-left" onclick="$(this).parent().find('input[type=file]').click();">DBF</button> | ||
79 | - <input name="i3GEOuploaddbf" onchange="$(this).parent().parent().find('.form-control').html($(this).val().split(/[\\|/]/).pop());" style="display: none;" type="file"> | ||
80 | - <span class="form-control"></span> | ||
81 | - </div> | ||
82 | - </div> | ||
83 | - <div class="form-group form-group-lg col-md-6"> | ||
84 | - <div class="input-group-btn"> | ||
85 | - <button type="button" class="btn btn-primary pull-left" onclick="$(this).parent().find('input[type=file]').click();">PRJ</button> | ||
86 | - <input name="i3GEOuploadprj" onchange="$(this).parent().parent().find('.form-control').html($(this).val().split(/[\\|/]/).pop());" style="display: none;" type="file"> | ||
87 | - <span class="form-control"></span> | 53 | + <form style="" target="i3GEOuploadiframe" action="exec.php" method="post" ENCTYPE="multipart/form-data" onsubmit="javascript:$('#modalUpload').modal('show');" class="form-horizontal" role="form" |
54 | + method="post"> | ||
55 | + <div class="row center-block well hidden" id="corpo"> | ||
56 | + <div class="col-md-12"> | ||
57 | + <div class="form-group form-group-lg"> | ||
58 | + <label class="col-md-5 control-label">{{{txtArquivos}}}</label> | ||
59 | + <div class="col-md-7"> | ||
60 | + <div class="form-group form-group-lg col-md-12"> | ||
61 | + <div class="input-group-btn"> | ||
62 | + <button type="button" class="btn btn-primary pull-left" onclick="$(this).parent().find('input[type=file]').click();">SHP</button> | ||
63 | + <input name="i3GEOuploadshp" onchange="$(this).parent().parent().find('.form-control').html($(this).val().split(/[\\|/]/).pop());" style="display: none;" type="file"> | ||
64 | + <span class="form-control"></span> | ||
65 | + </div> | ||
66 | + </div> | ||
67 | + <div class="form-group form-group-lg col-md-12"> | ||
68 | + <div class="input-group-btn"> | ||
69 | + <button type="button" class="btn btn-primary pull-left" onclick="$(this).parent().find('input[type=file]').click();">SHX</button> | ||
70 | + <input name="i3GEOuploadshx" onchange="$(this).parent().parent().find('.form-control').html($(this).val().split(/[\\|/]/).pop());" style="display: none;" type="file"> | ||
71 | + <span class="form-control"></span> | ||
72 | + </div> | ||
73 | + </div> | ||
74 | + <div class="form-group form-group-lg col-md-12"> | ||
75 | + <div class="input-group-btn"> | ||
76 | + <button type="button" class="btn btn-primary pull-left" onclick="$(this).parent().find('input[type=file]').click();">DBF</button> | ||
77 | + <input name="i3GEOuploaddbf" onchange="$(this).parent().parent().find('.form-control').html($(this).val().split(/[\\|/]/).pop());" style="display: none;" type="file"> | ||
78 | + <span class="form-control"></span> | ||
79 | + </div> | ||
80 | + </div> | ||
81 | + <div class="form-group form-group-lg col-md-12"> | ||
82 | + <div class="input-group-btn"> | ||
83 | + <button type="button" class="btn btn-primary pull-left" onclick="$(this).parent().find('input[type=file]').click();">PRJ</button> | ||
84 | + <input name="i3GEOuploadprj" onchange="$(this).parent().parent().find('.form-control').html($(this).val().split(/[\\|/]/).pop());" style="display: none;" type="file"> | ||
85 | + <span class="form-control"></span> | ||
86 | + </div> | ||
87 | + </div> | ||
88 | + </div> | ||
89 | + </div> | ||
88 | </div> | 90 | </div> |
89 | - </div> | 91 | + <div class="col-md-12"> |
92 | + <div class="form-group form-group-lg"> | ||
93 | + <label class="col-md-5 control-label" for="dirDestino">{{{pastaArmazenamento}}}</label> | ||
94 | + <div class="col-md-7"> | ||
95 | + <?php echo $comboPastas; ?> | ||
96 | + </div> | ||
97 | + </div> | ||
98 | + <div class="form-group form-group-lg"> | ||
99 | + <label class="col-md-5 control-label" for="uploadEPSG">{{{projecao}}}</label> | ||
100 | + <div class="col-md-7"> | ||
101 | + <select title="{{{projecao}}}" id="uploadEPSG" name="uploadEPSG" class="form-control"> | ||
90 | 102 | ||
91 | - </div> | ||
92 | - </div> | ||
93 | - <div class="row center-block well"> | ||
94 | - <div class="col-md-12"> | ||
95 | - <div class="form-group form-group-lg"> | ||
96 | - <label class="col-md-5 control-label" for="dirDestino">{{{pastaArmazenamento}}}</label> | ||
97 | - <div class="col-md-7"> | ||
98 | - <?php echo $comboPastas; ?> | 103 | + </select> |
104 | + </div> | ||
105 | + </div> | ||
106 | + <div class="form-group form-group-lg"> | ||
107 | + <label class="col-md-5 control-label" style="margin-top: 0px;" for="i3GEOuploadCriaMapfile">{{{criaMapfile}}}</label> | ||
108 | + <div class="col-md-7"> | ||
109 | + <div class=" checkbox"> | ||
110 | + <label> <input title="{{{criaMapfile}}}" name="i3GEOuploadCriaMapfile" type="checkbox"> | ||
111 | + </label> | ||
112 | + </div> | ||
113 | + </div> | ||
114 | + </div> | ||
99 | </div> | 115 | </div> |
100 | - </div> | ||
101 | - <div class="form-group form-group-lg"> | ||
102 | - <label class="col-md-5 control-label" for="tipo">{{{tipoGeom}}}</label> | ||
103 | - <div class="col-md-7"> | ||
104 | - <select title="{{{tipoGeom}}}" name="tipo" class="form-control"> | ||
105 | - <option value="">{{{naoConhecido}}}</option> | ||
106 | - <option value="1">{{{pontual}}}</option> | ||
107 | - <option value="5">{{{poligonal}}}</option> | ||
108 | - <option value="3">{{{linear}}}</option> | ||
109 | - </select> | 116 | + <div class="col-md-12"> |
117 | + <div class="pull-right"> | ||
118 | + <button type="submit" class="btn btn-primary" role="button" style="color: #008579;">{{envia}}</button> | ||
119 | + </div> | ||
110 | </div> | 120 | </div> |
111 | </div> | 121 | </div> |
112 | - <div class="form-group form-group-lg"> | ||
113 | - <label class="col-md-5 control-label" for="uploadEPSG">{{{projecao}}}</label> | ||
114 | - <div class="col-md-7"> | ||
115 | - <select title="{{{projecao}}}" id="uploadEPSG" name="uploadEPSG" class="form-control"> | ||
116 | - | ||
117 | - </select> | 122 | + </form> |
123 | + </div> | ||
124 | + <div id="modalUpload" class="modal fade" tabindex="-1"> | ||
125 | + <div class="modal-dialog modal-lg"> | ||
126 | + <div class="modal-content"> | ||
127 | + <div class="modal-header"> | ||
128 | + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||
129 | + <span aria-hidden="true">×</span> | ||
130 | + </button> | ||
118 | </div> | 131 | </div> |
119 | - </div> | ||
120 | - <div class="form-group form-group-lg"> | ||
121 | - <label class="col-md-5 control-label" style="margin-top: 0px;" for="i3GEOuploadCriaMapfile">{{{criaMapfile}}}</label> | ||
122 | - <div class="col-md-7"> | ||
123 | - <div class=" checkbox"> | ||
124 | - <label> <input title="{{{criaMapfile}}}" name="i3GEOuploadCriaMapfile" type="checkbox"> | ||
125 | - </label> | 132 | + <div class="modal-content"> |
133 | + <div class="modal-body modal-lg"> | ||
134 | + <iframe name=i3GEOuploadiframe style="text-align: left; border: 0px solid gray;" width="100%" height="500px"></iframe> | ||
126 | </div> | 135 | </div> |
127 | </div> | 136 | </div> |
128 | </div> | 137 | </div> |
129 | </div> | 138 | </div> |
130 | </div> | 139 | </div> |
131 | - <div class="row center-block well"> | ||
132 | - <div class="col-md-12"> | ||
133 | - <div class="pull-right"> | ||
134 | - <button type="submit" class="btn btn-primary" role="button" style="color: #008579;">{{envia}}</button> | ||
135 | - </div> | ||
136 | - </div> | ||
137 | - </div> | ||
138 | - | ||
139 | - </form> | ||
140 | -</div> | ||
141 | -<div id="modalUpload" class="modal fade" tabindex="-1"> | ||
142 | - <div class="modal-dialog modal-lg"> | ||
143 | - <div class="modal-header"> | ||
144 | - <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||
145 | - <span aria-hidden="true">×</span> | ||
146 | - </button> | ||
147 | - </div> | ||
148 | - <div class="modal-content"> | ||
149 | - <div class="modal-body modal-lg"> | ||
150 | - <iframe name=i3GEOuploadiframe style="text-align: left; border: 0px solid gray;" width="100%" height="500px"></iframe> | ||
151 | - </div> | ||
152 | - </div> | ||
153 | </div> | 140 | </div> |
154 | </div> | 141 | </div> |
142 | +<?php | ||
143 | +if (empty ( $_SESSION ["i3geoUploadDataWL"] )) { | ||
144 | + echo "<script>iniciaMenuPrincipal();i3GEOadmin.core.mostraErro('Nenhuma pasta cadastrada para upload nas configurações do i3Geo (ms_configura)');</script>"; | ||
145 | + exit (); | ||
146 | +} | ||
147 | +?> | ||
155 | <script id="templateProj" type="x-tmpl-mustache"> | 148 | <script id="templateProj" type="x-tmpl-mustache"> |
156 | <option value="{{{codigo}}}">{{{nome}}}</option> | 149 | <option value="{{{codigo}}}">{{{nome}}}</option> |
157 | </script> | 150 | </script> |
admin1/upload/banco/index.php
@@ -1,36 +0,0 @@ | @@ -1,36 +0,0 @@ | ||
1 | -<?php | ||
2 | -define ( "ONDEI3GEO", "../../.." ); | ||
3 | -include ("exec.php"); | ||
4 | - | ||
5 | -include "../../head.php"; | ||
6 | -?> | ||
7 | - <div class="container-fluid migalha" > | ||
8 | - <div class="row"> | ||
9 | - <div class="btn-group btn-breadcrumb"> | ||
10 | - <a class="btn btn-default" href="../../../init/index.php"><span>i3Geo</span></a> | ||
11 | - <a class="btn btn-default" href="../../index.php"><span>Admin</span></a> | ||
12 | - <a class="btn btn-default" style="pointer-events: none"><span>Upload</span></a> | ||
13 | - <a class="btn btn-default" style="pointer-events: none"><span>para o banco de dados</span></a> | ||
14 | - </div> | ||
15 | - </div> | ||
16 | - </div> | ||
17 | -<div class="container-fluid"> | ||
18 | - <div class="row"> | ||
19 | - <iframe src="../../../admin/html/estat_editor_.html" style="width:100%; height:5000px;border:none; scrolling:no; frameborder:0; marginheight:0; marginwidth:0;" ></iframe> | ||
20 | -</div> | ||
21 | -</div> | ||
22 | -<script> | ||
23 | - $(document).ready(function(){ | ||
24 | - //vem de admin1/index.js | ||
25 | - iniciaMenuPrincipal(); | ||
26 | - $('ul.dropdown-menu [data-toggle=dropdown]').on('click', function(event) { | ||
27 | - event.preventDefault(); | ||
28 | - event.stopPropagation(); | ||
29 | - $(this).parent().siblings().removeClass('open'); | ||
30 | - $(this).parent().toggleClass('open'); | ||
31 | - }); | ||
32 | - $.material.init(); | ||
33 | - }); | ||
34 | -</script> | ||
35 | -</body> | ||
36 | -</html> |
@@ -0,0 +1,443 @@ | @@ -0,0 +1,443 @@ | ||
1 | +<?php | ||
2 | +/****************************************************************/ | ||
3 | +// | ||
4 | +// checa login | ||
5 | +// valida _GET e _POST, juntando em _GET | ||
6 | +// pega algumas variaveis de uso mais comum | ||
7 | +// session_start | ||
8 | +// | ||
9 | +include ("../../php/checaLogin.php"); | ||
10 | +\admin\php\login\checaLogin (); | ||
11 | +// funcoes de administracao | ||
12 | +include ($_SESSION ["locaplic"] . "/admin1/php/funcoesAdmin.php"); | ||
13 | +// | ||
14 | +// carrega outras funcoes e extensoes do PHP | ||
15 | +// | ||
16 | +include ($_SESSION ["locaplic"] . "/classesphp/carrega_ext.php"); | ||
17 | +// | ||
18 | +// conexao com o banco de administracao | ||
19 | +// cria as variaveis $dbh e $dbhw alem de conexaoadmin | ||
20 | +// | ||
21 | +include ($_SESSION ["locaplic"] . "/admin1/php/conexao.php"); | ||
22 | +/** | ||
23 | + * ************************************************************ | ||
24 | + */ | ||
25 | +if (\admin\php\funcoesAdmin\verificaOperacaoSessao ( "admin/html/subirshapefile" ) === false) { | ||
26 | + header ( "HTTP/1.1 403 Vc nao pode realizar essa operacao" ); | ||
27 | + exit (); | ||
28 | +} | ||
29 | +if (! isset ( $idioma ) || $idioma == "") { | ||
30 | + $idioma = "pt"; | ||
31 | +} | ||
32 | + | ||
33 | +if (isset ( $_GET ["tipo"] )) { | ||
34 | + $tipo = $_GET ["tipo"]; | ||
35 | +} | ||
36 | +if (! isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { | ||
37 | + return; | ||
38 | +} | ||
39 | +?> | ||
40 | +<!DOCTYPE html> | ||
41 | +<html lang="pt-br"> | ||
42 | +<head> | ||
43 | +<META HTTP-EQUIV="Content-Type"> | ||
44 | +<meta charset='utf-8'> | ||
45 | +<meta http-equiv='X-UA-Compatible' content='IE=edge'> | ||
46 | +<meta name='viewport' content='width=device-width, initial-scale=1'> | ||
47 | +<link rel='stylesheet' type='text/css' href='../../../pacotes/jquery/jquery-ui/jquery-ui.min.css'> | ||
48 | +<link rel='stylesheet' type='text/css' href='//fonts.googleapis.com/css?family=Roboto:300,400,500,700'> | ||
49 | +<link rel='stylesheet' type='text/css' href='//fonts.googleapis.com/icon?family=Material+Icons'> | ||
50 | +<!-- Bootstrap core CSS --> | ||
51 | +<link href='../../../pacotes/bootstrap/css/bootstrap.min.css' rel='stylesheet'> | ||
52 | +<!-- Bootstrap Material Design --> | ||
53 | +<link rel='stylesheet' type='text/css' href='../../../pacotes/bootstrap-material-design/dist/css/bootstrap-material-design.min.css'> | ||
54 | +<link rel='stylesheet' type='text/css' href='../../../pacotes/bootstrap-material-design/dist/css/ripples.min.css'> | ||
55 | +<!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> | ||
56 | +<link href='../../../pacotes/bootstrap/css/ie10-viewport-bug-workaround.css' rel='stylesheet'> | ||
57 | +<!-- Custom styles for this template --> | ||
58 | +<link href='../../../pacotes/font-awesome/css/font-awesome.min.css' rel='stylesheet'> | ||
59 | + | ||
60 | +<link href='../../../pacotes/bootstrap-accessibility-plugin/plugins/css/bootstrap-accessibility.css' rel='stylesheet'> | ||
61 | +<script src='../../../admin1/headjs.php'></script> | ||
62 | +<script src="../../../classesjs/classe_util.js"></script> | ||
63 | +</head> | ||
64 | +<body bgcolor="white" style="background-color: white; text-align: left;"> | ||
65 | + <p> | ||
66 | +<?php | ||
67 | +ob_flush ();flush (); sleep ( 2 ); | ||
68 | +if (isset ( $_FILES ['i3GEOuploadshp'] ['name'] )) { | ||
69 | + if (empty ( $_SESSION ["dir_tmp"] )) { | ||
70 | + echo "<div class='alert alert-danger' role='alert'>Pasta não encontrada</div>"; | ||
71 | + exit (); | ||
72 | + } | ||
73 | + echo "<div class='alert alert-success' role='alert'>Carregando o arquivo...</div>"; | ||
74 | + | ||
75 | + ob_flush ();flush (); sleep ( 2 ); | ||
76 | + | ||
77 | + if (! file_exists ( $_SESSION ["dir_tmp"] ) || empty($_SESSION ["dir_tmp"])) { | ||
78 | + echo "<div class='alert alert-danger' role='alert'>Pasta temporária não existe no servidor</div>"; | ||
79 | + exit (); | ||
80 | + } | ||
81 | + // verifica nomes | ||
82 | + verificaNome ( $_FILES ['i3GEOuploadshp'] ['name'] ); | ||
83 | + verificaNome ( $_FILES ['i3GEOuploadshx'] ['name'] ); | ||
84 | + verificaNome ( $_FILES ['i3GEOuploaddbf'] ['name'] ); | ||
85 | + // remove acentos | ||
86 | + $nomePrefixo = "shp2pg".(rand (9000,10000)) * -1; | ||
87 | + // sobe arquivo | ||
88 | + $Arquivo = $_FILES ['i3GEOuploadshp'] ['tmp_name']; | ||
89 | + $status = move_uploaded_file ( $Arquivo, $_SESSION ["dir_tmp"] . "/" . $nomePrefixo . ".shp" ); | ||
90 | + if ($status != 1) { | ||
91 | + echo "<div class='alert alert-danger' role='alert'>Ocorreu um erro no envio do arquivo SHP. Pode ser uma limitação quanto ao tamanho do arquivo ou permissão de escrita na pasta indicada.</div>"; | ||
92 | + exit (); | ||
93 | + } | ||
94 | + $Arquivo = $_FILES ['i3GEOuploadshx'] ['tmp_name']; | ||
95 | + $status = move_uploaded_file ( $Arquivo, $_SESSION ["dir_tmp"] . "/" . $nomePrefixo . ".shx" ); | ||
96 | + if ($status != 1) { | ||
97 | + echo "<div class='alert alert-danger' role='alert'>Ocorreu um erro no envio do arquivo SHX</div>"; | ||
98 | + exit (); | ||
99 | + } | ||
100 | + $Arquivo = $_FILES ['i3GEOuploaddbf'] ['tmp_name']; | ||
101 | + $status = move_uploaded_file ( $Arquivo, $_SESSION ["dir_tmp"] . "/" . $nomePrefixo . ".dbf" ); | ||
102 | + if ($status != 1) { | ||
103 | + echo "<div class='alert alert-danger' role='alert'>Ocorreu um erro no envio do arquivo DBF</div>"; | ||
104 | + exit (); | ||
105 | + } | ||
106 | + if (! file_exists ( $_SESSION ["dir_tmp"] . "/" . $nomePrefixo . ".shp" )) { | ||
107 | + echo "<div class='alert alert-danger' role='alert'>Ocorreu algum problema no envio do arquivo</div>"; | ||
108 | + exit (); | ||
109 | + } | ||
110 | + $checkphp = \admin\php\funcoesAdmin\fileContemString ( $_SESSION ["dir_tmp"] . "/" . $nomePrefixo . ".shx", "<?php" ); | ||
111 | + if ($checkphp == true) { | ||
112 | + echo "<div class='alert alert-danger' role='alert'>Arquivo shx invalido</div>"; | ||
113 | + unlink ( $_SESSION ["dir_tmp"] . "/" . $nomePrefixo . ".shp" ); | ||
114 | + unlink ( $_SESSION ["dir_tmp"] . "/" . $nomePrefixo . ".dbf" ); | ||
115 | + unlink ( $_SESSION ["dir_tmp"] . "/" . $nomePrefixo . ".shx" ); | ||
116 | + exit (); | ||
117 | + } | ||
118 | + $checkphp = \admin\php\funcoesAdmin\fileContemString ( $dirmap . "/" . $nomePrefixo . ".dbf", "<?php" ); | ||
119 | + if ($checkphp == true) { | ||
120 | + echo "<div class='alert alert-danger' role='alert'>Arquivo dbf invalido</div>"; | ||
121 | + unlink ( $_SESSION ["dir_tmp"] . "/" . $nomePrefixo . ".shp" ); | ||
122 | + unlink ( $_SESSION ["dir_tmp"] . "/" . $nomePrefixo . ".dbf" ); | ||
123 | + unlink ( $_SESSION ["dir_tmp"] . "/" . $nomePrefixo . ".shx" ); | ||
124 | + exit (); | ||
125 | + } | ||
126 | + echo "<div class='alert alert-success' role='alert'>Arquivo enviado.</div>"; | ||
127 | + // | ||
128 | + //gera o script para inclusao no banco | ||
129 | + // | ||
130 | + $shapefileObj = ms_newShapefileObj($_SESSION ["dir_tmp"] . "/" . $nomePrefixo . ".shp",-1); | ||
131 | + $numshapes = $shapefileObj->numshapes; | ||
132 | + | ||
133 | + echo "<div class='alert alert-info' role='alert'>Numshapes existentes no SHP: " . $numshapes . "</div>"; | ||
134 | + ob_flush ();flush (); sleep ( 2 ); | ||
135 | + | ||
136 | + $mapObj = ms_newMapObjFromString("MAP END"); | ||
137 | + $layer = ms_newLayerObj($mapObj); | ||
138 | + $layer->set("data",$_SESSION ["dir_tmp"] . "/" . $nomePrefixo . ".shp"); | ||
139 | + if(file_exists($_SESSION ["dir_tmp"] . "/" . $nomePrefixo . ".prj")){ | ||
140 | + $layer->setprojection("AUTO"); | ||
141 | + } | ||
142 | + $layer->open(); | ||
143 | + $colunasTemp = $layer->getItems(); | ||
144 | + $colunas = array(); | ||
145 | + foreach($colunasTemp as $c){ | ||
146 | + if(!is_numeric($c)){ | ||
147 | + $colunas[] = $c; | ||
148 | + } | ||
149 | + } | ||
150 | + | ||
151 | + echo "<div class='alert alert-info' role='alert'>Tipo do SHP: " . $shapefileObj->type . "</div>"; | ||
152 | + echo "<div class='alert alert-info' role='alert'>Colunas: <p><pre>"; | ||
153 | + print_r( $colunas ); | ||
154 | + echo "</pre></p></div>"; | ||
155 | + | ||
156 | + ob_flush(); flush(); sleep(2); | ||
157 | + | ||
158 | + $sqinsert = array(); | ||
159 | + //verifica o tipo de coluna | ||
160 | + $tipoColuna = array(); | ||
161 | + $testar = $numshapes; | ||
162 | + if($numshapes > 50){ | ||
163 | + $testar = 50; | ||
164 | + } | ||
165 | + foreach($colunas as $coluna){ | ||
166 | + $tipo = "numeric"; | ||
167 | + for ($i=0; $i<$testar;$i++){ | ||
168 | + $s = $layer->getShape(new resultObj($i)); | ||
169 | + $v = $s->getValue($layer,$coluna); | ||
170 | + if(!is_numeric($v)){ | ||
171 | + $tipo = "varchar"; | ||
172 | + } | ||
173 | + } | ||
174 | + $tipoColuna[$coluna] = $tipo; | ||
175 | + } | ||
176 | + echo "<div class='alert alert-info' role='alert'>Tipos das colunas: <p><pre>"; | ||
177 | + print_r( $tipoColuna ); | ||
178 | + echo "</pre></p></div>"; | ||
179 | + | ||
180 | + //verifica autorizacao para o esquema | ||
181 | + if(empty($_POST["i3GEOuploadEsquemaDestino"]) || !in_array($_POST["i3GEOuploadEsquemaDestino"],$_SESSION["i3geoUploadDataWL"]["postgis"]["esquemas"])){ | ||
182 | + echo "<div class='alert alert-danger' role='alert'>Esquema não permitido</div>"; | ||
183 | + exit; | ||
184 | + } | ||
185 | + | ||
186 | + $conexao = $_SESSION["i3geoUploadDataWL"]["postgis"]["conexao"]; | ||
187 | + try { | ||
188 | + $dbh = new PDO('pgsql:dbname='.$conexao["dbname"].';user='.$conexao["user"].';password='.$conexao["password"].';host='.$conexao["host"].';port='.$conexao["port"]); | ||
189 | + } catch (PDOException $e) { | ||
190 | + echo "<div class='alert alert-danger' role='alert'>Falha ao conectar com o banco</div>"; | ||
191 | + exit; | ||
192 | + } | ||
193 | + if(empty($_POST["i3GEOuploadNomeTabela"]) || empty($_POST["i3GEOuploadEsquemaDestino"])){ | ||
194 | + exit; | ||
195 | + } | ||
196 | + //gera o script para criar a tabela | ||
197 | + //verifica se a tabela ja existe | ||
198 | + $sql = "SELECT table_name FROM information_schema.tables where table_schema = '".$_POST["i3GEOuploadEsquemaDestino"]."' AND table_name = '".$_POST["i3GEOuploadNomeTabela"]."'"; | ||
199 | + $res = $dbh->query($sql,PDO::FETCH_ASSOC); | ||
200 | + if(count($res->fetchAll())>0){ | ||
201 | + $tabelaExiste = true; | ||
202 | + } | ||
203 | + else{ | ||
204 | + $tabelaExiste = false; | ||
205 | + } | ||
206 | + //encoding do banco de dados | ||
207 | + $sql = "SELECT pg_encoding_to_char(encoding) FROM pg_database WHERE datname = '".$conexao["dbname"]."'"; | ||
208 | + $res = $dbh->query($sql,PDO::FETCH_ASSOC); | ||
209 | + $encodingdb = $res->fetchAll(); | ||
210 | + $encodingdb = $encodingdb[0]; | ||
211 | + $encodingdb = $encodingdb["pg_encoding_to_char"]; | ||
212 | + if($encodingdb == "UTF8"){ | ||
213 | + $encodingdb = "UTF-8"; | ||
214 | + } | ||
215 | + if($encodingdb == "LATIN1"){ | ||
216 | + $encodingdb = "ISO-8859-1"; | ||
217 | + } | ||
218 | + //a tabela nao existe e e do tipo create | ||
219 | + $sqltabela = array(); | ||
220 | + | ||
221 | + if($tabelaExiste == false && $_POST["i3GEOuploadTipoOperacao"] == "criar"){ | ||
222 | + $sql = "CREATE TABLE ".$_POST["i3GEOuploadEsquemaDestino"].".".$_POST["i3GEOuploadNomeTabela"]."(the_geom geometry"; | ||
223 | + foreach($colunas as $coluna){ | ||
224 | + $sql .= ",".\admin\php\funcoesAdmin\removeAcentos(strtolower($coluna))." ".$tipoColuna[$coluna]; | ||
225 | + } | ||
226 | + $sql .= ")WITH(OIDS=FALSE)"; | ||
227 | + $sqltabela[] = $sql; | ||
228 | + $sqltabela[] = "ALTER TABLE ".$_POST["i3GEOuploadEsquemaDestino"].".".$_POST["i3GEOuploadNomeTabela"]." OWNER TO ".$conexao["user"]; | ||
229 | + $sqltabela[] = "CREATE INDEX ".$_POST["i3GEOuploadNomeTabela"]."_indx_thegeom ON ".$_POST["i3GEOuploadEsquemaDestino"].".".$_POST["i3GEOuploadNomeTabela"]." USING gist (the_geom )"; | ||
230 | + if(!empty($_POST["comentarioShp"])){ | ||
231 | + $enc = mb_detect_encoding($texto); | ||
232 | + $_POST["i3GEOuploadComentario"] = mb_convert_encoding($_POST["i3GEOuploadComentario"],$encodingdb,$enc); | ||
233 | + $sqltabela[] = "COMMENT ON TABLE ".$_POST["i3GEOuploadEsquemaDestino"].".".$_POST["i3GEOuploadNomeTabela"]." IS '".$_POST["i3GEOuploadComentario"]."'"; | ||
234 | + } | ||
235 | + echo "<div class='alert alert-info' role='alert'>Sql tabela: <p><pre>"; | ||
236 | + print_r( $sqltabela ); | ||
237 | + echo "</pre></p></div>"; | ||
238 | + } | ||
239 | + if($tabelaExiste == true && $_POST["i3GEOuploadTipoOperacao"] == "criar"){ | ||
240 | + echo "<div class='alert alert-danger' role='alert'>A tabela existe. Não pode ser criada.</div>"; | ||
241 | + exit; | ||
242 | + } | ||
243 | + //se a tabela existe e e para atualizar os registros | ||
244 | + if($tabelaExiste == true && $_POST["i3GEOuploadTipoOperacao"] == "atualizar"){ | ||
245 | + $sqltabela[] = "delete from ".$_POST["i3GEOuploadEsquemaDestino"].".".$_POST["i3GEOuploadNomeTabela"]; | ||
246 | + } | ||
247 | + | ||
248 | + //gera o script para inserir os dados | ||
249 | + $linhas = array(); | ||
250 | + $insert = "INSERT INTO ".$_POST["i3GEOuploadEsquemaDestino"].".".$_POST["i3GEOuploadNomeTabela"]." (".strtolower(\admin\php\funcoesAdmin\removeAcentos(implode(",",$colunas))).",the_geom)"; | ||
251 | + echo "<div class='alert alert-success' role='alert'>Preparando inclusão de dados...</div>"; | ||
252 | + ob_flush(); | ||
253 | + flush(); | ||
254 | + sleep(1); | ||
255 | + | ||
256 | + $escapar = "'"; | ||
257 | + // | ||
258 | + //caso o usuario tenha definido a projecao de saida, os dados devem ser projetados | ||
259 | + // | ||
260 | + $mapObj->setProjection("init=epsg:".$_POST["i3GEOuploadSridDestino"]); | ||
261 | + $layer->setProjection("init=epsg:".$_POST["i3GEOuploadSridOrigem"]); | ||
262 | + $projInObj = $layer->getProjection(); | ||
263 | + $projOutObj = $mapObj->getProjection(); | ||
264 | + | ||
265 | + for ($i=0; $i<$numshapes;$i++){ | ||
266 | + $s = $layer->getShape(new resultObj($i)); | ||
267 | + //projeta o shape se existir .prj | ||
268 | + if($_POST["i3GEOuploadSridDestino"] != $_POST["i3GEOuploadSridOrigem"]){ | ||
269 | + $s->project($projInObj, $projOutObj); | ||
270 | + } | ||
271 | + $vs = array(); | ||
272 | + foreach($colunas as $coluna){ | ||
273 | + $escape = ""; | ||
274 | + if($tipoColuna[$coluna] == "varchar"){ | ||
275 | + $texto = $s->getValue($layer,$coluna); | ||
276 | + $enc = mb_detect_encoding($texto); | ||
277 | + $textosl = addcslashes($texto,$escapar); | ||
278 | + if($textosl != $texto){ | ||
279 | + $escape = "E"; | ||
280 | + } | ||
281 | + if($enc != "" && $enc != $encodingdb){ | ||
282 | + $textosl = "$escape'".mb_convert_encoding($textosl,$encodingdb,$enc)."'"; | ||
283 | + } | ||
284 | + else{ | ||
285 | + $textosl = "$escape'".$textosl."'"; | ||
286 | + } | ||
287 | + if($textosl == "''"){ | ||
288 | + $textosl = 'null'; | ||
289 | + } | ||
290 | + $vs[] = $textosl; | ||
291 | + } | ||
292 | + else{ | ||
293 | + $valor = $s->getValue($layer,$coluna); | ||
294 | + if($valor == "" || (empty($valor) && $valor != 0)){ | ||
295 | + $valor = 'nulo'; | ||
296 | + } | ||
297 | + $vs[] = $valor; | ||
298 | + } | ||
299 | + } | ||
300 | + if($_POST["i3GEOuploadSridDestino"] == $_POST["i3GEOuploadSridOrigem"]){ | ||
301 | + $vs[] = "st_geomfromtext('".$s->toWkt()."','".$_POST["i3GEOuploadSridDestino"]."')"; | ||
302 | + } | ||
303 | + else{ | ||
304 | + $vs[] = "st_transform(st_geomfromtext('".$s->toWkt()."','".$_POST["i3GEOuploadSridDestino"]."'),'".$_POST["i3GEOuploadSridDestino"]."')"; | ||
305 | + } | ||
306 | + $str = implode(",",$vs); | ||
307 | + $str = str_replace("nulo",'null',$str); | ||
308 | + $linhas[] = $insert."VALUES(".$escape."".$str.")"; | ||
309 | + } | ||
310 | + $layer->close(); | ||
311 | + | ||
312 | + if(!in_array($_POST["i3GEOuploadColunaGid"],$colunas) && $_POST["i3GEOuploadTipoOperacao"] == "criar"){ | ||
313 | + $linhas[] = "alter table ".$_POST["i3GEOuploadEsquemaDestino"].".".$_POST["i3GEOuploadNomeTabela"]." add " . $_POST["i3GEOuploadColunaGid"] . " serial CONSTRAINT ".$_POST["i3GEOuploadNomeTabela"]."_gid_pkey PRIMARY KEY"; | ||
314 | + } | ||
315 | + | ||
316 | + if($_POST["i3GEOuploadApenasScript"] == "on"){ | ||
317 | + echo "<div class='alert alert-info' role='alert'>Sql de inserção de dados: <p><pre>"; | ||
318 | + foreach($linhas as $linha){ | ||
319 | + print_r( $linha )."/n"; | ||
320 | + } | ||
321 | + echo "</pre></p></div>"; | ||
322 | + | ||
323 | + } else { | ||
324 | + //aqui o sql e executado verdadeiramente | ||
325 | + //antes e feito um backup da tabela | ||
326 | + | ||
327 | + | ||
328 | + //$sqltabela sera vazio se a tabela ja existir | ||
329 | + foreach($sqltabela as $linha){ | ||
330 | + try { | ||
331 | + $dbh->query($linha); | ||
332 | + } catch (PDOException $e) { | ||
333 | + echo "<div class='alert alert-danger' role='alert'>Não foi possível criar a tabela<p><pre>"; | ||
334 | + exit; | ||
335 | + } | ||
336 | + } | ||
337 | + //para testar com acentuacao diferente | ||
338 | + $conexao = $_SESSION["i3geoUploadDataWL"]["postgis"]["conexao"]; | ||
339 | + $bdcon = pg_connect('dbname='.$conexao["dbname"].' user='.$conexao["user"].' password='.$conexao["password"].' host='.$conexao["host"].' port='.$conexao["port"]."options='-c client_encoding=LATIN1'"); | ||
340 | + foreach($linhas as $linha){ | ||
341 | + try { | ||
342 | + echo "<div class='alert alert-info' role='alert'>Sql de inserção de dados com erros ou modificados: <p><pre>"; | ||
343 | + $res = $dbh->query($linha); | ||
344 | + if($res == false){ | ||
345 | + $res = pg_query($bdcon,$linha); | ||
346 | + if($res == false){ | ||
347 | + $linha = remove_accents($linha); | ||
348 | + $res = $dbh->query($linha); | ||
349 | + if($res == false){ | ||
350 | + $res = pg_query($bdcon,$linha); | ||
351 | + if($res == false){ | ||
352 | + echo "<p><span style=color:red >Erro em: </span>$linha</p>"; | ||
353 | + } | ||
354 | + } | ||
355 | + else{ | ||
356 | + echo "<p><span style=color:red >Acentos removidos: $linha</span></p>"; | ||
357 | + } | ||
358 | + } | ||
359 | + } | ||
360 | + echo "</pre></p></div>"; | ||
361 | + } catch (PDOException $e) { | ||
362 | + echo "<div class='alert alert-danger' role='alert'>Não foi possível executar os SQLs<p><pre>"; | ||
363 | + } | ||
364 | + } | ||
365 | + $sql = "select * from ".$_POST["i3GEOuploadEsquemaDestino"].".".$_POST["i3GEOuploadNomeTabela"]; | ||
366 | + $q = $dbh->query($sql,PDO::FETCH_ASSOC); | ||
367 | + $r = $q->fetchAll(); | ||
368 | + | ||
369 | + echo "<div class='alert alert-info' role='alert'>"; | ||
370 | + echo "<p>Registros existentes no SHP: $numshapes</p>"; | ||
371 | + | ||
372 | + echo "<p>Registros na tabela final: ". count($r) . "</p>"; | ||
373 | + echo "<p>Diferenças podem ocorrer em função de caracteres acentuados não suportados pelo banco de dados</p>"; | ||
374 | + echo "<p><b>Feito!!!</p>"; | ||
375 | + echo "</div>"; | ||
376 | + } | ||
377 | + // | ||
378 | + ob_flush ();flush (); sleep ( 2 ); | ||
379 | + $nomeMapfile = $_SESSION ["locaplic"] . "/temas/" . $_POST["i3GEOuploadNomeTabela"] . ".map"; | ||
380 | + if ($_POST["i3GEOuploadCriaMapfile"] == "on" && file_exists ( $nomeMapfile )) { | ||
381 | + echo "<div class='alert alert-danger' role='alert'>Arquivo mapfile com o nome " . $_POST["i3GEOuploadNomeTabela"] . "já existe.</div>"; | ||
382 | + $_POST["i3GEOuploadCriaMapfile"] = ""; | ||
383 | + } | ||
384 | + if ($_POST["i3GEOuploadCriaMapfile"] == "on" && $_POST["i3GEOuploadAliasConexao"] != "") { | ||
385 | + $_POST["i3GEOuploadAliasConexao"] = str_replace(" ","",$_POST["i3GEOuploadAliasConexao"]); | ||
386 | + if(!in_array($_POST["i3GEOuploadAliasConexao"],array_keys($_SESSION ["postgis_mapa"]))){ | ||
387 | + echo "<div class='alert alert-danger' role='alert'>Alias para a conexão com o banco não definida</div>"; | ||
388 | + } else { | ||
389 | + echo "<div class='alert alert-success' role='alert'>Criando mapfile...</div>"; | ||
390 | + ob_flush ();flush (); sleep ( 2 ); | ||
391 | + | ||
392 | + if ($shapefileObj->type == 1) { | ||
393 | + $tipoLayer = MS_LAYER_POINT; | ||
394 | + } | ||
395 | + if ($shapefileObj->type == 3) { | ||
396 | + $tipoLayer = MS_LAYER_LINE; | ||
397 | + } | ||
398 | + if ($shapefileObj->type == 5) { | ||
399 | + $tipoLayer = MS_LAYER_POLYGON; | ||
400 | + } | ||
401 | + include ($_SESSION ["locaplic"] . "/admin1/catalogo/mapfile/funcoes.php"); | ||
402 | + $cria = \admin\catalogo\mapfile\adicionar ( $_SESSION ["locaplic"], $_POST["i3GEOuploadNomeTabela"], "", $_POST["i3GEOuploadNomeTabela"], "", "", $_POST["i3GEOuploadNomeTabela"], "", $_POST["i3GEOuploadNomeTabela"], $_POST["i3GEOuploadNomeTabela"], true, $dbhw ); | ||
403 | + if ($cria == true && file_exists ( $_SESSION ["locaplic"] . "/temas/" . $_POST["i3GEOuploadNomeTabela"] . ".map" )) { | ||
404 | + $mapa = ms_newMapObj ( $_SESSION ["locaplic"] . "/temas/" . $_POST["i3GEOuploadNomeTabela"] . ".map" ); | ||
405 | + $layer = $mapa->getLayerByName ( $_POST["i3GEOuploadNomeTabela"] ); | ||
406 | + $layer->set ( "data", "the_geom from (select * from " . $_POST["i3GEOuploadEsquemaDestino"] . "." . $_POST["i3GEOuploadNomeTabela"] . ") as foo using unique " . $_POST["i3GEOuploadColunaGid"] . " using srid=" . $_POST["i3GEOuploadSridDestino"] ); | ||
407 | + $layer->set("connection",$_POST["i3GEOuploadAliasConexao"]); | ||
408 | + $layer->setconnectiontype(6); | ||
409 | + $layer->set ( "type", $tipoLayer ); | ||
410 | + $mapa->save ( $_SESSION ["locaplic"] . "/temas/" . $_POST["i3GEOuploadNomeTabela"] . ".map" ); | ||
411 | + echo "<div class='alert alert-success' role='alert'>Mapfile " . $_POST["i3GEOuploadNomeTabela"] ." criado!!!</div>"; | ||
412 | + } else { | ||
413 | + echo "<div class='alert alert-danger' role='alert'>Mapfile não pode ser criado criado!!!</div>"; | ||
414 | + } | ||
415 | + } | ||
416 | + } | ||
417 | + echo "<div class='alert alert-success' role='alert'>Pode fechar essa janela.</div>"; | ||
418 | +} else { | ||
419 | + echo "<div class='alert alert-danger' role='alert'>Erro ao enviar o arquivo. Talvez o tamanho do arquivo seja maior do que o permitido.</div>"; | ||
420 | +} | ||
421 | +if (file_exists ( $_SESSION ["locaplic"] . "/temas/" . $_POST["i3GEOuploadNomeTabela"] . ".map" )) { | ||
422 | + echo "<div class='alert alert-info' role='alert'><a href='#' onclick=\"abreEditor('" . $_POST["i3GEOuploadNomeTabela"] . "')\" class='alert-link'>Editar mapfile</a></div>"; | ||
423 | +} | ||
424 | +function verificaNome($nome) { | ||
425 | + if (strlen ( basename ( $nome ) ) > 200) { | ||
426 | + exit (); | ||
427 | + } | ||
428 | + $nome = strtolower ( $nome ); | ||
429 | + $lista = explode ( ".", $nome ); | ||
430 | + $extensao = $lista [count ( $lista ) - 1]; | ||
431 | + if (($extensao != "dbf") && ($extensao != "shx") && ($extensao != "shp") && ($extensao != "prj")) { | ||
432 | + echo "Nome de arquivo inválido. $nome"; | ||
433 | + exit (); | ||
434 | + } | ||
435 | +} | ||
436 | +?> | ||
437 | +<script> | ||
438 | +function abreEditor (codigo){ | ||
439 | + window.parent.location.href = "../../catalogo/mapfile/opcoes/index.php?codigo=" + codigo + "&id_tema"; | ||
440 | +} | ||
441 | +</script> | ||
442 | +</body> | ||
443 | +</html> |
@@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
1 | +/* | ||
2 | +Licenca: | ||
3 | + | ||
4 | +GPL2 | ||
5 | + | ||
6 | +i3Geo Interface Integrada de Ferramentas de Geoprocessamento para Internet | ||
7 | + | ||
8 | +Direitos Autorais Reservados (c) 2006 Ministério do Meio Ambiente Brasil | ||
9 | +Desenvolvedor: Edmar Moretti edmar.moretti@gmail.com | ||
10 | + | ||
11 | +Este programa é software livre; você pode redistribuí-lo | ||
12 | +e/ou modificá-lo sob os termos da Licença Pública Geral | ||
13 | +GNU conforme publicada pela Free Software Foundation; | ||
14 | + | ||
15 | +Este programa é distribuído na expectativa de que seja útil, | ||
16 | +porém, SEM NENHUMA GARANTIA; nem mesmo a garantia implícita | ||
17 | +de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. | ||
18 | +Consulte a Licença Pública Geral do GNU para mais detalhes. | ||
19 | +Você deve ter recebido uma cópia da Licença Pública Geral do | ||
20 | +GNU junto com este programa; se não, escreva para a | ||
21 | +Free Software Foundation, Inc., no endereço | ||
22 | +59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | ||
23 | + | ||
24 | + */ | ||
25 | +i3GEOadmin.shp2pg = {}; | ||
0 | \ No newline at end of file | 26 | \ No newline at end of file |
@@ -0,0 +1,253 @@ | @@ -0,0 +1,253 @@ | ||
1 | +<?php | ||
2 | +define ( "ONDEI3GEO", "../../.." ); | ||
3 | +include ("exec.php"); | ||
4 | +include "../../head.php"; | ||
5 | +// monta o combo com a lista de pastas para armazenar os arquivos | ||
6 | +$comboEsquemas = '<select name="i3GEOuploadEsquemaDestino" class="form-control" required ><option value=""></option>'; | ||
7 | +foreach ( $_SESSION ["i3geoUploadDataWL"]["postgis"]["esquemas"] as $c ) { | ||
8 | + $comboEsquemas .= "<option value='$c'>$c</option>"; | ||
9 | +} | ||
10 | +$comboEsquemas .= "</select>"; | ||
11 | +// monta o combo com a lista de alias para conexao com o banco de dados | ||
12 | +$comboAliasConexao = '<select name="i3GEOuploadAliasConexao" class="form-control" ><option value=""></option>'; | ||
13 | +foreach ( array_keys($_SESSION ["postgis_mapa"]) as $c ) { | ||
14 | + $comboAliasConexao .= "<option value='$c'>$c</option>"; | ||
15 | +} | ||
16 | +$comboAliasConexao .= "</select>"; | ||
17 | +?> | ||
18 | +<div class="container-fluid migalha"> | ||
19 | + <div class="row"> | ||
20 | + <div class="btn-group btn-breadcrumb"> | ||
21 | + <a class="btn btn-default" href="../../../init/index.php"> | ||
22 | + <span>i3Geo</span> | ||
23 | + </a> | ||
24 | + <a class="btn btn-default" href="../../index.php"> | ||
25 | + <span>Admin</span> | ||
26 | + </a> | ||
27 | + <a class="btn btn-default" style="pointer-events: none"> | ||
28 | + <span>Upload</span> | ||
29 | + </a> | ||
30 | + <a class="btn btn-default" style="pointer-events: none"> | ||
31 | + <span>SHP->Postgis</span> | ||
32 | + </a> | ||
33 | + </div> | ||
34 | + </div> | ||
35 | +</div> | ||
36 | +<div class="container"> | ||
37 | + <div class="row center-block"> | ||
38 | + <div class="col-md-12"> | ||
39 | + <div class="well hidden" id="titulo"> | ||
40 | + <button data-toggle="modal" data-target="#ajudaPrincipal" class="btn btn-primary btn-fab btn-fab-mini pull-right"> | ||
41 | + <i class="material-icons">help</i> | ||
42 | + </button> | ||
43 | + <h2> | ||
44 | + <small>{{{txtTituloShp2Pg}}}</small> | ||
45 | + </h2> | ||
46 | + <blockquote>{{{txtDescShp2Pg}}}</blockquote> | ||
47 | + <!--Modal ajuda--> | ||
48 | + <div id="ajudaPrincipal" class="modal fade" tabindex="-1"> | ||
49 | + <div class="modal-dialog"> | ||
50 | + <div class="modal-content"> | ||
51 | + <div class="modal-body"> | ||
52 | + <p>{{{txtAjudaShp2Pg}}}</p> | ||
53 | + </div> | ||
54 | + </div> | ||
55 | + </div> | ||
56 | + </div> | ||
57 | + </div> | ||
58 | + | ||
59 | + <form style="" target="i3GEOuploadiframe" action="exec.php" method="post" ENCTYPE="multipart/form-data" onsubmit="javascript:$('#modalUpload').modal('show');" class="form-horizontal" role="form" | ||
60 | + method="post"> | ||
61 | + <div class="row center-block well hidden" id="corpo"> | ||
62 | + <div class="col-md-12"> | ||
63 | + <div class="form-group form-group-lg"> | ||
64 | + <label class="col-md-5 control-label">{{{txtArquivos}}}</label> | ||
65 | + <div class="col-md-7"> | ||
66 | + <div class="form-group form-group-lg col-md-12"> | ||
67 | + <div class="input-group-btn"> | ||
68 | + <button type="button" class="btn btn-primary pull-left" onclick="$(this).parent().find('input[type=file]').click();">SHP</button> | ||
69 | + <input name="i3GEOuploadshp" onchange="$(this).parent().parent().find('.form-control').html($(this).val().split(/[\\|/]/).pop());" style="display: none;" type="file"> | ||
70 | + <span class="form-control"></span> | ||
71 | + </div> | ||
72 | + </div> | ||
73 | + <div class="form-group form-group-lg col-md-12"> | ||
74 | + <div class="input-group-btn"> | ||
75 | + <button type="button" class="btn btn-primary pull-left" onclick="$(this).parent().find('input[type=file]').click();">SHX</button> | ||
76 | + <input name="i3GEOuploadshx" onchange="$(this).parent().parent().find('.form-control').html($(this).val().split(/[\\|/]/).pop());" style="display: none;" type="file"> | ||
77 | + <span class="form-control"></span> | ||
78 | + </div> | ||
79 | + </div> | ||
80 | + <div class="form-group form-group-lg col-md-12"> | ||
81 | + <div class="input-group-btn"> | ||
82 | + <button type="button" class="btn btn-primary pull-left" onclick="$(this).parent().find('input[type=file]').click();">DBF</button> | ||
83 | + <input name="i3GEOuploaddbf" onchange="$(this).parent().parent().find('.form-control').html($(this).val().split(/[\\|/]/).pop());" style="display: none;" type="file"> | ||
84 | + <span class="form-control"></span> | ||
85 | + </div> | ||
86 | + </div> | ||
87 | + </div> | ||
88 | + </div> | ||
89 | + </div> | ||
90 | + <div class="col-md-12"> | ||
91 | + <div class="form-group form-group-lg"> | ||
92 | + <label class="col-md-5 control-label" for="i3GEOuploadEsquemaDestino">{{{esquemaArmazenamento}}}</label> | ||
93 | + <div class="col-md-7"> | ||
94 | + <?php echo $comboEsquemas; ?> | ||
95 | + </div> | ||
96 | + </div> | ||
97 | + <div class="form-group form-group-lg"> | ||
98 | + <label class="col-md-5 control-label" for="i3GEOuploadNomeTabela">{{{nomeTabela}}}</label> | ||
99 | + <div class="col-md-7"> | ||
100 | + <input type="text" value="" class="form-control" name="i3GEOuploadNomeTabela" required> | ||
101 | + <div class="input-group-btn"> | ||
102 | + <a role="button" class="btn btn-danger btn-fab btn-fab-mini" style="height: 20px; min-width: 20px; width: 20px;" onclick="listaTabelasUpload('i3GEOuploadNomeTabela')" href="javascript:void(0)"> | ||
103 | + <i class="material-icons md-18">list</i> | ||
104 | + </a> | ||
105 | + </div> | ||
106 | + </div> | ||
107 | + </div> | ||
108 | + <div class="form-group form-group-lg"> | ||
109 | + <label class="col-md-5 control-label" for="i3GEOuploadSridOrigem">{{{sridOrigem}}}</label> | ||
110 | + <div class="col-md-7"> | ||
111 | + <input type="text" value="<?php echo $_SESSION["i3GeoProjDefault"]["epsg"]; ?>" class="form-control" name="i3GEOuploadSridOrigem" required> | ||
112 | + </div> | ||
113 | + </div> | ||
114 | + <div class="form-group form-group-lg"> | ||
115 | + <label class="col-md-5 control-label" for="i3GEOuploadSridDestino">{{{sridDestino}}}</label> | ||
116 | + <div class="col-md-7"> | ||
117 | + <input type="text" value="<?php echo $_SESSION["i3GeoProjDefault"]["epsg"]; ?>" class="form-control" name="i3GEOuploadSridDestino" required> | ||
118 | + </div> | ||
119 | + </div> | ||
120 | + <div class="form-group form-group-lg"> | ||
121 | + <label class="col-md-5 control-label" for="i3GEOuploadComentario">{{{comentarioTabela}}}</label> | ||
122 | + <div class="col-md-7"> | ||
123 | + <input type="text" value="" class="form-control" name="i3GEOuploadComentario"> | ||
124 | + </div> | ||
125 | + </div> | ||
126 | + <div class="form-group form-group-lg"> | ||
127 | + <label class="col-md-5 control-label" for="i3GEOuploadTipoOperacao">{{{tipoOperacao}}}</label> | ||
128 | + <div class="col-md-7"> | ||
129 | + <select title="{{{tipoOperacao}}}" name="i3GEOuploadTipoOperacao" class="form-control"> | ||
130 | + <option value="criar">{{{tabelaNova}}}</option> | ||
131 | + <option value="inserir">{{{tabelaInsert}}}</option> | ||
132 | + <option value="atualizar">{{{tabelaUpdate}}}</option> | ||
133 | + </select> | ||
134 | + </div> | ||
135 | + </div> | ||
136 | + <div class="form-group form-group-lg"> | ||
137 | + <label class="col-md-5 control-label" style="margin-top: 0px;" for="i3GEOuploadColunaGid">{{{colunaGid}}}</label> | ||
138 | + <div class="col-md-7"> | ||
139 | + <input type="text" value="" class="form-control" name="i3GEOuploadColunaGid" required > | ||
140 | + </div> | ||
141 | + </div> | ||
142 | + <div class="form-group form-group-lg"> | ||
143 | + <label class="col-md-5 control-label" for="i3GEOuploadAliasConexao">{{{comboAliasConexao}}}</label> | ||
144 | + <div class="col-md-7"> | ||
145 | + <?php echo $comboAliasConexao; ?> | ||
146 | + </div> | ||
147 | + </div> | ||
148 | + <div class="form-group form-group-lg"> | ||
149 | + <label class="col-md-5 control-label" style="margin-top: 0px;" for="i3GEOuploadApenasScript">{{{apenasScript}}}</label> | ||
150 | + <div class="col-md-7"> | ||
151 | + <div class=" checkbox"> | ||
152 | + <label> <input title="{{{apenasScript}}}" name="i3GEOuploadApenasScript" type="checkbox"> | ||
153 | + </label> | ||
154 | + </div> | ||
155 | + </div> | ||
156 | + </div> | ||
157 | + <div class="form-group form-group-lg"> | ||
158 | + <label class="col-md-5 control-label" style="margin-top: 0px;" for="i3GEOuploadCriaMapfile">{{{criaMapfile}}}</label> | ||
159 | + <div class="col-md-7"> | ||
160 | + <div class=" checkbox"> | ||
161 | + <label> <input title="{{{criaMapfile}}}" name="i3GEOuploadCriaMapfile" type="checkbox"> | ||
162 | + </label> | ||
163 | + </div> | ||
164 | + </div> | ||
165 | + </div> | ||
166 | + <div class="col-md-12"> | ||
167 | + <div class="pull-right"> | ||
168 | + <button type="submit" class="btn btn-primary" role="button" style="color: #008579;">{{envia}}</button> | ||
169 | + </div> | ||
170 | + </div> | ||
171 | + </div> | ||
172 | + </div> | ||
173 | + </form> | ||
174 | + </div> | ||
175 | + <div id="modalUpload" class="modal fade" tabindex="-1"> | ||
176 | + <div class="modal-dialog modal-lg"> | ||
177 | + <div class="modal-content"> | ||
178 | + <div class="modal-header"> | ||
179 | + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | ||
180 | + <span aria-hidden="true">×</span> | ||
181 | + </button> | ||
182 | + </div> | ||
183 | + <div class="modal-content"> | ||
184 | + <div class="modal-body modal-lg"> | ||
185 | + <iframe name=i3GEOuploadiframe style="text-align: left; border: 0px solid gray;" width="100%" height="500px"></iframe> | ||
186 | + </div> | ||
187 | + </div> | ||
188 | + </div> | ||
189 | + </div> | ||
190 | + </div> | ||
191 | + </div> | ||
192 | +</div> | ||
193 | +<script id="templateProj" type="x-tmpl-mustache"> | ||
194 | + <option value="{{{codigo}}}">{{{nome}}}</option> | ||
195 | +</script> | ||
196 | +<?php | ||
197 | +if (empty ( $_SESSION ["i3geoEsquemasWL"] )) { | ||
198 | + echo "<script>iniciaMenuPrincipal();i3GEOadmin.core.mostraErro('Nenhum esquema cadastrado para armazenar a tabela nas configurações do i3Geo (ms_configura)');</script>"; | ||
199 | + exit (); | ||
200 | +} | ||
201 | +?> | ||
202 | +<script type="text/javascript" src="index.js"></script> | ||
203 | +<script type="text/javascript" src="../../dicionario/uploadshp.js"></script> | ||
204 | +<script type="text/javascript" src="../../js/bdexplorer.js"></script> | ||
205 | +<script> | ||
206 | + $(document).ready(function(){ | ||
207 | + //vem de admin1/index.js | ||
208 | + iniciaMenuPrincipal(); | ||
209 | + $('ul.dropdown-menu [data-toggle=dropdown]').on('click', function(event) { | ||
210 | + event.preventDefault(); | ||
211 | + event.stopPropagation(); | ||
212 | + $(this).parent().siblings().removeClass('open'); | ||
213 | + $(this).parent().toggleClass('open'); | ||
214 | + }); | ||
215 | + //traducao | ||
216 | + var t = $("#titulo"); | ||
217 | + //complementa dicionario | ||
218 | + i3GEOadmin.shp2pg.dicionario = $.extend( | ||
219 | + {}, | ||
220 | + i3GEOadmin.uploadshp.dicionario, | ||
221 | + i3GEOadmin.core.dicionario | ||
222 | + ); | ||
223 | + | ||
224 | + i3GEOadmin.core.dicionario = null; | ||
225 | + | ||
226 | + i3GEOadmin.shp2pg.dicionario = i3GEO.idioma.objetoIdioma(i3GEOadmin.shp2pg.dicionario); | ||
227 | + | ||
228 | + t.html( | ||
229 | + Mustache.to_html( | ||
230 | + t.html(), | ||
231 | + i3GEOadmin.shp2pg.dicionario | ||
232 | + ) | ||
233 | + ); | ||
234 | + $.material.init(); | ||
235 | + i3GEOadmin.core.loginOn(); | ||
236 | + $(".hidden").removeClass('hidden'); | ||
237 | + var t = $("#corpo"); | ||
238 | + t.html( | ||
239 | + Mustache.to_html( | ||
240 | + t.html(), | ||
241 | + i3GEOadmin.shp2pg.dicionario | ||
242 | + ) | ||
243 | + ); | ||
244 | + }); | ||
245 | + function listaTabelasUpload(destino){ | ||
246 | + var esquema = $("form select[name='i3GEOuploadEsquemaDestino']").val(); | ||
247 | + if(esquema != ""){ | ||
248 | + i3GEOadmin.bdExplorer.listaTabelasUpload(esquema,destino); | ||
249 | + } | ||
250 | + } | ||
251 | +</script> | ||
252 | +</body> | ||
253 | +</html> | ||
0 | \ No newline at end of file | 254 | \ No newline at end of file |
classesphp/classe_bdexplorer.php
@@ -34,6 +34,8 @@ class Bdexplorer{ | @@ -34,6 +34,8 @@ class Bdexplorer{ | ||
34 | * Lista branca de esquemas permitidos | 34 | * Lista branca de esquemas permitidos |
35 | */ | 35 | */ |
36 | public $i3geoEsquemasWL; | 36 | public $i3geoEsquemasWL; |
37 | + | ||
38 | + public $i3geoEsquemasUpload; | ||
37 | /** | 39 | /** |
38 | * Construtor | 40 | * Construtor |
39 | * Faz o include de conexao.php que por sua vez faz o include de i3geo/ms_configura.php | 41 | * Faz o include de conexao.php que por sua vez faz o include de i3geo/ms_configura.php |
@@ -56,6 +58,11 @@ class Bdexplorer{ | @@ -56,6 +58,11 @@ class Bdexplorer{ | ||
56 | } else { | 58 | } else { |
57 | $this->i3geoEsquemasWL = $i3geoEsquemasWL; | 59 | $this->i3geoEsquemasWL = $i3geoEsquemasWL; |
58 | } | 60 | } |
61 | + if(!isset($i3geoUploadDataWL) || !is_array($i3geoUploadDataWL)){ | ||
62 | + $this->i3geoEsquemasUpload = array(); | ||
63 | + } else { | ||
64 | + $this->i3geoEsquemasUpload = $i3geoUploadDataWL["postgis"]["esquemas"]; | ||
65 | + } | ||
59 | //se a conexao nao vier como parametro, cria uma nova | 66 | //se a conexao nao vier como parametro, cria uma nova |
60 | if(is_array($dbh)){ | 67 | if(is_array($dbh)){ |
61 | $this->dbh = $this->conecta($dbh); | 68 | $this->dbh = $this->conecta($dbh); |
@@ -79,17 +86,23 @@ class Bdexplorer{ | @@ -79,17 +86,23 @@ class Bdexplorer{ | ||
79 | function listaDeEsquemas(){ | 86 | function listaDeEsquemas(){ |
80 | return $this->i3geoEsquemasWL; | 87 | return $this->i3geoEsquemasWL; |
81 | } | 88 | } |
82 | - function validaEsquemas($listaDeEsquemas){ | 89 | + function listaDeEsquemasUpload(){ |
90 | + return $this->i3geoEsquemasUpload; | ||
91 | + } | ||
92 | + function validaEsquemas($listaDeEsquemas,$lista = ""){ | ||
93 | + if($lista == ""){ | ||
94 | + $lista = $this->i3geoEsquemasWL; | ||
95 | + } | ||
83 | $novaLista = array(); | 96 | $novaLista = array(); |
84 | foreach($listaDeEsquemas as $e){ | 97 | foreach($listaDeEsquemas as $e){ |
85 | - if(in_array($e,$this->i3geoEsquemasWL)){ | 98 | + if(in_array($e,$lista)){ |
86 | $novaLista[] = $e; | 99 | $novaLista[] = $e; |
87 | } | 100 | } |
88 | } | 101 | } |
89 | return $novaLista; | 102 | return $novaLista; |
90 | } | 103 | } |
91 | - function validaEsquema($esquema){ | ||
92 | - $lista = $this->validaEsquemas(array($esquema)); | 104 | + function validaEsquema($esquema,$lista=""){ |
105 | + $lista = $this->validaEsquemas(array($esquema),$lista); | ||
93 | if(count($lista) == 0){ | 106 | if(count($lista) == 0){ |
94 | return false; | 107 | return false; |
95 | } else { | 108 | } else { |
@@ -107,6 +120,17 @@ class Bdexplorer{ | @@ -107,6 +120,17 @@ class Bdexplorer{ | ||
107 | } | 120 | } |
108 | return $tabelas; | 121 | return $tabelas; |
109 | } | 122 | } |
123 | + function listaDeTabelasUpload($esquema){ | ||
124 | + $tabelas = array(); | ||
125 | + if($this->validaEsquema($esquema,$this->i3geoEsquemasUpload) == true){ | ||
126 | + $sql = "SELECT table_name as tabela FROM information_schema.tables where table_schema = '$esquema' AND table_schema NOT LIKE 'i3geo%' AND table_schema NOT LIKE 'pg_%' AND table_schema NOT LIKE '%_schema%'"; | ||
127 | + $res = $this->execSQL($sql); | ||
128 | + foreach($res as $r){ | ||
129 | + $tabelas[] = $r["tabela"]; | ||
130 | + } | ||
131 | + } | ||
132 | + return $tabelas; | ||
133 | + } | ||
110 | function listaDeColunas($esquema,$tabela){ | 134 | function listaDeColunas($esquema,$tabela){ |
111 | $colunas = array(); | 135 | $colunas = array(); |
112 | if($this->validaEsquema($esquema) == true){ | 136 | if($this->validaEsquema($esquema) == true){ |
ms_configura.php
@@ -136,18 +136,31 @@ $i3geoEsquemasWL = array("publicy"); | @@ -136,18 +136,31 @@ $i3geoEsquemasWL = array("publicy"); | ||
136 | /* | 136 | /* |
137 | Variale: $i3geoUploadDataWL | 137 | Variale: $i3geoUploadDataWL |
138 | 138 | ||
139 | - Lista com as pastas (caminho completo) que podem ser utilizadas para o upload de arquivos shapefile. | 139 | + Lista com as pastas (caminho completo no sistema de arquivos) ou esquemas em bancos de dados Postgis, que podem ser utilizadas para o |
140 | + upload de arquivos shapefile. | ||
140 | O upload e uma funcao disponivel no sistema de administracao do i3Geo. | 141 | O upload e uma funcao disponivel no sistema de administracao do i3Geo. |
141 | - Para nao expor o endereco das pastas nos formularios, cada pasta recebe um nome. | 142 | + Para nao expor o endereco das pastas nos formularios, cada pasta recebe um apelido. |
143 | + | ||
144 | + No caso dos esquemas, o nome e o mesmo existente no banco. Alem dos esquemas e necessario fornecer os parametros de conexao | ||
145 | + com o banco de dados que permita a escrita nesses esquemas, pois a conversao de shapefile para Postgis exige a criação de tabela. | ||
146 | + Esses parametros podem ser diferentes de outros existentes aqui no ms_configura e nao interferem em outras operacoes | ||
142 | 147 | ||
143 | Exemplo: | 148 | Exemplo: |
144 | 149 | ||
145 | - $i3geoUploadDataWL = array( "Pasta 1"=>"/tmp/ms_tmp", "Pasta 2"=>"/var/www/data"); | 150 | + $i3geoUploadDataWL = array( |
151 | + "arquivos" => array( | ||
152 | + "Pasta 1"=>"/tmp/ms_tmp" | ||
153 | + ), | ||
154 | + "postgis" => array( | ||
155 | + "esquemas"=>array("esquema1","esquema2","publicy"), | ||
156 | + "conexao"=>array("user"=> "postgres", "password"=>"postgres", "dbname"=>"i3geosaude", "host"=>"localhost", "port"=>"5432") | ||
157 | + ) | ||
158 | + ); | ||
146 | 159 | ||
147 | Tipo: | 160 | Tipo: |
148 | {array} | 161 | {array} |
149 | */ | 162 | */ |
150 | -$i3geoUploadDataWL = array( "Pasta 1"=>"/tmp/ms_tmp", "Pasta 2"=>"/var/www/data"); | 163 | + $i3geoUploadDataWL = array(); |
151 | 164 | ||
152 | //TODO documentar moodle | 165 | //TODO documentar moodle |
153 | /* | 166 | /* |
@@ -256,7 +269,7 @@ buscarapida,conectarservicos,convertemapakml,cortina,editorsql,filtroarvore,geol | @@ -256,7 +269,7 @@ buscarapida,conectarservicos,convertemapakml,cortina,editorsql,filtroarvore,geol | ||
256 | inseretxt,mostraexten,outputformat,perfil,tipoimagem | 269 | inseretxt,mostraexten,outputformat,perfil,tipoimagem |
257 | 270 | ||
258 | */ | 271 | */ |
259 | -$i3geoBlFerramentas = array("saiku","ffff"); | 272 | +$i3geoBlFerramentas = array("saiku"); |
260 | /* | 273 | /* |
261 | Variable: $ogrOutput | 274 | Variable: $ogrOutput |
262 | 275 | ||
@@ -640,7 +653,7 @@ Tipo: | @@ -640,7 +653,7 @@ Tipo: | ||
640 | */ | 653 | */ |
641 | $utilizacgi = "nao"; | 654 | $utilizacgi = "nao"; |
642 | /* | 655 | /* |
643 | -Variable: expoeMapfile | 656 | +Variable: expoeMapfile (depreciado) |
644 | 657 | ||
645 | Essa variável controla se o nome do mapfile atual será ou não retornado para a aplicação via ajax. | 658 | Essa variável controla se o nome do mapfile atual será ou não retornado para a aplicação via ajax. |
646 | 659 | ||
@@ -653,22 +666,21 @@ $expoeMapfile = "sim"; | @@ -653,22 +666,21 @@ $expoeMapfile = "sim"; | ||
653 | /* | 666 | /* |
654 | Variable: conexaoadmin | 667 | Variable: conexaoadmin |
655 | 668 | ||
656 | -Arquivo PHP que define a string de conexão (PDO) com o banco de dados administrativo. | 669 | +Arquivo PHP que define a string de conexao (PDO) com o banco de dados administrativo. |
657 | 670 | ||
658 | -Esse arquivo é incluído no programa i3geo/admin/conexao.php | 671 | +Esse arquivo e incluido no programa i3geo/admin/conexao.php |
659 | 672 | ||
660 | -O banco de dados administrativo é utilizado para definir coisas como a árvore de temas, árvore de mapas, etc. | 673 | +O banco de dados administrativo e utilizado para definir coisas como a arvore de temas, arvore de mapas, etc. |
661 | 674 | ||
662 | -O banco de dados, originalmente, é montado em SQLITE, porém, em ambientes corporativos, sugere-se o uso de bancos de dados mais robustos. | 675 | +O banco de dados, originalmente, e montado em SQLITE, porem, em ambientes corporativos, sugere-se o uso de bancos de dados mais robustos. |
663 | 676 | ||
664 | -Se você quiser utilizar a conexão default, baseado no SQLITE, mantenha essa variável vazia. | 677 | +Se voce quiser utilizar a conexao default, baseado no SQLITE, mantenha essa variavel vazia. |
665 | 678 | ||
666 | -O programa PHP que estabelece a conexão deve retornar objetos com nomes padronizados. Veja o arquivo i3geo/admin/conexao.php e i3geo/admin/php/conexaopostgresql.php para maiores detalhes. | 679 | +O programa PHP que estabelece a conexao deve retornar objetos com nomes padronizados. Veja o arquivo i3geo/admin/conexao.php e i3geo/admin/php/conexaopostgresql.php para maiores detalhes. |
667 | 680 | ||
668 | Exemplos: | 681 | Exemplos: |
669 | 682 | ||
670 | $conexaoadmin = $locaplic."/admin/php/conexaopostgresql.php"; | 683 | $conexaoadmin = $locaplic."/admin/php/conexaopostgresql.php"; |
671 | -$conexaoadmin = $locaplic."/admin/php/conexaomma.php"; | ||
672 | 684 | ||
673 | Tipo: | 685 | Tipo: |
674 | {string} | 686 | {string} |
@@ -678,7 +690,7 @@ $conexaoadmin = ""; | @@ -678,7 +690,7 @@ $conexaoadmin = ""; | ||
678 | /* | 690 | /* |
679 | Variable: $esquemaadmin | 691 | Variable: $esquemaadmin |
680 | 692 | ||
681 | -Indica em qual esquema do banco de dados de administração estão armazenadas as tabelas do sistema de administração. Por default, utiliza-se o esquema public. | 693 | +Indica em qual esquema do banco de dados de administracao estao armazenadas as tabelas do sistema de administracao. Por default, utiliza-se o esquema public. |
682 | 694 | ||
683 | Tipo: | 695 | Tipo: |
684 | {string} | 696 | {string} |
temas/bacia_ipojuca.map
@@ -1,79 +0,0 @@ | @@ -1,79 +0,0 @@ | ||
1 | -MAP | ||
2 | - FONTSET "../symbols/fontes.txt" | ||
3 | - IMAGETYPE "png" | ||
4 | - NAME "MS" | ||
5 | - SIZE -1 -1 | ||
6 | - STATUS ON | ||
7 | - SYMBOLSET "../symbols/simbolosv6.sym" | ||
8 | - UNITS METERS | ||
9 | - | ||
10 | - OUTPUTFORMAT | ||
11 | - NAME "png" | ||
12 | - MIMETYPE "image/png" | ||
13 | - DRIVER "AGG/PNG" | ||
14 | - EXTENSION "png" | ||
15 | - IMAGEMODE RGB | ||
16 | - TRANSPARENT FALSE | ||
17 | - END # OUTPUTFORMAT | ||
18 | - | ||
19 | - LEGEND | ||
20 | - KEYSIZE 20 10 | ||
21 | - KEYSPACING 5 5 | ||
22 | - LABEL | ||
23 | - SIZE MEDIUM | ||
24 | - OFFSET 0 0 | ||
25 | - SHADOWSIZE 1 1 | ||
26 | - TYPE BITMAP | ||
27 | - END # LABEL | ||
28 | - STATUS OFF | ||
29 | - END # LEGEND | ||
30 | - | ||
31 | - QUERYMAP | ||
32 | - SIZE -1 -1 | ||
33 | - STATUS OFF | ||
34 | - STYLE HILITE | ||
35 | - END # QUERYMAP | ||
36 | - | ||
37 | - SCALEBAR | ||
38 | - INTERVALS 4 | ||
39 | - LABEL | ||
40 | - SIZE MEDIUM | ||
41 | - OFFSET 0 0 | ||
42 | - SHADOWSIZE 1 1 | ||
43 | - TYPE BITMAP | ||
44 | - END # LABEL | ||
45 | - SIZE 200 3 | ||
46 | - STATUS OFF | ||
47 | - UNITS MILES | ||
48 | - END # SCALEBAR | ||
49 | - | ||
50 | - WEB | ||
51 | - END # WEB | ||
52 | - | ||
53 | - LAYER | ||
54 | - CONNECTION "" | ||
55 | - DATA "/tmp/ms_tmp/bacia_ipojuca.shp" | ||
56 | - METADATA | ||
57 | - "CLASSE" "SIM" | ||
58 | - "permitekmz" "SIM" | ||
59 | - "permitedownload" "SIM" | ||
60 | - "permitekml" "SIM" | ||
61 | - "permiteogc" "SIM" | ||
62 | - "TEMA" "bacia_ipojuca" | ||
63 | - END # METADATA | ||
64 | - NAME "bacia_ipojuca" | ||
65 | - STATUS DEFAULT | ||
66 | - TEMPLATE "none.htm" | ||
67 | - TILEITEM "location" | ||
68 | - TYPE POLYGON | ||
69 | - UNITS METERS | ||
70 | - CLASS | ||
71 | - NAME "" | ||
72 | - STYLE | ||
73 | - COLOR 0 0 0 | ||
74 | - SIZE 12 | ||
75 | - END # STYLE | ||
76 | - END # CLASS | ||
77 | - END # LAYER | ||
78 | - | ||
79 | -END # MAP |