Commit 0827b8bc63e9d77494f75228c6c12ee265bdf46c

Authored by Edmar Moretti
1 parent 10577a26

Refatoração do código para separação de funções em arquivos de include

admin/admin.db
No preview for this file type
admin1/cadastros/identifica/index.php
@@ -80,12 +80,13 @@ include("../../templates/templateOpcoesPublicado.php"); @@ -80,12 +80,13 @@ include("../../templates/templateOpcoesPublicado.php");
80 ) 80 )
81 ); 81 );
82 $.material.init(); 82 $.material.init();
83 - var inicia = function() { 83 + if(i3GEO.login.verificaCookieLogin() == true){
84 i3GEOadmin.core.loginOn(); 84 i3GEOadmin.core.loginOn();
85 $(".hidden").removeClass('hidden'); 85 $(".hidden").removeClass('hidden');
86 i3GEOadmin.identifica.init($("#corpo")); 86 i3GEOadmin.identifica.init($("#corpo"));
87 - };  
88 - i3GEO.login.verificaOperacao("admin/html/identifica",i3GEO.configura.locaplic, inicia, "sessao" ,i3GEOadmin.core.erroLogin); 87 + } else {
  88 + i3GEOadmin.core.erroLogin();
  89 + }
89 }); 90 });
90 </script> 91 </script>
91 </body> 92 </body>
admin1/catalogo/mapfile/editor/exec.php
1 <?php 1 <?php
2 -include_once (dirname ( __FILE__ ) . "/../../../../admin/php/login.php");  
3 -include_once (dirname ( __FILE__ ) . "/../../../../admin/php/conexao.php");  
4 -error_reporting ( 0 );  
5 -if (isset ( $_POST ["texto"] )) {  
6 - $gravarTexto = $_POST ["texto"];  
7 - $_POST ["texto"] = "";  
8 -}  
9 -$versao = versao ();  
10 -$versao = $versao ["principal"];  
11 2
12 -if (verificaOperacaoSessao ( "admin/html/editortexto" ) === false) {  
13 - header ( "HTTP/1.1 403 Vc nao pode realizar essa operacao" );  
14 - exit ();  
15 -}  
16 -  
17 -error_reporting ( 0 );  
18 -function textoMapfile($codigo) {  
19 - global $locaplic, $dbhw;  
20 - $mapfile = $locaplic . "/temas/" . $codigo . ".map";  
21 - if (! file_exists ( $mapfile )) {  
22 - return "Arquivo $codigo n&atilde;o existe.";  
23 - }  
24 - // testa  
25 - try {  
26 - ms_newMapObj ( $mapfile );  
27 - } catch ( Exception $e ) {  
28 - $texto = file_get_contents ( $mapfile );  
29 - if (mb_detect_encoding ( $texto, 'UTF-8, ISO-8859-1' ) == "ISO-8859-1") {  
30 - return utf8_encode ( $texto );  
31 - } else {  
32 - return $texto;  
33 - }  
34 - }  
35 - if (@ms_newMapObj ( $mapfile )) {  
36 - // verifica os metadata que sao armazenados tambem no banco de dados de administracao  
37 - // isso e necessario para manter a consistencia caso o usuario altere manualmente os valores  
38 - // cria o objeto map  
39 - $mapa = ms_newMapObj ( $mapfile );  
40 - $layer = $mapa->getlayerbyname ( $codigo );  
41 - if ($layer == "") {  
42 - return "<br><span style='color:red;'>Aten&ccedil;&atilde;o: n&atilde;o existe nenhum LAYER com NAME igual a " . $codigo . "</span><br>";  
43 - } else {  
44 - // pega o metadata  
45 - $meta = $layer->getmetadata ( "permitedownload" );  
46 - $meta = strtoupper ( $meta );  
47 - if ($meta != "" && ($meta == "SIM" || $meta == "NAO")) {  
48 - // grava no banco  
49 - $dbhw->query ( "UPDATE " . $esquemaadmin . "i3geoadmin_temas SET download_tema='$meta' WHERE codigo_tema = '$codigo'" );  
50 - }  
51 - $meta = $layer->getmetadata ( "permiteogc" );  
52 - $meta = strtoupper ( $meta );  
53 - if ($meta != "" && ($meta == "SIM" || $meta == "NAO")) {  
54 - $dbhw->query ( "UPDATE " . $esquemaadmin . "i3geoadmin_temas SET ogc_tema='$meta' WHERE codigo_tema = '$codigo'" );  
55 - }  
56 - $meta = $layer->getmetadata ( "permitekml" );  
57 - $meta = strtoupper ( $meta );  
58 - if ($meta != "" && ($meta == "SIM" || $meta == "NAO")) {  
59 - $dbhw->query ( "UPDATE " . $esquemaadmin . "i3geoadmin_temas SET kml_tema='$meta' WHERE codigo_tema = '$codigo'" );  
60 - }  
61 - $meta = $layer->getmetadata ( "permitekmz" );  
62 - $meta = strtoupper ( $meta );  
63 - if ($meta != "" && ($meta == "SIM" || $meta == "NAO")) {  
64 - $dbhw->query ( "UPDATE " . $esquemaadmin . "i3geoadmin_temas SET kmz_tema='$meta' WHERE codigo_tema = '$codigo'" );  
65 - }  
66 - }  
67 - }  
68 - $texto = file_get_contents ( $mapfile );  
69 - if (mb_detect_encoding ( $texto, 'UTF-8, ISO-8859-1' ) == "ISO-8859-1") {  
70 - return utf8_encode ( $texto );  
71 - } else {  
72 - return $texto;  
73 - }  
74 -}  
75 -function salvaMapfile() {  
76 - global $locaplic, $dbhw, $codigo, $gravarTexto, $esquemaadmin;  
77 - if (empty ( $gravarTexto )) {  
78 - return;  
79 - }  
80 - $mapfile = $locaplic . "/temas/" . $codigo . ".map";  
81 - $original = file_get_contents ( $mapfile );  
82 - $fp = fopen ( $mapfile, "w" );  
83 - if ($fp == false) {  
84 - echo "<span style=color:red <b>N&atilde;o foi poss&iacute;vel salvar o arquivo. Verifique as permiss&otilde;es ou se h&aacute; algum erro no mapfile</b></span><br><br>";  
85 - exit ();  
86 - } else {  
87 - // remove itens vazios  
88 - $novoTexto = array ();  
89 - $testar = array (  
90 - "TEMPORIZADOR",  
91 - "PALLETESTEP",  
92 - "LTEMPOITEMIMAGEM",  
93 - "METAESTAT_ID_MEDIDA_VARIAVEL",  
94 - "GMOPACITY",  
95 - "GMSTATUS",  
96 - "ICONETEMA",  
97 - "LTEMPOITEMTITULO",  
98 - "DESCRIPTION_TEMPLATE",  
99 - "LTEMPOITEMLINK",  
100 - "TILES",  
101 - "METAESTAT_CODIGO_TIPO_REGIAO",  
102 - "ARQUIVOTEMAORIGINAL",  
103 - "PALLETEFILE",  
104 - "NOMEORIGINAL",  
105 - "OLSTATUS",  
106 - "PERMITEDOWNLOAD",  
107 - "LTEMPOFORMATODATA",  
108 - "FILTROORIGINAL",  
109 - "PERMITECOMENTARIO",  
110 - "LTEMPOITEMICONE",  
111 - "DATAORIGINAL",  
112 - "PLUGINI3GEO",  
113 - "METAESTAT",  
114 - "ITEMBUSCARAPIDA",  
115 - "ARQUIVODOWNLOAD",  
116 - "ARQUIVOKMZ",  
117 - "PERMITEKML",  
118 - "PERMITEOGC",  
119 - "CONVCARACTER",  
120 - "CORTEPIXELS",  
121 - "EDITORSQL",  
122 - "LTEMPOCONVENCODE",  
123 - "LTEMPOITEMFIM",  
124 - "OLOPACITY",  
125 - "LEGENDAWMS",  
126 - "LEGENDAIMG",  
127 - "KEYIMAGE",  
128 - "TILEINDEX",  
129 - "TILEITEM",  
130 - "SYMBOL",  
131 - "LABELITEM",  
132 - "FILTERITEM",  
133 - "GROUP",  
134 - "ENCODING",  
135 - "TIP",  
136 - "CLASSE",  
137 - "ITENSDESC",  
138 - "CLASSESNOME",  
139 - "ITENSLINK",  
140 - "ESCALA",  
141 - "CLASSESSIMBOLO",  
142 - "MENSAGEM",  
143 - "EXTENSAO",  
144 - "CLASSESITEM",  
145 - "ESCONDIDO",  
146 - "CLASSESCOR",  
147 - "DOWNLOAD",  
148 - "CLASSESTAMANHO",  
149 - "ITENS",  
150 - "TEMA",  
151 - "APLICAEXTENSAO",  
152 - "IDENTIFICA",  
153 - "TRANSITIONEFFECT"  
154 - );  
155 - foreach ( preg_split ( '~[\r\n]+~', $gravarTexto ) as $line ) {  
156 - $teste = strtoupper ( $line );  
157 - $teste = trim ( $teste );  
158 - $teste = str_replace ( array (  
159 - " ",  
160 - "'",  
161 - '"'  
162 - ), "", $teste );  
163 - $teste = preg_replace ( '/[\n\r\t ]*/', '', $teste );  
164 - $passou = true;  
165 - foreach ( $testar as $t ) {  
166 - if ($teste == $t) {  
167 - $passou = false;  
168 - }  
169 - }  
170 - if ($passou == true) {  
171 - if (mb_detect_encoding ( $line, 'UTF-8' ) == "UTF-8") {  
172 - $line = mb_convert_encoding ( $line, "ISO-8859-1", "UTF-8" );  
173 - }  
174 - $novoTexto [] = $line;  
175 - }  
176 - }  
177 - fwrite ( $fp, implode ( "\r\n", $novoTexto ) );  
178 - }  
179 - fclose ( $fp );  
180 - // testa o mapfile  
181 - ms_ResetErrorList ();  
182 - if (! @ms_newMapObj ( $mapfile )) {  
183 - echo "Erro no arquivo sera mantido o original<br>";  
184 - $error = ms_GetErrorObj ();  
185 - while ( $error && $error->code != MS_NOERR ) {  
186 - printf ( "<br>Error in %s: %s<br>\n", $error->routine, $error->message );  
187 - $error = $error->next ();  
188 - }  
189 - $fp = fopen ( $mapfile, "w" );  
190 - fwrite ( $fp, $original );  
191 - fclose ( $fp );  
192 - exit ();  
193 - }  
194 -  
195 - // verifica os metadata que sao armazenados tambem no banco de dados de administracao  
196 - // isso e necessario para manter a consistencia caso o usuario altere manualmente os valores  
197 -  
198 - // cria o objeto map  
199 - $mapa = ms_newMapObj ( $mapfile );  
200 -  
201 - $layer = $mapa->getlayerbyname ( $codigo );  
202 - if ($layer == "") {  
203 - return "<br><span style='color:red;'>Atenção: não existe nenhum LAYER com NAME igual a " . $codigo . "</span><br>";  
204 - } else {  
205 - // pega o metadata  
206 - $meta = $layer->getmetadata ( "permitedownload" );  
207 - $meta = strtoupper ( $meta );  
208 - $dataCol = array();  
209 - if ($meta != "" && ($meta == "SIM" || $meta == "NAO")) {  
210 - $dataCol["download_tema"] = $meta;  
211 - }  
212 - $meta = $layer->getmetadata ( "permiteogc" );  
213 - $meta = strtoupper ( $meta );  
214 - if ($meta != "" && ($meta == "SIM" || $meta == "NAO")) {  
215 - $dataCol["ogc_tema"] = $meta;  
216 - }  
217 - $meta = $layer->getmetadata ( "permitekml" );  
218 - $meta = strtoupper ( $meta );  
219 - if ($meta != "" && ($meta == "SIM" || $meta == "NAO")) {  
220 - $dataCol["kml_tema"] = $meta;  
221 - }  
222 - $meta = $layer->getmetadata ( "permitekmz" );  
223 - $meta = strtoupper ( $meta );  
224 - if ($meta != "" && ($meta == "SIM" || $meta == "NAO")) {  
225 - $dataCol["kmz_tema"] = $meta;  
226 - }  
227 - $resultado = i3GeoAdminUpdate ( $dbhw, "i3geoadmin_temas", $dataCol, "WHERE codigo_tema = '$codigo'" );  
228 - }  
229 -}  
230 ?> 3 ?>
231 \ No newline at end of file 4 \ No newline at end of file
admin1/catalogo/mapfile/editor/funcoes.php 0 → 100644
@@ -0,0 +1,215 @@ @@ -0,0 +1,215 @@
  1 +<?php
  2 +namespace admin\catalogo\mapfile\editor;
  3 +function textoMapfile($codigo) {
  4 + global $locaplic, $dbhw;
  5 + $mapfile = $locaplic . "/temas/" . $codigo . ".map";
  6 + if (! file_exists ( $mapfile )) {
  7 + return "Arquivo $codigo n&atilde;o existe.";
  8 + }
  9 + // testa
  10 + try {
  11 + ms_newMapObj ( $mapfile );
  12 + } catch ( Exception $e ) {
  13 + $texto = file_get_contents ( $mapfile );
  14 + if (mb_detect_encoding ( $texto, 'UTF-8, ISO-8859-1' ) == "ISO-8859-1") {
  15 + return utf8_encode ( $texto );
  16 + } else {
  17 + return $texto;
  18 + }
  19 + }
  20 + if (@ms_newMapObj ( $mapfile )) {
  21 + // verifica os metadata que sao armazenados tambem no banco de dados de administracao
  22 + // isso e necessario para manter a consistencia caso o usuario altere manualmente os valores
  23 + // cria o objeto map
  24 + $mapa = ms_newMapObj ( $mapfile );
  25 + $layer = $mapa->getlayerbyname ( $codigo );
  26 + if ($layer == "") {
  27 + return "<br><span style='color:red;'>Aten&ccedil;&atilde;o: n&atilde;o existe nenhum LAYER com NAME igual a " . $codigo . "</span><br>";
  28 + } else {
  29 + // pega o metadata
  30 + $meta = $layer->getmetadata ( "permitedownload" );
  31 + $meta = strtoupper ( $meta );
  32 + if ($meta != "" && ($meta == "SIM" || $meta == "NAO")) {
  33 + // grava no banco
  34 + $dbhw->query ( "UPDATE " . $esquemaadmin . "i3geoadmin_temas SET download_tema='$meta' WHERE codigo_tema = '$codigo'" );
  35 + }
  36 + $meta = $layer->getmetadata ( "permiteogc" );
  37 + $meta = strtoupper ( $meta );
  38 + if ($meta != "" && ($meta == "SIM" || $meta == "NAO")) {
  39 + $dbhw->query ( "UPDATE " . $esquemaadmin . "i3geoadmin_temas SET ogc_tema='$meta' WHERE codigo_tema = '$codigo'" );
  40 + }
  41 + $meta = $layer->getmetadata ( "permitekml" );
  42 + $meta = strtoupper ( $meta );
  43 + if ($meta != "" && ($meta == "SIM" || $meta == "NAO")) {
  44 + $dbhw->query ( "UPDATE " . $esquemaadmin . "i3geoadmin_temas SET kml_tema='$meta' WHERE codigo_tema = '$codigo'" );
  45 + }
  46 + $meta = $layer->getmetadata ( "permitekmz" );
  47 + $meta = strtoupper ( $meta );
  48 + if ($meta != "" && ($meta == "SIM" || $meta == "NAO")) {
  49 + $dbhw->query ( "UPDATE " . $esquemaadmin . "i3geoadmin_temas SET kmz_tema='$meta' WHERE codigo_tema = '$codigo'" );
  50 + }
  51 + }
  52 + }
  53 + $texto = file_get_contents ( $mapfile );
  54 + if (mb_detect_encoding ( $texto, 'UTF-8, ISO-8859-1' ) == "ISO-8859-1") {
  55 + return utf8_encode ( $texto );
  56 + } else {
  57 + return $texto;
  58 + }
  59 +}
  60 +function salvaMapfile() {
  61 + global $locaplic, $dbhw, $codigo, $gravarTexto, $esquemaadmin;
  62 + if (empty ( $gravarTexto )) {
  63 + return;
  64 + }
  65 + $mapfile = $locaplic . "/temas/" . $codigo . ".map";
  66 + $original = file_get_contents ( $mapfile );
  67 + $fp = fopen ( $mapfile, "w" );
  68 + if ($fp == false) {
  69 + echo "<span style=color:red <b>N&atilde;o foi poss&iacute;vel salvar o arquivo. Verifique as permiss&otilde;es ou se h&aacute; algum erro no mapfile</b></span><br><br>";
  70 + exit ();
  71 + } else {
  72 + // remove itens vazios
  73 + $novoTexto = array ();
  74 + $testar = array (
  75 + "TEMPORIZADOR",
  76 + "PALLETESTEP",
  77 + "LTEMPOITEMIMAGEM",
  78 + "METAESTAT_ID_MEDIDA_VARIAVEL",
  79 + "GMOPACITY",
  80 + "GMSTATUS",
  81 + "ICONETEMA",
  82 + "LTEMPOITEMTITULO",
  83 + "DESCRIPTION_TEMPLATE",
  84 + "LTEMPOITEMLINK",
  85 + "TILES",
  86 + "METAESTAT_CODIGO_TIPO_REGIAO",
  87 + "ARQUIVOTEMAORIGINAL",
  88 + "PALLETEFILE",
  89 + "NOMEORIGINAL",
  90 + "OLSTATUS",
  91 + "PERMITEDOWNLOAD",
  92 + "LTEMPOFORMATODATA",
  93 + "FILTROORIGINAL",
  94 + "PERMITECOMENTARIO",
  95 + "LTEMPOITEMICONE",
  96 + "DATAORIGINAL",
  97 + "PLUGINI3GEO",
  98 + "METAESTAT",
  99 + "ITEMBUSCARAPIDA",
  100 + "ARQUIVODOWNLOAD",
  101 + "ARQUIVOKMZ",
  102 + "PERMITEKML",
  103 + "PERMITEOGC",
  104 + "CONVCARACTER",
  105 + "CORTEPIXELS",
  106 + "EDITORSQL",
  107 + "LTEMPOCONVENCODE",
  108 + "LTEMPOITEMFIM",
  109 + "OLOPACITY",
  110 + "LEGENDAWMS",
  111 + "LEGENDAIMG",
  112 + "KEYIMAGE",
  113 + "TILEINDEX",
  114 + "TILEITEM",
  115 + "SYMBOL",
  116 + "LABELITEM",
  117 + "FILTERITEM",
  118 + "GROUP",
  119 + "ENCODING",
  120 + "TIP",
  121 + "CLASSE",
  122 + "ITENSDESC",
  123 + "CLASSESNOME",
  124 + "ITENSLINK",
  125 + "ESCALA",
  126 + "CLASSESSIMBOLO",
  127 + "MENSAGEM",
  128 + "EXTENSAO",
  129 + "CLASSESITEM",
  130 + "ESCONDIDO",
  131 + "CLASSESCOR",
  132 + "DOWNLOAD",
  133 + "CLASSESTAMANHO",
  134 + "ITENS",
  135 + "TEMA",
  136 + "APLICAEXTENSAO",
  137 + "IDENTIFICA",
  138 + "TRANSITIONEFFECT"
  139 + );
  140 + foreach ( preg_split ( '~[\r\n]+~', $gravarTexto ) as $line ) {
  141 + $teste = strtoupper ( $line );
  142 + $teste = trim ( $teste );
  143 + $teste = str_replace ( array (
  144 + " ",
  145 + "'",
  146 + '"'
  147 + ), "", $teste );
  148 + $teste = preg_replace ( '/[\n\r\t ]*/', '', $teste );
  149 + $passou = true;
  150 + foreach ( $testar as $t ) {
  151 + if ($teste == $t) {
  152 + $passou = false;
  153 + }
  154 + }
  155 + if ($passou == true) {
  156 + if (mb_detect_encoding ( $line, 'UTF-8' ) == "UTF-8") {
  157 + $line = mb_convert_encoding ( $line, "ISO-8859-1", "UTF-8" );
  158 + }
  159 + $novoTexto [] = $line;
  160 + }
  161 + }
  162 + fwrite ( $fp, implode ( "\r\n", $novoTexto ) );
  163 + }
  164 + fclose ( $fp );
  165 + // testa o mapfile
  166 + ms_ResetErrorList ();
  167 + if (! @ms_newMapObj ( $mapfile )) {
  168 + echo "Erro no arquivo sera mantido o original<br>";
  169 + $error = ms_GetErrorObj ();
  170 + while ( $error && $error->code != MS_NOERR ) {
  171 + printf ( "<br>Error in %s: %s<br>\n", $error->routine, $error->message );
  172 + $error = $error->next ();
  173 + }
  174 + $fp = fopen ( $mapfile, "w" );
  175 + fwrite ( $fp, $original );
  176 + fclose ( $fp );
  177 + exit ();
  178 + }
  179 +
  180 + // verifica os metadata que sao armazenados tambem no banco de dados de administracao
  181 + // isso e necessario para manter a consistencia caso o usuario altere manualmente os valores
  182 +
  183 + // cria o objeto map
  184 + $mapa = ms_newMapObj ( $mapfile );
  185 +
  186 + $layer = $mapa->getlayerbyname ( $codigo );
  187 + if ($layer == "") {
  188 + return "<br><span style='color:red;'>Atenção: não existe nenhum LAYER com NAME igual a " . $codigo . "</span><br>";
  189 + } else {
  190 + // pega o metadata
  191 + $meta = $layer->getmetadata ( "permitedownload" );
  192 + $meta = strtoupper ( $meta );
  193 + $dataCol = array();
  194 + if ($meta != "" && ($meta == "SIM" || $meta == "NAO")) {
  195 + $dataCol["download_tema"] = $meta;
  196 + }
  197 + $meta = $layer->getmetadata ( "permiteogc" );
  198 + $meta = strtoupper ( $meta );
  199 + if ($meta != "" && ($meta == "SIM" || $meta == "NAO")) {
  200 + $dataCol["ogc_tema"] = $meta;
  201 + }
  202 + $meta = $layer->getmetadata ( "permitekml" );
  203 + $meta = strtoupper ( $meta );
  204 + if ($meta != "" && ($meta == "SIM" || $meta == "NAO")) {
  205 + $dataCol["kml_tema"] = $meta;
  206 + }
  207 + $meta = $layer->getmetadata ( "permitekmz" );
  208 + $meta = strtoupper ( $meta );
  209 + if ($meta != "" && ($meta == "SIM" || $meta == "NAO")) {
  210 + $dataCol["kmz_tema"] = $meta;
  211 + }
  212 + $resultado = i3GeoAdminUpdate ( $dbhw, "i3geoadmin_temas", $dataCol, "WHERE codigo_tema = '$codigo'" );
  213 + }
  214 +}
  215 +?>
0 \ No newline at end of file 216 \ No newline at end of file
admin1/catalogo/mapfile/editor/index.php
@@ -8,9 +8,24 @@ error_reporting ( 0 ); @@ -8,9 +8,24 @@ error_reporting ( 0 );
8 include "../../../head.php"; 8 include "../../../head.php";
9 $codigo = filter_var ( $_GET ["codigo"], FILTER_SANITIZE_STRING ); 9 $codigo = filter_var ( $_GET ["codigo"], FILTER_SANITIZE_STRING );
10 $id_tema = ( int ) $_GET ["id_tema"]; 10 $id_tema = ( int ) $_GET ["id_tema"];
11 -include ("exec.php");  
12 -salvaMapfile ();  
13 -$textoMapfile = textoMapfile ( $codigo ); 11 +include_once (dirname ( __FILE__ ) . "/../../../../admin/php/login.php");
  12 +include_once (dirname ( __FILE__ ) . "/../../../../admin/php/conexao.php");
  13 +error_reporting ( 0 );
  14 +if (isset ( $_POST ["texto"] )) {
  15 + $gravarTexto = $_POST ["texto"];
  16 + $_POST ["texto"] = "";
  17 +}
  18 +$versao = versao ();
  19 +$versao = $versao ["principal"];
  20 +
  21 +if (verificaOperacaoSessao ( "admin/html/editortexto" ) === false) {
  22 + header ( "HTTP/1.1 403 Vc nao pode realizar essa operacao" );
  23 + exit ();
  24 +}
  25 +error_reporting ( 0 );
  26 +include("funcoes.php");
  27 +\admin\catalogo\mapfile\editor\salvaMapfile ();
  28 +$textoMapfile = \admin\catalogo\mapfile\editor\textoMapfile ( $codigo );
14 ?> 29 ?>
15 <div class="container-fluid migalha"> 30 <div class="container-fluid migalha">
16 <div class="row"> 31 <div class="row">
admin1/catalogo/mapfile/exec.php
@@ -34,65 +34,45 @@ if (verificaOperacaoSessao ( &quot;admin/html/editormapfile&quot; ) === false) { @@ -34,65 +34,45 @@ if (verificaOperacaoSessao ( &quot;admin/html/editormapfile&quot; ) === false) {
34 } 34 }
35 35
36 include (dirname ( __FILE__ ) . "/../../../admin/php/conexao.php"); 36 include (dirname ( __FILE__ ) . "/../../../admin/php/conexao.php");
37 - 37 +include ("funcoes.php");
38 $codigo = $_POST ["codigo"]; 38 $codigo = $_POST ["codigo"];
  39 +$codigo = str_replace ( " ", "", removeAcentos ( $codigo ) );
  40 +$codigo = str_replace ( ".", "", $codigo );
  41 +$codigo = strip_tags ( $codigo );
  42 +$codigo = htmlspecialchars ( $codigo, ENT_QUOTES );
39 43
40 $funcao = strtoupper ( $funcao ); 44 $funcao = strtoupper ( $funcao );
41 switch ($funcao) { 45 switch ($funcao) {
42 case "ADICIONAR" : 46 case "ADICIONAR" :
43 - $codigo = str_replace ( " ", "", removeAcentos ( $codigo ) );  
44 - $codigo = str_replace ( ".", "", $codigo );  
45 - $codigo = strip_tags ( $codigo );  
46 - $codigo = htmlspecialchars ( $codigo, ENT_QUOTES );  
47 - $arq = $locaplic . "/temas/" . $codigo . ".map";  
48 - if ($codigo == "" || file_exists ( $arq )) {  
49 - header ( "HTTP/1.1 400 arquivo ja existe" );  
50 - exit ();  
51 - }  
52 if(empty($_POST["titulolegenda"])){ 47 if(empty($_POST["titulolegenda"])){
53 $_POST["titulolegenda"] = $_POST ["nome_tema"]; 48 $_POST["titulolegenda"] = $_POST ["nome_tema"];
54 } 49 }
55 - $novo = adicionar ( $locaplic, $_POST["titulolegenda"], $_POST ["link_tema"], $codigo, $_POST ["acessopublico"], $_POST ["metaestat"], $_POST ["nome_tema"], $_POST ["desc_tema"], $_POST ["en"], $_POST ["es"], true, $dbhw ); 50 + $novo = \admin\catalogo\mapfile\adicionar ( $locaplic, $_POST["titulolegenda"], $_POST ["link_tema"], $codigo, $_POST ["acessopublico"], $_POST ["metaestat"], $_POST ["nome_tema"], $_POST ["desc_tema"], $_POST ["en"], $_POST ["es"], true, $dbhw );
  51 + $dbhw = null;
  52 + $dbh = null;
56 if ($novo === false) { 53 if ($novo === false) {
57 header ( "HTTP/1.1 500 erro ao consultar banco de dados" ); 54 header ( "HTTP/1.1 500 erro ao consultar banco de dados" );
58 - exit (); 55 + } else {
  56 + //e necessario retornar o codigo criado pois e usado na interface
  57 + retornaJSON ( array (
  58 + "codigo" => $codigo
  59 + ) );
59 } 60 }
60 - retornaJSON ( array (  
61 - "codigo" => $codigo  
62 - ) );  
63 - exit ();  
64 break; 61 break;
65 case "ALTERAR" : 62 case "ALTERAR" :
66 - $codigo = str_replace ( " ", "", removeAcentos ( $codigo ) );  
67 - $codigo = str_replace ( ".", "", $codigo );  
68 - $codigo = strip_tags ( $codigo );  
69 - $codigo = htmlspecialchars ( $codigo, ENT_QUOTES );  
70 - $arq = $locaplic . "/temas/" . $codigo . ".map";  
71 - if ($codigo == "" || !file_exists ( $arq )) {  
72 - header ( "HTTP/1.1 400 arquivo nao existe" );  
73 - exit ();  
74 - }  
75 if(empty($_POST["titulolegenda"])){ 63 if(empty($_POST["titulolegenda"])){
76 $_POST["titulolegenda"] = $_POST ["nome_tema"]; 64 $_POST["titulolegenda"] = $_POST ["nome_tema"];
77 } 65 }
78 //quando e feita a listagem unica, o mapfile ja foi registrado no banco se nao tinha sido antes 66 //quando e feita a listagem unica, o mapfile ja foi registrado no banco se nao tinha sido antes
79 - $novo = alterar ( $locaplic, $_POST["id_tema"], $_POST["titulolegenda"], $_POST ["link_tema"], $codigo, $_POST ["acessopublico"], $_POST ["metaestat"], $_POST ["nome_tema"], $_POST ["desc_tema"], $_POST ["en"], $_POST ["es"], true, $dbhw ); 67 + $novo = \admin\catalogo\mapfile\alterar ( $locaplic, $_POST["id_tema"], $_POST["titulolegenda"], $_POST ["link_tema"], $codigo, $_POST ["acessopublico"], $_POST ["metaestat"], $_POST ["nome_tema"], $_POST ["desc_tema"], $_POST ["en"], $_POST ["es"], true, $dbhw );
  68 + $dbhw = null;
  69 + $dbh = null;
80 if ($novo === false) { 70 if ($novo === false) {
81 header ( "HTTP/1.1 500 erro ao consultar banco de dados" ); 71 header ( "HTTP/1.1 500 erro ao consultar banco de dados" );
82 - exit ();  
83 } 72 }
84 - retornaJSON ( array (  
85 - "codigo" => $codigo  
86 - ) );  
87 - exit ();  
88 break; 73 break;
89 case "EXCLUIR" : 74 case "EXCLUIR" :
90 - $codigo = $_POST ["codigo"];  
91 - $codigo = str_replace ( " ", "", removeAcentos ( $codigo ) );  
92 - $codigo = str_replace ( ".", "", $codigo );  
93 - $codigo = strip_tags ( $codigo );  
94 - $codigo = htmlspecialchars ( $codigo, ENT_QUOTES );  
95 - $retorna = excluir ( $codigo, $dbhw ); 75 + $retorna = \admin\catalogo\mapfile\excluir ( $codigo, $dbhw );
96 $dbhw = null; 76 $dbhw = null;
97 $dbh = null; 77 $dbh = null;
98 if ($retorna === false) { 78 if ($retorna === false) {
@@ -102,10 +82,9 @@ switch ($funcao) { @@ -102,10 +82,9 @@ switch ($funcao) {
102 retornaJSON ( array ( 82 retornaJSON ( array (
103 "codigo" => $codigo 83 "codigo" => $codigo
104 ) ); 84 ) );
105 - exit ();  
106 break; 85 break;
107 case "LISTA" : 86 case "LISTA" :
108 - $retorna = lista ( $dbh, $_POST ["filtro"], $_POST ["palavra"], $_POST ["validar"] ); 87 + $retorna = \admin\catalogo\mapfile\listar ( $dbh, $_POST ["filtro"], $_POST ["palavra"], $_POST ["validar"] );
109 $dbhw = null; 88 $dbhw = null;
110 $dbh = null; 89 $dbh = null;
111 if ($retorna === false) { 90 if ($retorna === false) {
@@ -113,566 +92,35 @@ switch ($funcao) { @@ -113,566 +92,35 @@ switch ($funcao) {
113 exit (); 92 exit ();
114 } 93 }
115 retornaJSON ( $retorna ); 94 retornaJSON ( $retorna );
116 - exit ();  
117 break; 95 break;
118 case "LISTAUNICO" : 96 case "LISTAUNICO" :
119 - //pega o nome registrado no mapfile  
120 - if(!file_exists($locaplic."/temas/".$codigo.".map")){  
121 - header ( "HTTP/1.1 500 erro mapfile nao existe" );  
122 - exit ();  
123 - }  
124 - $mapa = ms_newMapObj ( $locaplic."/temas/".$codigo.".map" );  
125 - $layer = $mapa->getlayerbyname($codigo);  
126 - if($layer == ""){  
127 - header ( "HTTP/1.1 500 erro nao existe LAYER com o nome $codigo" );  
128 - exit ();  
129 - }  
130 - $titulolegenda = $layer->getmetadata("TEMA");  
131 - $metaestat = $layer->getmetadata("METAESTAT");  
132 - $dados = pegaDados ( "SELECT * from ".$esquemaadmin."i3geoadmin_temas WHERE codigo_tema = '$codigo' ", $dbh, false );  
133 - //se nao existir no sistema de admin, faz o registro  
134 - if(count($dados) == 0){  
135 - $dataCol = array (  
136 - "kml_tema" => "SIM",  
137 - "kmz_tema" => "SIM",  
138 - "ogc_tema" => "SIM",  
139 - "download_tema" => "SIM",  
140 - "desc_tema" => "",  
141 - "tipoa_tema" => "",  
142 - "tags_tema" => "",  
143 - "nome_tema" => $titulolegenda,  
144 - "codigo_tema" => $codigo,  
145 - "it" => "",  
146 - "es" => "",  
147 - "en" => ""  
148 - );  
149 - $id_tema = i3GeoAdminInsertUnico($dbhw,"i3geoadmin_temas",$dataCol,"link_tema","id_tema");  
150 - $dados = pegaDados ( "SELECT * from ".$esquemaadmin."i3geoadmin_temas WHERE codigo_tema = '$codigo' AND id_tema = $id_tema ", $dbh, false );  
151 - if(count($dados) == 0){  
152 - $dbhw = null;  
153 - $dbh = null;  
154 - header ( "HTTP/1.1 500 erro ao registrar no banco de dados" );  
155 - exit ();  
156 - }  
157 - }  
158 - if ($dados === false) {  
159 - $dbhw = null;  
160 - $dbh = null; 97 + $retorna = \admin\catalogo\mapfile\listaUnico ( $dbh, $codigo );
  98 + $dbhw = null;
  99 + $dbh = null;
  100 + if ($retorna === false) {
161 header ( "HTTP/1.1 500 erro ao consultar banco de dados" ); 101 header ( "HTTP/1.1 500 erro ao consultar banco de dados" );
162 - exit ();  
163 - }  
164 - $acessopublico = "";  
165 - if(strtolower($dados[0]["ogc_tema"]) !== "nao" || strtolower($dados[0]["download_tema"]) !== "nao"){  
166 - $acessopublico = "checked";  
167 - }  
168 - if($metaestat == ""){  
169 - $dados[0]["metaestatnao"] = "selected";  
170 } else { 102 } else {
171 - $dados[0]["metaestatsim"] = "selected";  
172 - }  
173 - $dados[0]["acessopublico"] = $acessopublico;  
174 - $dados[0]["metaestat"] = $metaestat;  
175 - //a pagina e utf e o texto pode ser iso  
176 - if(mb_detect_encoding($titulolegenda,'UTF-8, ISO-8859-1') == "ISO-8859-1"){  
177 - $titulolegenda = utf8_encode($titulolegenda); 103 + retornaJSON ( array("dados"=>$retorna) );
178 } 104 }
179 - $dados[0]["titulolegenda"] = $titulolegenda;  
180 - $dados[0]["codigo"] = $codigo;  
181 - retornaJSON ( array("dados"=>$dados[0]) );  
182 break; 105 break;
183 case "LIMPACACHE" : 106 case "LIMPACACHE" :
184 - $mapfile = $locaplic . "/temas/" . $_POST ["codigo"] . ".map";  
185 - if (! file_exists ( $mapfile )) {  
186 - header ( "HTTP/1.1 403 arquivo nao existe" );  
187 - exit ();  
188 - }  
189 - $mapa = ms_newMapObj ( $mapfile );  
190 - $nomes = $mapa->getalllayernames ();  
191 - // $cachedir e $dir_tmp vem de ms_configura.php  
192 - if ($cachedir != "") {  
193 - $d = $cachedir;  
194 - } else {  
195 - $d = $dir_tmp . "/cache";  
196 - }  
197 - foreach ( $nomes as $nome ) {  
198 - $nome = str_replace ( ".", "", $nome );  
199 - $nome = strip_tags ( $nome );  
200 - $nome = htmlspecialchars ( $nome, ENT_QUOTES );  
201 - $dirs [] = $d . "/" . $nome;  
202 - $dirs [] = $d . "/googlemaps/" . $nome;  
203 - $dirs [] = $d . "/wmts/" . $nome;  
204 - foreach ( $dirs as $dir ) {  
205 - rrmdir ( $dir );  
206 - }  
207 - } 107 + $retorna = \admin\catalogo\mapfile\limpaCache($locaplic, $codigo, $cachedir, $dir_tmp);
208 retornaJSON ( "ok" ); 108 retornaJSON ( "ok" );
209 - exit ();  
210 break; 109 break;
211 case "CLONARMAPFILE" : 110 case "CLONARMAPFILE" :
212 - $codigo = $_POST ["codigo"];  
213 - $codigo = str_replace ( " ", "", removeAcentos ( $codigo ) );  
214 - $codigo = str_replace ( ".", "", $codigo );  
215 - $codigo = strip_tags ( $codigo );  
216 - $codigo = htmlspecialchars ( $codigo, ENT_QUOTES );  
217 -  
218 $novocodigo = $_POST ["novocodigo"]; 111 $novocodigo = $_POST ["novocodigo"];
219 $novocodigo = str_replace ( " ", "", removeAcentos ( $novocodigo ) ); 112 $novocodigo = str_replace ( " ", "", removeAcentos ( $novocodigo ) );
220 $novocodigo = str_replace ( ".", "", $novocodigo ); 113 $novocodigo = str_replace ( ".", "", $novocodigo );
221 $novocodigo = strip_tags ( $novocodigo ); 114 $novocodigo = strip_tags ( $novocodigo );
222 $novocodigo = htmlspecialchars ( $novocodigo, ENT_QUOTES ); 115 $novocodigo = htmlspecialchars ( $novocodigo, ENT_QUOTES );
223 -  
224 - $arq = $locaplic . "/temas/" . $codigo . ".map";  
225 - $arqnovo = $locaplic . "/temas/" . $novocodigo . ".map";  
226 -  
227 - if ($codigo == "" || !file_exists ( $arq )) {  
228 - header ( "HTTP/1.1 400 arquivo nao existe" );  
229 - exit ();  
230 - }  
231 - if ($novocodigo == "" || file_exists ( $arqnovo )) {  
232 - header ( "HTTP/1.1 400 arquivo ja existe" );  
233 - exit ();  
234 - }  
235 - //obtem os dados do banco do tema existente  
236 - $dados = pegaDados ( "SELECT * from " . $esquemaadmin . "i3geoadmin_temas WHERE codigo_tema = '" . $codigo . "'", $dbh, false );  
237 - if (count ( $dados ) > 0) {  
238 - //o mapfile esta registrado como um tema no banco de adm  
239 - $dataCol = array (  
240 - "link_tema" => $dados [0] ["link_tema"],  
241 - "kml_tema" => $dados [0] ["kml_tema"],  
242 - "kmz_tema" => $dados [0] ["kmz_tema"],  
243 - "ogc_tema" => $dados [0] ["ogc_tema"],  
244 - "download_tema" => $dados [0] ["download_tema"],  
245 - "desc_tema" => "",  
246 - "tipoa_tema" => $dados [0] ["tipoa_tema"],  
247 - "tags_tema" => '',  
248 - "nome_tema" => $_POST["titulo"],  
249 - "codigo_tema" => $novocodigo,  
250 - "it" => "",  
251 - "es" => "",  
252 - "en" => ""  
253 - );  
254 - $acessopublico = $dados [0] ["download_tema"];  
255 - } else {  
256 - $acessopublico = "";  
257 - }  
258 - //faz a copia do mapfile  
259 - $mapa = ms_newMapObj($arq);  
260 - $layer = @$mapa->getlayerbyname($codigo);  
261 - $layer->set("name",$novocodigo);  
262 - $layer->setmetadata("TEMA",$_POST["titulo"]);  
263 - $mapa->save($arqnovo);  
264 - include(dirname(__FILE__)."/../../php/removeCabecalhoMapfile.php");  
265 - removeCabecalhoMapfile($arqnovo);  
266 -  
267 - if (count ( $dados ) > 0) {  
268 - //registra no banco de dados caso nao tenha ocorrido erro ao criar o mapfile  
269 - i3GeoAdminInsert ( $dbhw, "i3geoadmin_temas", $dataCol );  
270 - } 116 + $titulo = $_POST["titulo"];
  117 + $retorna = \admin\catalogo\mapfile\clonarMapfile($codigo,$novocodigo,$titulo,$dbh,$dbhw);
271 retornaJSON ( array ( 118 retornaJSON ( array (
272 "codigo" => $novocodigo 119 "codigo" => $novocodigo
273 ) ); 120 ) );
274 - exit (); 121 + break;
  122 + default:
  123 + header ( "HTTP/1.1 500 erro funcao nao existe" );
275 break; 124 break;
276 } 125 }
277 -cpjson ( $retorno );  
278 -function excluir($codigo, $dbhw) {  
279 - global $locaplic, $esquemaadmin;  
280 - // pega o id do tema  
281 - // se o mapfile nao estiver registrado, $id sera vazio  
282 - $dados = pegaDados ( "SELECT id_tema from " . $esquemaadmin . "i3geoadmin_temas WHERE codigo_tema = '" . $codigo . "'", $dbhw, false );  
283 - if (count ( $dados ) > 0) {  
284 - $id = $dados [0] ["id_tema"];  
285 - } else {  
286 - $id = "";  
287 - }  
288 - // verifica se o tema esta em uso  
289 - if ($id != "") {  
290 - $r = pegaDados ( "SELECT id_tema from " . $esquemaadmin . "i3geoadmin_n3 where id_tema ='$id'", $dbhw, false );  
291 - if (count ( $r ) > 0) {  
292 - return "o tema e utilizado em algum subgrupo";  
293 - }  
294 - $r = pegaDados ( "SELECT id_tema from " . $esquemaadmin . "i3geoadmin_raiz where id_tema ='$id'", $dbhw, false );  
295 - if (count ( $r ) > 0) {  
296 - return "o tema e utilizado em alguma raiz";  
297 - }  
298 - }  
299 - if (! file_exists ( "$locaplic/temas/" . $codigo . ".map" )) {  
300 - return "o arquivo mapfile nao existe";  
301 - }  
302 - // verifica se pode escrever  
303 - $handle = fopen ( "$locaplic/temas/" . $codigo . ".map", "r+" );  
304 - if ($handle == false) {  
305 - return "o arquivo nao pode ser apagado verifique as permissoes";  
306 - }  
307 - fclose ( $handle );  
308 - // tenta excluir do banco  
309 - $resultado = i3GeoAdminExclui ( $esquemaadmin . "i3geoadmin_temas", "id_tema", $id, $dbhw, true );  
310 - if ($resultado === false) {  
311 - return "nao foi possivel excluir do banco de dados";  
312 - }  
313 - unlink ( "$locaplic/temas/" . $codigo . ".map" );  
314 - return true;  
315 -}  
316 -function alterar($locaplic, $id_tema, $titulolegenda, $link_tema, $codigo, $acessopublico, $metaestat, $titulo, $desc_tema, $tituloEN, $tituloES, $registraBanco, $dbhw) {  
317 - global $convUTF, $esquemaadmin;  
318 - $arq = $locaplic . "/temas/" . $codigo . ".map";  
319 - if(!file_exists($locaplic . "/temas/" . $codigo . ".map")){  
320 - return false;  
321 - }  
322 - $mapa = ms_newMapObj($arq);  
323 - $layer = @$mapa->getlayerbyname($codigo);  
324 - if($layer == ""){  
325 - return false;  
326 - }  
327 - if(mb_detect_encoding($titulolegenda,'UTF-8, ISO-8859-1') == "UTF-8"){  
328 - $titulolegenda = utf8_decode($titulolegenda);  
329 - }  
330 - if ($convUTF != true) {  
331 - $titulo = utf8_decode ( $titulo );  
332 - $desc_tema = utf8_decode ( $desc_tema );  
333 - }  
334 -  
335 - if (empty ( $acessopublico ) || $acessopublico == "on") {  
336 - $acessopublico = "SIM";  
337 - } else {  
338 - $acessopublico = "NAO";  
339 - }  
340 - $layer->setmetadata("permiteogc",$acessopublico);  
341 - $layer->setmetadata("permitedownload",$acessopublico);  
342 - $layer->setmetadata("permitekml",$acessopublico);  
343 - $layer->setmetadata("permitekmz",$acessopublico);  
344 - $layer->setmetadata("TEMA",$titulolegenda);  
345 - if (! empty ( $metaestat ) && $metaestat == "SIM") {  
346 - $layer->setmetadata("METAESTAT","SIM");  
347 - $tipoa_tema = "META";  
348 - } else {  
349 - $layer->setmetadata("METAESTAT","");  
350 - $tipoa_tema = "";  
351 - }  
352 -  
353 -  
354 - try {  
355 - $dataCol = array (  
356 - "link_tema" => $link_tema,  
357 - "kml_tema" => $acessopublico,  
358 - "kmz_tema" => $acessopublico,  
359 - "ogc_tema" => $acessopublico,  
360 - "download_tema" => $acessopublico,  
361 - "desc_tema" => $desc_tema,  
362 - "tipoa_tema" => $tipoa_tema,  
363 - "tags_tema" => '',  
364 - "nome_tema" => $titulo,  
365 - "codigo_tema" => $codigo,  
366 - "it" => "",  
367 - "es" => $tituloES,  
368 - "en" => $tituloEN  
369 - );  
370 - $resultado = i3GeoAdminUpdate ( $dbhw, "i3geoadmin_temas", $dataCol, "WHERE id_tema = $id_tema" );  
371 - if ($resultado === false) {  
372 - return false;  
373 - }  
374 - $mapa->save($arq);  
375 - include(dirname(__FILE__)."/../../php/removeCabecalhoMapfile.php");  
376 - removeCabecalhoMapfile($arq);  
377 - return true;  
378 - } catch ( PDOException $e ) {  
379 - return false;  
380 - }  
381 -}  
382 -function adicionar($locaplic, $titulolegenda, $link_tema, $codigo, $acessopublico, $metaestat, $titulo, $desc_tema, $tituloEN, $tituloES, $registraBanco, $dbhw) {  
383 - global $convUTF, $esquemaadmin;  
384 - $arq = $locaplic . "/temas/" . $codigo . ".map";  
385 - if (empty ( $acessopublico ) || $acessopublico == "on") {  
386 - $acessopublico = "SIM";  
387 - } else {  
388 - $acessopublico = "NAO";  
389 - }  
390 - if(mb_detect_encoding($titulolegenda,'UTF-8, ISO-8859-1') == "UTF-8"){  
391 - $titulolegenda = utf8_decode($titulolegenda);  
392 - }  
393 - $tipoLayer = "line";  
394 - $dados [] = "MAP";  
395 - $dados [] = "SYMBOLSET ../symbols/simbolosv6.sym";  
396 - $dados [] = 'FONTSET "../symbols/fontes.txt"';  
397 - $dados [] = "LAYER";  
398 - $dados [] = ' NAME "' . $codigo . '"';  
399 - $dados [] = ' TEMPLATE "none.htm"';  
400 - if (! empty ( $metaestat ) && $metaestat == "SIM") {  
401 - $dados [] = ' CONNECTIONTYPE POSTGIS';  
402 - $tipoLayer = "polygon";  
403 - }  
404 - $dados [] = " TYPE " . $tipoLayer;  
405 - $dados [] = ' DATA ""';  
406 - $dados [] = ' CONNECTION ""';  
407 - $dados [] = ' STATUS DEFAULT';  
408 - $dados [] = ' METADATA';  
409 - $dados [] = ' TEMA "' . $titulolegenda . '"';  
410 - $dados [] = ' CLASSE "SIM"';  
411 - $tipoa_tema = "";  
412 - if (! empty ( $metaestat ) && $metaestat == "SIM") {  
413 - $dados [] = ' METAESTAT "SIM"';  
414 - // para marcar no banco de dados de administracao  
415 - $tipoa_tema = "META";  
416 - }  
417 - $dados [] = ' permiteogc "' . $acessopublico . '"';  
418 - $dados [] = ' permitedownload "' . $acessopublico . '"';  
419 - $dados [] = ' permitekml "' . $acessopublico . '"';  
420 - $dados [] = ' permitekmz "' . $acessopublico . '"';  
421 - $dados [] = ' END';  
422 - $dados [] = ' CLASS';  
423 - $dados [] = ' NAME ""';  
424 - $dados [] = ' STYLE';  
425 - $dados [] = ' COLOR 0 0 0';  
426 - $dados [] = ' SIZE 12';  
427 - $dados [] = ' END';  
428 - $dados [] = ' END';  
429 - $dados [] = "END";  
430 - $dados [] = "END";  
431 -  
432 - // abre o arquivo para ver se nao deu erro antes de adicionar ao banco  
433 - $fp = fopen ( $arq, "w" );  
434 - if ($fp === false) {  
435 - return false;  
436 - }  
437 - if ($convUTF != true) {  
438 - $titulo = utf8_decode ( $titulo );  
439 - $desc_tema = utf8_decode ( $desc_tema );  
440 - }  
441 - if($registraBanco == true){  
442 - try {  
443 - $dataCol = array (  
444 - "link_tema" => $link_tema,  
445 - "kml_tema" => $acessopublico,  
446 - "kmz_tema" => $acessopublico,  
447 - "ogc_tema" => $acessopublico,  
448 - "download_tema" => $acessopublico,  
449 - "desc_tema" => $desc_tema,  
450 - "tipoa_tema" => $tipoa_tema,  
451 - "tags_tema" => '',  
452 - "nome_tema" => $titulo,  
453 - "codigo_tema" => $codigo,  
454 - "it" => "",  
455 - "es" => $tituloES,  
456 - "en" => $tituloEN  
457 - );  
458 - i3GeoAdminInsert ( $dbhw, "i3geoadmin_temas", $dataCol );  
459 - // salva o arquivo mapfile  
460 - foreach ( $dados as $dado ) {  
461 - fwrite ( $fp, $dado . "\n" );  
462 - }  
463 - fclose ( $fp );  
464 - return true;  
465 - } catch ( PDOException $e ) {  
466 - return false;  
467 - }  
468 - } else {  
469 - return true;  
470 - }  
471 -}  
472 -function lista($dbh, $filtro = "", $palavra = "", $validar = "") {  
473 - global $convUTF, $locaplic, $esquemaadmin;  
474 - $arquivos = array ();  
475 - if (is_dir ( $locaplic . "/temas" )) {  
476 - if ($dh = opendir ( $locaplic . "/temas" )) {  
477 - while ( ($file = readdir ( $dh )) !== false ) {  
478 - if (! stristr ( $file, '.map' ) === FALSE) {  
479 - $file = str_replace ( ".map", "", $file );  
480 - // verifica se existe um filtro de palavra  
481 - if ($palavra != "") {  
482 - if (stripos ( $file, $palavra ) !== false) {  
483 - $arquivos [] = array (  
484 - "nome" => $file  
485 - );  
486 - }  
487 - } else {  
488 - $arquivos [] = array (  
489 - "nome" => $file  
490 - );  
491 - }  
492 - }  
493 - }  
494 - }  
495 - closedir ( $dh );  
496 - }  
497 - sort ( $arquivos );  
498 -  
499 - //  
500 - // pega o nome de cada tema filtrando a listagem se for o caso  
501 - //  
502 - $regs = pegaDados ( "select * from " . $esquemaadmin . "i3geoadmin_temas ", $dbh, false );  
503 -  
504 - $nomes = array ();  
505 - $ids = array ();  
506 - $dadosBanco = array ();  
507 - foreach ( $regs as $reg ) {  
508 - if ($convUTF != true) {  
509 - $reg ["nome_tema"] = utf8_decode ( $reg ["nome_tema"] );  
510 - }  
511 - $nomes [$reg ["codigo_tema"]] = $reg ["nome_tema"];  
512 - $ids [$reg ["codigo_tema"]] = $reg ["id_tema"];  
513 - $dadosBanco [$reg ["id_tema"]] = $reg;  
514 - }  
515 - $lista = array ();  
516 - foreach ( $arquivos as $arq ) {  
517 - $arq = $arq ["nome"];  
518 - $nT = explode ( ".", $arq );  
519 - $n = $nomes [$nT [0]];  
520 - if (! $n) {  
521 - $n = "";  
522 - }  
523 - $id = $ids [$nT [0]];  
524 - //o mapfile nao esta registrado no banco  
525 - if (! $id && empty($validar)) {  
526 - $id = "";  
527 - } else {  
528 - //aplica as validacoes. Se nao passar na validacao $id ficara vazio, para nao mostrar no resultado final  
529 - switch ($validar) {  
530 - case 1 :  
531 - if($dadosBanco[$id]["link_tema"] !== ""){  
532 - $id = "";  
533 - }  
534 - break;  
535 - case 2 :  
536 - if($dadosBanco[$id]["nome_tema"] == ""){  
537 - $id = "-";  
538 - } else {  
539 - $id = "";  
540 - }  
541 - break;  
542 - case 3 :  
543 - if($dadosBanco[$id]["nome_tema"] == ""){  
544 - $id = "";  
545 - }  
546 - break;  
547 - case 4 :  
548 - if(strtolower($dadosBanco[$id]["download_tema"]) !== "sim"){  
549 - $id = "";  
550 - }  
551 - break;  
552 - case 5 :  
553 - if(strtolower($dadosBanco[$id]["download_tema"]) !== "nao"){  
554 - $id = "";  
555 - }  
556 - break;  
557 - case 6 :  
558 - if(strtolower($dadosBanco[$id]["ogc_tema"]) !== "sim"){  
559 - $id = "";  
560 - }  
561 - break;  
562 - case 7 :  
563 - if(strtolower($dadosBanco[$id]["ogc_tema"]) !== "nao"){  
564 - $id = "";  
565 - }  
566 - break;  
567 - case 8 :  
568 - if(strtolower($dadosBanco[$id]["kml_tema"]) !== "sim"){  
569 - $id = "";  
570 - }  
571 - break;  
572 - case 9 :  
573 - if(strtolower($dadosBanco[$id]["kml_tema"]) !== "nao"){  
574 - $id = "";  
575 - }  
576 - break;  
577 - case 10 :  
578 - if(strtolower($dadosBanco[$id]["kmz_tema"]) !== "sim"){  
579 - $id = "";  
580 - }  
581 - break;  
582 - case 11 :  
583 - if(strtolower($dadosBanco[$id]["kmz_tema"]) !== "nao"){  
584 - $id = "";  
585 - }  
586 - break;  
587 - }  
588 - }  
589 - $imagem = "";  
590 - if (file_exists ( $locaplic . "/temas/miniaturas/" . $arq . ".map.mini.png" )) {  
591 - $imagem = $arq . ".map.mini.png";  
592 - }  
593 -  
594 - if ($validar == 12) {  
595 - if (file_exists ( $locaplic . "/temas/" . $arq . ".map" )) {  
596 - $handle = fopen ( $locaplic . "/temas/" . $arq . ".map", "r" );  
597 - while ( ! feof ( $handle ) ) {  
598 - $linha = fgets ( $handle );  
599 - if (stripos ( $linha, "'TEMA'" ) !== false || stripos ( $linha, '"TEMA"' ) !== false) {  
600 - $ntema = str_replace ( array (  
601 - "'TEMA'",  
602 - '"TEMA"',  
603 - "'tema'",  
604 - '"tema"'  
605 - ), "", $linha );  
606 - $ntema = trim ( str_replace ( array (  
607 - "'",  
608 - '"'  
609 - ), "", $ntema ) );  
610 - $temp = $n;  
611 - if ($n != $ntema && utf8_decode($temp) != $ntema && $n != "") {  
612 - $n .= "<span style=color:red;margin-left:5px >" . utf8_encode($ntema) . "</span>";  
613 - } else {  
614 - $n .= "<span style=color:lightslategray;margin-left:5px >" . utf8_encode($ntema) . "</span>";  
615 - }  
616 - break;  
617 - }  
618 - }  
619 - fclose ( $handle );  
620 - }  
621 - }  
622 - if ($validar == 13) {  
623 - if (file_exists ( $locaplic . "/temas/" . $arq . ".map" )) {  
624 - $handle = fopen ( $locaplic . "/temas/" . $arq . ".map", "r" );  
625 - // deve buscar dentro de LAYER pois pode haver simbolos antes  
626 - $elayer = false;  
627 - while ( ! feof ( $handle ) ) {  
628 - $linha = trim ( fgets ( $handle ) );  
629 - if (stripos ( $linha, "LAYER" ) === 0) {  
630 - $elayer = true;  
631 - }  
632 - if ($elayer == true && stripos ( $linha, "NAME" ) === 0) {  
633 - $ntema = ltrim ( $linha, "NAMEname" );  
634 - $ntema = trim ( str_replace ( array (  
635 - "'",  
636 - '"'  
637 - ), "", $ntema ) );  
638 - if ($arq != $ntema) {  
639 - $n .= "<span style=color:red;margin-left:5px >" . $ntema . "</span>";  
640 - }  
641 - break;  
642 - }  
643 - }  
644 - fclose ( $handle );  
645 - }  
646 - }  
647 - //se id for vazio, nao consta no banco, por isso, se validar for definido, nao pode ser aplicado  
648 - if(empty($validar) || (!empty($validar) && $id != "")){  
649 - $lista [] = array (  
650 - "id_tema" => $id,  
651 - "nome" => $n,  
652 - "codigo" => $arq,  
653 - "imagem" => $imagem,  
654 - "extensao" => ""  
655 - );  
656 - }  
657 - }  
658 - return $lista;  
659 -}  
660 -function rrmdir($dir) {  
661 - if (is_dir ( $dir )) {  
662 - $objects = scandir ( $dir );  
663 - foreach ( $objects as $object ) {  
664 - if ($object != "." && $object != "..") {  
665 - if (filetype ( $dir . "/" . $object ) == "dir") {  
666 - rrmdir ( $dir . "/" . $object );  
667 - } else {  
668 - $object = str_replace ( ".png", "", $object ) . ".png";  
669 - chmod ( $dir . "/" . $object, 077 );  
670 - unlink ( $dir . "/" . $object );  
671 - }  
672 - }  
673 - }  
674 - reset ( $objects );  
675 - // rmdir($dir);  
676 - }  
677 -}  
678 -?> 126 +?>
679 \ No newline at end of file 127 \ No newline at end of file
admin1/catalogo/mapfile/funcoes.php 0 → 100755
@@ -0,0 +1,554 @@ @@ -0,0 +1,554 @@
  1 +<?php
  2 +
  3 +namespace admin\catalogo\mapfile;
  4 +
  5 +function excluir($codigo, $dbhw) {
  6 + global $locaplic, $esquemaadmin;
  7 + // pega o id do tema
  8 + // se o mapfile nao estiver registrado, $id sera vazio
  9 + $dados = pegaDados ( "SELECT id_tema from " . $esquemaadmin . "i3geoadmin_temas WHERE codigo_tema = '" . $codigo . "'", $dbhw, false );
  10 + if (count ( $dados ) > 0) {
  11 + $id = $dados [0] ["id_tema"];
  12 + } else {
  13 + $id = "";
  14 + }
  15 + // verifica se o tema esta em uso
  16 + if ($id != "") {
  17 + $r = pegaDados ( "SELECT id_tema from " . $esquemaadmin . "i3geoadmin_n3 where id_tema ='$id'", $dbhw, false );
  18 + if (count ( $r ) > 0) {
  19 + return "o tema e utilizado em algum subgrupo";
  20 + }
  21 + $r = pegaDados ( "SELECT id_tema from " . $esquemaadmin . "i3geoadmin_raiz where id_tema ='$id'", $dbhw, false );
  22 + if (count ( $r ) > 0) {
  23 + return "o tema e utilizado em alguma raiz";
  24 + }
  25 + }
  26 + if (! file_exists ( "$locaplic/temas/" . $codigo . ".map" )) {
  27 + return "o arquivo mapfile nao existe";
  28 + }
  29 + // verifica se pode escrever
  30 + $handle = fopen ( "$locaplic/temas/" . $codigo . ".map", "r+" );
  31 + if ($handle == false) {
  32 + return "o arquivo nao pode ser apagado verifique as permissoes";
  33 + }
  34 + fclose ( $handle );
  35 + // tenta excluir do banco
  36 + $resultado = i3GeoAdminExclui ( $esquemaadmin . "i3geoadmin_temas", "id_tema", $id, $dbhw, true );
  37 + if ($resultado === false) {
  38 + return "nao foi possivel excluir do banco de dados";
  39 + }
  40 + unlink ( "$locaplic/temas/" . $codigo . ".map" );
  41 + return true;
  42 +}
  43 +function alterar($locaplic, $id_tema, $titulolegenda, $link_tema, $codigo, $acessopublico, $metaestat, $titulo, $desc_tema, $tituloEN, $tituloES, $registraBanco, $dbhw) {
  44 + global $convUTF, $esquemaadmin;
  45 + $arq = $locaplic . "/temas/" . $codigo . ".map";
  46 + if ($codigo == "" || ! file_exists ( $arq )) {
  47 + header ( "HTTP/1.1 400 arquivo nao existe" );
  48 + exit ();
  49 + }
  50 + $mapa = ms_newMapObj ( $arq );
  51 + $layer = @$mapa->getlayerbyname ( $codigo );
  52 + if ($layer == "") {
  53 + return false;
  54 + }
  55 + if (mb_detect_encoding ( $titulolegenda, 'UTF-8, ISO-8859-1' ) == "UTF-8") {
  56 + $titulolegenda = utf8_decode ( $titulolegenda );
  57 + }
  58 + if ($convUTF != true) {
  59 + $titulo = utf8_decode ( $titulo );
  60 + $desc_tema = utf8_decode ( $desc_tema );
  61 + }
  62 +
  63 + if (empty ( $acessopublico ) || $acessopublico == "on") {
  64 + $acessopublico = "SIM";
  65 + } else {
  66 + $acessopublico = "NAO";
  67 + }
  68 + $layer->setmetadata ( "permiteogc", $acessopublico );
  69 + $layer->setmetadata ( "permitedownload", $acessopublico );
  70 + $layer->setmetadata ( "permitekml", $acessopublico );
  71 + $layer->setmetadata ( "permitekmz", $acessopublico );
  72 + $layer->setmetadata ( "TEMA", $titulolegenda );
  73 + if (! empty ( $metaestat ) && $metaestat == "SIM") {
  74 + $layer->setmetadata ( "METAESTAT", "SIM" );
  75 + $tipoa_tema = "META";
  76 + } else {
  77 + $layer->setmetadata ( "METAESTAT", "" );
  78 + $tipoa_tema = "";
  79 + }
  80 + try {
  81 + $dataCol = array (
  82 + "link_tema" => $link_tema,
  83 + "kml_tema" => $acessopublico,
  84 + "kmz_tema" => $acessopublico,
  85 + "ogc_tema" => $acessopublico,
  86 + "download_tema" => $acessopublico,
  87 + "desc_tema" => $desc_tema,
  88 + "tipoa_tema" => $tipoa_tema,
  89 + "tags_tema" => '',
  90 + "nome_tema" => $titulo,
  91 + "codigo_tema" => $codigo,
  92 + "it" => "",
  93 + "es" => $tituloES,
  94 + "en" => $tituloEN
  95 + );
  96 + $resultado = i3GeoAdminUpdate ( $dbhw, "i3geoadmin_temas", $dataCol, "WHERE id_tema = $id_tema" );
  97 + if ($resultado === false) {
  98 + return false;
  99 + }
  100 + $mapa->save ( $arq );
  101 + include (dirname ( __FILE__ ) . "/../../php/removeCabecalhoMapfile.php");
  102 + removeCabecalhoMapfile ( $arq );
  103 + return true;
  104 + } catch ( PDOException $e ) {
  105 + return false;
  106 + }
  107 +}
  108 +function adicionar($locaplic, $titulolegenda, $link_tema, $codigo, $acessopublico, $metaestat, $titulo, $desc_tema, $tituloEN, $tituloES, $registraBanco, $dbhw) {
  109 + global $convUTF, $esquemaadmin;
  110 + if ($codigo == "" || file_exists ( $arq )) {
  111 + header ( "HTTP/1.1 400 arquivo ja existe" );
  112 + exit ();
  113 + }
  114 + $arq = $locaplic . "/temas/" . $codigo . ".map";
  115 +
  116 + if (empty ( $acessopublico ) || $acessopublico == "on") {
  117 + $acessopublico = "SIM";
  118 + } else {
  119 + $acessopublico = "NAO";
  120 + }
  121 + if (mb_detect_encoding ( $titulolegenda, 'UTF-8, ISO-8859-1' ) == "UTF-8") {
  122 + $titulolegenda = utf8_decode ( $titulolegenda );
  123 + }
  124 + $tipoLayer = "line";
  125 + $dados [] = "MAP";
  126 + $dados [] = "SYMBOLSET ../symbols/simbolosv6.sym";
  127 + $dados [] = 'FONTSET "../symbols/fontes.txt"';
  128 + $dados [] = "LAYER";
  129 + $dados [] = ' NAME "' . $codigo . '"';
  130 + $dados [] = ' TEMPLATE "none.htm"';
  131 + if (! empty ( $metaestat ) && $metaestat == "SIM") {
  132 + $dados [] = ' CONNECTIONTYPE POSTGIS';
  133 + $tipoLayer = "polygon";
  134 + }
  135 + $dados [] = " TYPE " . $tipoLayer;
  136 + $dados [] = ' DATA ""';
  137 + $dados [] = ' CONNECTION ""';
  138 + $dados [] = ' STATUS DEFAULT';
  139 + $dados [] = ' METADATA';
  140 + $dados [] = ' TEMA "' . $titulolegenda . '"';
  141 + $dados [] = ' CLASSE "SIM"';
  142 + $tipoa_tema = "";
  143 + if (! empty ( $metaestat ) && $metaestat == "SIM") {
  144 + $dados [] = ' METAESTAT "SIM"';
  145 + // para marcar no banco de dados de administracao
  146 + $tipoa_tema = "META";
  147 + }
  148 + $dados [] = ' permiteogc "' . $acessopublico . '"';
  149 + $dados [] = ' permitedownload "' . $acessopublico . '"';
  150 + $dados [] = ' permitekml "' . $acessopublico . '"';
  151 + $dados [] = ' permitekmz "' . $acessopublico . '"';
  152 + $dados [] = ' END';
  153 + $dados [] = ' CLASS';
  154 + $dados [] = ' NAME ""';
  155 + $dados [] = ' STYLE';
  156 + $dados [] = ' COLOR 0 0 0';
  157 + $dados [] = ' SIZE 12';
  158 + $dados [] = ' END';
  159 + $dados [] = ' END';
  160 + $dados [] = "END";
  161 + $dados [] = "END";
  162 +
  163 + // abre o arquivo para ver se nao deu erro antes de adicionar ao banco
  164 + $fp = fopen ( $arq, "w" );
  165 + if ($fp === false) {
  166 + return false;
  167 + }
  168 + if ($convUTF != true) {
  169 + $titulo = utf8_decode ( $titulo );
  170 + $desc_tema = utf8_decode ( $desc_tema );
  171 + }
  172 + if ($registraBanco == true) {
  173 + try {
  174 + $dataCol = array (
  175 + "link_tema" => $link_tema,
  176 + "kml_tema" => $acessopublico,
  177 + "kmz_tema" => $acessopublico,
  178 + "ogc_tema" => $acessopublico,
  179 + "download_tema" => $acessopublico,
  180 + "desc_tema" => $desc_tema,
  181 + "tipoa_tema" => $tipoa_tema,
  182 + "tags_tema" => '',
  183 + "nome_tema" => $titulo,
  184 + "codigo_tema" => $codigo,
  185 + "it" => "",
  186 + "es" => $tituloES,
  187 + "en" => $tituloEN
  188 + );
  189 + i3GeoAdminInsert ( $dbhw, "i3geoadmin_temas", $dataCol );
  190 + // salva o arquivo mapfile
  191 + foreach ( $dados as $dado ) {
  192 + fwrite ( $fp, $dado . "\n" );
  193 + }
  194 + fclose ( $fp );
  195 + return true;
  196 + } catch ( PDOException $e ) {
  197 + return false;
  198 + }
  199 + } else {
  200 + return true;
  201 + }
  202 +}
  203 +function listar($dbh, $filtro = "", $palavra = "", $validar = "") {
  204 + global $convUTF, $locaplic, $esquemaadmin;
  205 + $arquivosTemp = array ();
  206 + if (is_dir ( $locaplic . "/temas" )) {
  207 + if ($dh = opendir ( $locaplic . "/temas" )) {
  208 + while ( ($file = readdir ( $dh )) !== false ) {
  209 + if (! stristr ( $file, '.map' ) === FALSE) {
  210 + $file = str_replace ( ".map", "", $file );
  211 + // verifica se existe um filtro de palavra
  212 + if ($palavra != "") {
  213 + if (stripos ( $file, $palavra ) !== false) {
  214 + $arquivosTemp [] = $file;
  215 + }
  216 + } else {
  217 + $arquivosTemp [] = $file;
  218 + }
  219 + }
  220 + }
  221 + }
  222 + closedir ( $dh );
  223 + }
  224 + natcasesort( $arquivosTemp );
  225 + $arquivos = array ();
  226 + foreach($arquivosTemp as $arq){
  227 + $arquivos[] = array("nome"=>$arq);
  228 + }
  229 +
  230 + //
  231 + // pega o nome de cada tema filtrando a listagem se for o caso
  232 + //
  233 + $regs = pegaDados ( "select * from " . $esquemaadmin . "i3geoadmin_temas ", $dbh, false );
  234 +
  235 + $nomes = array ();
  236 + $ids = array ();
  237 + $dadosBanco = array ();
  238 + foreach ( $regs as $reg ) {
  239 + if ($convUTF != true) {
  240 + $reg ["nome_tema"] = utf8_decode ( $reg ["nome_tema"] );
  241 + }
  242 + $nomes [$reg ["codigo_tema"]] = $reg ["nome_tema"];
  243 + $ids [$reg ["codigo_tema"]] = $reg ["id_tema"];
  244 + $dadosBanco [$reg ["id_tema"]] = $reg;
  245 + }
  246 + $lista = array ();
  247 + foreach ( $arquivos as $arq ) {
  248 + $arq = $arq ["nome"];
  249 + $nT = explode ( ".", $arq );
  250 + $n = $nomes [$nT [0]];
  251 + if (! $n) {
  252 + $n = "";
  253 + }
  254 + $id = $ids [$nT [0]];
  255 + // o mapfile nao esta registrado no banco
  256 + if (! $id && empty ( $validar )) {
  257 + $id = "";
  258 + } else {
  259 + // aplica as validacoes. Se nao passar na validacao $id ficara vazio, para nao mostrar no resultado final
  260 + switch ($validar) {
  261 + case 1 :
  262 + if ($dadosBanco [$id] ["link_tema"] !== "") {
  263 + $id = "";
  264 + }
  265 + break;
  266 + case 2 :
  267 + if ($dadosBanco [$id] ["nome_tema"] == "") {
  268 + $id = "-";
  269 + } else {
  270 + $id = "";
  271 + }
  272 + break;
  273 + case 3 :
  274 + if ($dadosBanco [$id] ["nome_tema"] == "") {
  275 + $id = "";
  276 + }
  277 + break;
  278 + case 4 :
  279 + if (strtolower ( $dadosBanco [$id] ["download_tema"] ) !== "sim") {
  280 + $id = "";
  281 + }
  282 + break;
  283 + case 5 :
  284 + if (strtolower ( $dadosBanco [$id] ["download_tema"] ) !== "nao") {
  285 + $id = "";
  286 + }
  287 + break;
  288 + case 6 :
  289 + if (strtolower ( $dadosBanco [$id] ["ogc_tema"] ) !== "sim") {
  290 + $id = "";
  291 + }
  292 + break;
  293 + case 7 :
  294 + if (strtolower ( $dadosBanco [$id] ["ogc_tema"] ) !== "nao") {
  295 + $id = "";
  296 + }
  297 + break;
  298 + case 8 :
  299 + if (strtolower ( $dadosBanco [$id] ["kml_tema"] ) !== "sim") {
  300 + $id = "";
  301 + }
  302 + break;
  303 + case 9 :
  304 + if (strtolower ( $dadosBanco [$id] ["kml_tema"] ) !== "nao") {
  305 + $id = "";
  306 + }
  307 + break;
  308 + case 10 :
  309 + if (strtolower ( $dadosBanco [$id] ["kmz_tema"] ) !== "sim") {
  310 + $id = "";
  311 + }
  312 + break;
  313 + case 11 :
  314 + if (strtolower ( $dadosBanco [$id] ["kmz_tema"] ) !== "nao") {
  315 + $id = "";
  316 + }
  317 + break;
  318 + }
  319 + }
  320 + $imagem = "";
  321 + if (file_exists ( $locaplic . "/temas/miniaturas/" . $arq . ".map.mini.png" )) {
  322 + $imagem = $arq . ".map.mini.png";
  323 + }
  324 +
  325 + if ($validar == 12) {
  326 + if (file_exists ( $locaplic . "/temas/" . $arq . ".map" )) {
  327 + $handle = fopen ( $locaplic . "/temas/" . $arq . ".map", "r" );
  328 + while ( ! feof ( $handle ) ) {
  329 + $linha = fgets ( $handle );
  330 + if (stripos ( $linha, "'TEMA'" ) !== false || stripos ( $linha, '"TEMA"' ) !== false) {
  331 + $ntema = str_replace ( array (
  332 + "'TEMA'",
  333 + '"TEMA"',
  334 + "'tema'",
  335 + '"tema"'
  336 + ), "", $linha );
  337 + $ntema = trim ( str_replace ( array (
  338 + "'",
  339 + '"'
  340 + ), "", $ntema ) );
  341 + $temp = $n;
  342 + if ($n != $ntema && utf8_decode ( $temp ) != $ntema && $n != "") {
  343 + $n .= "<span style=color:red;margin-left:5px >" . utf8_encode ( $ntema ) . "</span>";
  344 + } else {
  345 + $n .= "<span style=color:lightslategray;margin-left:5px >" . utf8_encode ( $ntema ) . "</span>";
  346 + }
  347 + break;
  348 + }
  349 + }
  350 + fclose ( $handle );
  351 + }
  352 + }
  353 + if ($validar == 13) {
  354 + if (file_exists ( $locaplic . "/temas/" . $arq . ".map" )) {
  355 + $handle = fopen ( $locaplic . "/temas/" . $arq . ".map", "r" );
  356 + // deve buscar dentro de LAYER pois pode haver simbolos antes
  357 + $elayer = false;
  358 + while ( ! feof ( $handle ) ) {
  359 + $linha = trim ( fgets ( $handle ) );
  360 + if (stripos ( $linha, "LAYER" ) === 0) {
  361 + $elayer = true;
  362 + }
  363 + if ($elayer == true && stripos ( $linha, "NAME" ) === 0) {
  364 + $ntema = ltrim ( $linha, "NAMEname" );
  365 + $ntema = trim ( str_replace ( array (
  366 + "'",
  367 + '"'
  368 + ), "", $ntema ) );
  369 + if ($arq != $ntema) {
  370 + $n .= "<span style=color:red;margin-left:5px >" . $ntema . "</span>";
  371 + }
  372 + break;
  373 + }
  374 + }
  375 + fclose ( $handle );
  376 + }
  377 + }
  378 + // se id for vazio, nao consta no banco, por isso, se validar for definido, nao pode ser aplicado
  379 + if (empty ( $validar ) || (! empty ( $validar ) && $id != "")) {
  380 + $lista [] = array (
  381 + "id_tema" => $id,
  382 + "nome" => $n,
  383 + "codigo" => $arq,
  384 + "imagem" => $imagem,
  385 + "extensao" => ""
  386 + );
  387 + }
  388 + }
  389 + return $lista;
  390 +}
  391 +function listaUnico($dbh, $codigo) {
  392 + global $convUTF, $locaplic, $esquemaadmin;
  393 + if(!file_exists($locaplic."/temas/".$codigo.".map")){
  394 + header ( "HTTP/1.1 500 erro mapfile nao existe" );
  395 + exit ();
  396 + }
  397 + $mapa = ms_newMapObj ( $locaplic."/temas/".$codigo.".map" );
  398 + $layer = $mapa->getlayerbyname($codigo);
  399 + if($layer == ""){
  400 + header ( "HTTP/1.1 500 erro nao existe LAYER com o nome $codigo" );
  401 + exit ();
  402 + }
  403 + $titulolegenda = $layer->getmetadata("TEMA");
  404 + $metaestat = $layer->getmetadata("METAESTAT");
  405 + $dados = pegaDados ( "SELECT * from ".$esquemaadmin."i3geoadmin_temas WHERE codigo_tema = '$codigo' ", $dbh, false );
  406 + //se nao existir no sistema de admin, faz o registro
  407 + if(count($dados) == 0){
  408 + $dataCol = array (
  409 + "kml_tema" => "SIM",
  410 + "kmz_tema" => "SIM",
  411 + "ogc_tema" => "SIM",
  412 + "download_tema" => "SIM",
  413 + "desc_tema" => "",
  414 + "tipoa_tema" => "",
  415 + "tags_tema" => "",
  416 + "nome_tema" => $titulolegenda,
  417 + "codigo_tema" => $codigo,
  418 + "it" => "",
  419 + "es" => "",
  420 + "en" => ""
  421 + );
  422 + $id_tema = i3GeoAdminInsertUnico($dbhw,"i3geoadmin_temas",$dataCol,"link_tema","id_tema");
  423 + $dados = pegaDados ( "SELECT * from ".$esquemaadmin."i3geoadmin_temas WHERE codigo_tema = '$codigo' AND id_tema = $id_tema ", $dbh, false );
  424 + if(count($dados) == 0){
  425 + $dbhw = null;
  426 + $dbh = null;
  427 + header ( "HTTP/1.1 500 erro ao registrar no banco de dados" );
  428 + exit ();
  429 + }
  430 + }
  431 + if ($dados === false) {
  432 + $dbhw = null;
  433 + $dbh = null;
  434 + header ( "HTTP/1.1 500 erro ao consultar banco de dados" );
  435 + exit ();
  436 + }
  437 + $acessopublico = "";
  438 + if(strtolower($dados[0]["ogc_tema"]) !== "nao" || strtolower($dados[0]["download_tema"]) !== "nao"){
  439 + $acessopublico = "checked";
  440 + }
  441 + if($metaestat == ""){
  442 + $dados[0]["metaestatnao"] = "selected";
  443 + } else {
  444 + $dados[0]["metaestatsim"] = "selected";
  445 + }
  446 + $dados[0]["acessopublico"] = $acessopublico;
  447 + $dados[0]["metaestat"] = $metaestat;
  448 + //a pagina e utf e o texto pode ser iso
  449 + if(mb_detect_encoding($titulolegenda,'UTF-8, ISO-8859-1') == "ISO-8859-1"){
  450 + $titulolegenda = utf8_encode($titulolegenda);
  451 + }
  452 + $dados[0]["titulolegenda"] = $titulolegenda;
  453 + $dados[0]["codigo"] = $codigo;
  454 + return $dados[0];
  455 +}
  456 +function limpaCache($locaplic, $codigo, $cachedir, $dir_tmp){
  457 + $mapfile = $locaplic . "/temas/" . $codigo . ".map";
  458 + if (! file_exists ( $mapfile )) {
  459 + header ( "HTTP/1.1 403 arquivo nao existe" );
  460 + exit ();
  461 + }
  462 + $mapa = ms_newMapObj ( $mapfile );
  463 + $nomes = $mapa->getalllayernames ();
  464 + if ($cachedir != "") {
  465 + $d = $cachedir;
  466 + } else {
  467 + $d = $dir_tmp . "/cache";
  468 + }
  469 + foreach ( $nomes as $nome ) {
  470 + $nome = str_replace ( ".", "", $nome );
  471 + $nome = strip_tags ( $nome );
  472 + $nome = htmlspecialchars ( $nome, ENT_QUOTES );
  473 + $dirs [] = $d . "/" . $nome;
  474 + $dirs [] = $d . "/googlemaps/" . $nome;
  475 + $dirs [] = $d . "/wmts/" . $nome;
  476 + foreach ( $dirs as $dir ) {
  477 + \admin\catalogo\mapfile\rrmdir ( $dir );
  478 + }
  479 + }
  480 + $nome = $nomes[0];
  481 + if(file_exists($d . "/" . $nome) || file_exists($d . "/googlemaps/" . $nome) || file_exists($d . "/wmts/" . $nome)){
  482 + header ( "HTTP/1.1 403 cache nao removido" );
  483 + exit;
  484 + } else {
  485 + return true;
  486 + }
  487 +}
  488 +function clonarMapfile($codigo,$novocodigo,$titulo,$dbh,$dbhw){
  489 + global $esquemaadmin;
  490 + $arq = $locaplic . "/temas/" . $codigo . ".map";
  491 + $arqnovo = $locaplic . "/temas/" . $novocodigo . ".map";
  492 +
  493 + if ($codigo == "" || !file_exists ( $arq )) {
  494 + header ( "HTTP/1.1 400 arquivo nao existe" );
  495 + exit ();
  496 + }
  497 + if ($novocodigo == "" || file_exists ( $arqnovo )) {
  498 + header ( "HTTP/1.1 400 arquivo ja existe" );
  499 + exit ();
  500 + }
  501 + //obtem os dados do banco do tema existente
  502 + $dados = pegaDados ( "SELECT * from " . $esquemaadmin . "i3geoadmin_temas WHERE codigo_tema = '" . $codigo . "'", $dbh, false );
  503 + if (count ( $dados ) > 0) {
  504 + //o mapfile esta registrado como um tema no banco de adm
  505 + $dataCol = array (
  506 + "link_tema" => $dados [0] ["link_tema"],
  507 + "kml_tema" => $dados [0] ["kml_tema"],
  508 + "kmz_tema" => $dados [0] ["kmz_tema"],
  509 + "ogc_tema" => $dados [0] ["ogc_tema"],
  510 + "download_tema" => $dados [0] ["download_tema"],
  511 + "desc_tema" => "",
  512 + "tipoa_tema" => $dados [0] ["tipoa_tema"],
  513 + "tags_tema" => '',
  514 + "nome_tema" => $_POST["titulo"],
  515 + "codigo_tema" => $novocodigo,
  516 + "it" => "",
  517 + "es" => "",
  518 + "en" => ""
  519 + );
  520 + $acessopublico = $dados [0] ["download_tema"];
  521 + } else {
  522 + $acessopublico = "";
  523 + }
  524 + //faz a copia do mapfile
  525 + $mapa = ms_newMapObj($arq);
  526 + $layer = @$mapa->getlayerbyname($codigo);
  527 + $layer->set("name",$novocodigo);
  528 + $layer->setmetadata("TEMA",$titulo);
  529 + $mapa->save($arqnovo);
  530 + include(dirname(__FILE__)."/../../php/removeCabecalhoMapfile.php");
  531 + removeCabecalhoMapfile($arqnovo);
  532 + if (count ( $dados ) > 0) {
  533 + //registra no banco de dados caso nao tenha ocorrido erro ao criar o mapfile
  534 + i3GeoAdminInsert ( $dbhw, "i3geoadmin_temas", $dataCol );
  535 + }
  536 +}
  537 +function rrmdir($dir) {
  538 + if (is_dir ( $dir )) {
  539 + $objects = scandir ( $dir );
  540 + foreach ( $objects as $object ) {
  541 + if ($object != "." && $object != "..") {
  542 + if (filetype ( $dir . "/" . $object ) == "dir") {
  543 + \admin\catalogo\mapfile\rrmdir ( $dir . "/" . $object );
  544 + } else {
  545 + $object = str_replace ( ".png", "", $object ) . ".png";
  546 + chmod ( $dir . "/" . $object, 077 );
  547 + unlink ( $dir . "/" . $object );
  548 + }
  549 + }
  550 + }
  551 + reset ( $objects );
  552 + }
  553 +}
  554 +?>
0 \ No newline at end of file 555 \ No newline at end of file
admin1/catalogo/mapfile/index.js
@@ -124,7 +124,6 @@ Obt&amp;eacute;m a lista @@ -124,7 +124,6 @@ Obt&amp;eacute;m a lista
124 .done( 124 .done(
125 function(data, status){ 125 function(data, status){
126 var json = jQuery.parseJSON(data); 126 var json = jQuery.parseJSON(data);
127 -  
128 var html = Mustache.to_html( 127 var html = Mustache.to_html(
129 "{{#data}}" + $("#templateManterTema").html() + "{{/data}}", 128 "{{#data}}" + $("#templateManterTema").html() + "{{/data}}",
130 $.extend( 129 $.extend(
@@ -231,9 +230,8 @@ Obt&amp;eacute;m a lista @@ -231,9 +230,8 @@ Obt&amp;eacute;m a lista
231 .done( 230 .done(
232 function(data, status){ 231 function(data, status){
233 i3GEOadmin.core.modalAguarde(false); 232 i3GEOadmin.core.modalAguarde(false);
234 - var json = jQuery.parseJSON(data);  
235 - $("#form-" + json.codigo).remove();  
236 - i3GEOadmin.mapfile.registraFavoritos(json.codigo); 233 + i3GEOadmin.mapfile.registraFavoritos(id);
  234 + i3GEOadmin.mapfile.lista("","");
237 } 235 }
238 ) 236 )
239 .fail( 237 .fail(
@@ -282,7 +280,7 @@ Obt&amp;eacute;m a lista @@ -282,7 +280,7 @@ Obt&amp;eacute;m a lista
282 codigo = i3GEOadmin.mapfile.favoritosArray[i]; 280 codigo = i3GEOadmin.mapfile.favoritosArray[i];
283 h = $("#form-" + codigo).html(); 281 h = $("#form-" + codigo).html();
284 if(h != undefined){ 282 if(h != undefined){
285 - conteudo.push(h); 283 + conteudo.push(h+"&nbsp;");
286 } 284 }
287 } 285 }
288 $("#body-favoritos").html(conteudo.join("\n")); 286 $("#body-favoritos").html(conteudo.join("\n"));
admin1/catalogo/mapfile/preview/index.php
@@ -6,6 +6,37 @@ if(verificaOperacaoSessao(&quot;admin/php/editortexto&quot;) == false){ @@ -6,6 +6,37 @@ if(verificaOperacaoSessao(&quot;admin/php/editortexto&quot;) == false){
6 } 6 }
7 7
8 8
  9 +//calcula resolucoes
  10 +$res = array();
  11 +$temp = 0.703125;
  12 +for($i = 0; $i < 40; $i++){
  13 + $res[] = $temp;
  14 + $temp = $temp / 2;
  15 +}
  16 +$top_left_minx = -180;
  17 +$top_left_maxy = 90;
  18 +
  19 +$x_size = $res[$_GET["TileMatrix"] - 1] * 256;
  20 +$y_size = $x_size;
  21 +
  22 +$lon1 = $top_left_minx + ($_GET["TileCol"] * $x_size);
  23 +$lat1 = $top_left_maxy - ($_GET["TileRow"] * $y_size) - $y_size;
  24 +$lon2 = $top_left_minx + ($_GET["TileCol"] * $x_size) + $x_size;
  25 +$lat2 = $top_left_maxy - ($_GET["TileRow"] * $y_size);
  26 +
  27 +$_GET["WIDTH"] = 256;
  28 +$_GET["HEIGHT"] = 256;
  29 +
  30 +$_GET["tms"] = "/wmts/".$tema."/".$_GET["TileMatrix"]."/".$_GET["TileCol"]."/".$_GET["TileRow"];
  31 +$_GET["tms"] = str_replace(".png","",$_GET["tms"]).".png";
  32 +
  33 +if($_GET["TileMatrix"]."/".$_GET["TileCol"]."/".$_GET["TileRow"] == "0/0/0" || $_GET["TileCol"] == -1 || $_GET["TileRow"]== -1){
  34 + return;
  35 +}
  36 +$_GET["BBOX"] = $lon1.",".$lat1.",".$lon2.",".$lat2;
  37 +$_GET["SERVICE"] = "WMS";
  38 +$_GET["REQUEST"] = "getMap";
  39 +
9 // 40 //
10 //pega os endere&ccedil;os para compor a url de chamada do gerador de web services 41 //pega os endere&ccedil;os para compor a url de chamada do gerador de web services
11 //ogc.php 42 //ogc.php
@@ -15,6 +46,7 @@ $protocolo = $protocolo[0]; @@ -15,6 +46,7 @@ $protocolo = $protocolo[0];
15 $protocolo1 = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME']; 46 $protocolo1 = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'];
16 $protocolo = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'] .":". $_SERVER['SERVER_PORT']; 47 $protocolo = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'] .":". $_SERVER['SERVER_PORT'];
17 $urli3geo = str_replace("/ogc.php","",$protocolo.$_SERVER["PHP_SELF"]); 48 $urli3geo = str_replace("/ogc.php","",$protocolo.$_SERVER["PHP_SELF"]);
  49 +
18 // 50 //
19 //cria o web service 51 //cria o web service
20 // 52 //
@@ -44,17 +76,15 @@ foreach ($_GET as $k=&gt;$v){ @@ -44,17 +76,15 @@ foreach ($_GET as $k=&gt;$v){
44 } 76 }
45 } 77 }
46 $tema = $locaplic . "/temas/" . $_GET["tema"] . ".map"; 78 $tema = $locaplic . "/temas/" . $_GET["tema"] . ".map";
  79 +
47 if(!file_exists($tema)){ 80 if(!file_exists($tema)){
48 echo "Erro"; 81 echo "Erro";
49 exit; 82 exit;
50 } 83 }
51 $req->setParameter("srsName",$req->getValueByName("SRS")); 84 $req->setParameter("srsName",$req->getValueByName("SRS"));
52 $listaepsg = $req->getValueByName("SRS")." EPSG:4618 EPSG:4291 EPSG:4326 EPSG:22521 EPSG:22522 EPSG:22523 EPSG:22524 EPSG:22525 EPSG:29101 EPSG:29119 EPSG:29120 EPSG:29121 EPSG:29122 EPSG:29177 EPSG:29178 EPSG:29179 EPSG:29180 EPSG:29181 EPSG:29182 EPSG:29183 EPSG:29184 EPSG:29185"; 85 $listaepsg = $req->getValueByName("SRS")." EPSG:4618 EPSG:4291 EPSG:4326 EPSG:22521 EPSG:22522 EPSG:22523 EPSG:22524 EPSG:22525 EPSG:29101 EPSG:29119 EPSG:29120 EPSG:29121 EPSG:29122 EPSG:29177 EPSG:29178 EPSG:29179 EPSG:29180 EPSG:29181 EPSG:29182 EPSG:29183 EPSG:29184 EPSG:29185";
53 -if(isset($_GET["version"]) && !isset($VERSION)){  
54 - $_GET["VERSION"] = $_GET["version"];  
55 -}  
56 -$req->setParameter("VeRsIoN",$_GET["VERSION"]);  
57 86
  87 +$req->setParameter("VeRsIoN",$_GET["Version"]);
58 // 88 //
59 //compatibiliza chamadas fora do padrao 89 //compatibiliza chamadas fora do padrao
60 // 90 //
@@ -94,7 +124,6 @@ $nmap = ms_newMapobj($tema); @@ -94,7 +124,6 @@ $nmap = ms_newMapobj($tema);
94 $nmap->setmetadata("ows_enable_request","*"); 124 $nmap->setmetadata("ows_enable_request","*");
95 $l = $nmap->getlayer(0); 125 $l = $nmap->getlayer(0);
96 126
97 -  
98 //$l->setmetadata("ows_title",pegaNome($l)); 127 //$l->setmetadata("ows_title",pegaNome($l));
99 $l->setmetadata("ows_srs",$listaepsg); 128 $l->setmetadata("ows_srs",$listaepsg);
100 $l->set("group",""); 129 $l->set("group","");
@@ -152,6 +181,8 @@ if(ob_get_contents ()){ @@ -152,6 +181,8 @@ if(ob_get_contents ()){
152 cloneInlineSymbol($l,$nmap,$oMap); 181 cloneInlineSymbol($l,$nmap,$oMap);
153 182
154 $l = $oMap->getlayer(0); 183 $l = $oMap->getlayer(0);
  184 +$l->set("status",MS_DEFAULT);
  185 +
155 $req->setParameter("LAYERS",$l->name); 186 $req->setParameter("LAYERS",$l->name);
156 187
157 if(strtolower($req->getValueByName("REQUEST")) == "getfeatureinfo"){ 188 if(strtolower($req->getValueByName("REQUEST")) == "getfeatureinfo"){
@@ -167,7 +198,7 @@ ms_ioinstallstdouttobuffer(); @@ -167,7 +198,7 @@ ms_ioinstallstdouttobuffer();
167 $req->setParameter("format","image/png"); 198 $req->setParameter("format","image/png");
168 $oMap->owsdispatch($req); 199 $oMap->owsdispatch($req);
169 $contenttype = ms_iostripstdoutbuffercontenttype(); 200 $contenttype = ms_iostripstdoutbuffercontenttype();
170 -$oMap->save("/tmp/ms_tmp/teste.map"); 201 +
171 if(!isset($OUTPUTFORMAT)){ 202 if(!isset($OUTPUTFORMAT)){
172 header("Content-type: $contenttype"); 203 header("Content-type: $contenttype");
173 } 204 }
admin1/catalogo/mapfile/templates/templateLista.php
@@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
27 </a> 27 </a>
28 <span class="pull-right">&nbsp;&nbsp;</span> 28 <span class="pull-right">&nbsp;&nbsp;</span>
29 29
30 - &nbsp;<strong>{{{nome}}}</strong> <small> {{{arquivoTxt}}}:</small> {{{codigo}}} 30 + &nbsp;<div style="min-width:250px;" class="pull-left"><strong>{{{codigo}}}</strong></div> <small> {{{nome}}}</small>
31 </h4> 31 </h4>
32 </div> 32 </div>
33 <div class="list-group-separator"></div> 33 <div class="list-group-separator"></div>
admin1/head.php
@@ -6,8 +6,7 @@ @@ -6,8 +6,7 @@
6 <meta http-equiv='X-UA-Compatible' content='IE=edge'> 6 <meta http-equiv='X-UA-Compatible' content='IE=edge'>
7 <meta name='viewport' content='width=device-width, initial-scale=1'> 7 <meta name='viewport' content='width=device-width, initial-scale=1'>
8 <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> 8 <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
9 -<meta name='description'  
10 - content='Interface Integrada para Internet de ferramentas de geoprocessamento'> 9 +<meta name='description' content='Interface Integrada para Internet de ferramentas de geoprocessamento'>
11 <meta name='author' content='i3Geo'> 10 <meta name='author' content='i3Geo'>
12 <title>i3Geo</title> 11 <title>i3Geo</title>
13 <?php 12 <?php
@@ -81,7 +80,6 @@ hr { @@ -81,7 +80,6 @@ hr {
81 80
82 .material-icons.md-18 { 81 .material-icons.md-18 {
83 font-size: 18px; 82 font-size: 18px;
84 -  
85 } 83 }
86 84
87 body { 85 body {
@@ -142,7 +140,8 @@ body { @@ -142,7 +140,8 @@ body {
142 position: unset; 140 position: unset;
143 } 141 }
144 142
145 -.navbar .dropdown-menu li>a, .navbar.navbar-default .dropdown-menu li>a { 143 +.navbar .dropdown-menu li>a, .navbar.navbar-default .dropdown-menu li>a
  144 + {
146 font-size: 1em; 145 font-size: 1em;
147 } 146 }
148 147
@@ -221,7 +220,8 @@ a, a:focus, a:hover { @@ -221,7 +220,8 @@ a, a:focus, a:hover {
221 color: #767676; 220 color: #767676;
222 } 221 }
223 222
224 -.form-group.form-group-lg .checkbox label, .form-group.form-group-lg .radio label, .form-group.form-group-lg label { 223 +.form-group.form-group-lg .checkbox label, .form-group.form-group-lg .radio label,
  224 + .form-group.form-group-lg label {
225 color: #767676; 225 color: #767676;
226 } 226 }
227 227
@@ -229,7 +229,6 @@ h2 small { @@ -229,7 +229,6 @@ h2 small {
229 color: #767676; 229 color: #767676;
230 } 230 }
231 231
232 -  
233 .migalha { 232 .migalha {
234 background-color: rgb(255, 255, 255); 233 background-color: rgb(255, 255, 255);
235 border-bottom-width: 0px; 234 border-bottom-width: 0px;
@@ -324,38 +323,37 @@ h2 small { @@ -324,38 +323,37 @@ h2 small {
324 .btn-breadcrumb > *:nth-child(n+2) { 323 .btn-breadcrumb > *:nth-child(n+2) {
325 display:none; 324 display:none;
326 } 325 }
327 -  
328 /* === For phones =================================== */ 326 /* === For phones =================================== */
329 -@media (max-width: 767px) {  
330 - .btn-breadcrumb > *:nth-last-child(-n+2) {  
331 - display:block;  
332 - }  
333 - .btn-breadcrumb > * div {  
334 - max-width: 60px;  
335 - } 327 +@media ( max-width : 767px) {
  328 + .btn-breadcrumb>*:nth-last-child(-n+2) {
  329 + display: block;
  330 + }
  331 + .btn-breadcrumb>* div {
  332 + max-width: 60px;
  333 + }
336 } 334 }
337 335
338 /* === For tablets ================================== */ 336 /* === For tablets ================================== */
339 -@media (min-width: 768px) and (max-width:991px) {  
340 - .btn-breadcrumb > *:nth-last-child(-n+4) {  
341 - display:block;  
342 - }  
343 - .btn-breadcrumb > * div {  
344 - max-width: 100px;  
345 - } 337 +@media ( min-width : 768px) and (max-width:991px) {
  338 + .btn-breadcrumb>*:nth-last-child(-n+4) {
  339 + display: block;
  340 + }
  341 + .btn-breadcrumb>* div {
  342 + max-width: 100px;
  343 + }
346 } 344 }
347 345
348 /* === For desktops ================================== */ 346 /* === For desktops ================================== */
349 -@media (min-width: 992px) {  
350 - .btn-breadcrumb > *:nth-last-child(-n+6) {  
351 - display:block;  
352 - }  
353 - .btn-breadcrumb > * div {  
354 - max-width: 170px;  
355 - } 347 +@media ( min-width : 992px) {
  348 + .btn-breadcrumb>*:nth-last-child(-n+6) {
  349 + display: block;
  350 + }
  351 + .btn-breadcrumb>* div {
  352 + max-width: 170px;
  353 + }
356 } 354 }
357 355
358 -.btn-breadcrumb a:not([style*="pointer-events: none"]) > span { 356 +.btn-breadcrumb a:not ([style*="pointer-events: none"] ) >span {
359 text-decoration: underline; 357 text-decoration: underline;
360 } 358 }
361 </style> 359 </style>
@@ -375,23 +373,24 @@ h2 small { @@ -375,23 +373,24 @@ h2 small {
375 </script> 373 </script>
376 374
377 <body style="padding-top: 55px;" id="topo"> 375 <body style="padding-top: 55px;" id="topo">
378 - <nav class="navbar navbar-default navbar-fixed-top" style="margin-bottom: 0px;max-height:55px;height:55px;"> 376 + <nav class="navbar navbar-default navbar-fixed-top" style="margin-bottom: 0px; max-height: 55px; height: 55px;">
379 <div class="container-fluid"> 377 <div class="container-fluid">
380 <div class="navbar-header"> 378 <div class="navbar-header">
381 - <button title="icon bar" type="button" class="navbar-toggle collapsed" data-toggle="collapse"  
382 - data-target="#navbar" aria-expanded="false" aria-controls="navbar">  
383 - <span class="sr-only"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span  
384 - class="icon-bar"></span> 379 + <button title="icon bar" type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
  380 + <span class="sr-only"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span>
385 </button> 381 </button>
386 - <a class="navbar-brand" href="<?php echo ONDEI3GEO; ?>/init/index.php"><?php echo $mensagemInicia;?> <i  
387 - class="material-icons">home</i></a> 382 + <a class="navbar-brand" href="<?php echo ONDEI3GEO; ?>/init/index.php"><?php echo $mensagemInicia;?> <i class="material-icons">home</i>
  383 + </a>
388 </div> 384 </div>
389 <div id="navbar" class="navbar-collapse collapse navbar-responsive-collapse"> 385 <div id="navbar" class="navbar-collapse collapse navbar-responsive-collapse">
390 <ul class="nav navbar-nav" id="menuPrincipalTpl"> 386 <ul class="nav navbar-nav" id="menuPrincipalTpl">
391 </ul> 387 </ul>
392 <ul class="nav navbar-nav"> 388 <ul class="nav navbar-nav">
393 - <li class="dropdown"><a role="button" onclick="i3GEO.login.recarrega = true; i3GEO.login.dialogo.abreLogin('<?php echo ONDEI3GEO; ?>','template_mst_bt.html');"  
394 - href="#topo" data-toggle="modal" data-target="#modalLogin">Login <i id="loginOff" style="display:none;" class="material-icons md-18">lock</i><i id="loginOn" style="display:none;" class="material-icons md-18">lock_open</i></a> 389 + <li class="dropdown">
  390 + <a role="button" onclick="i3GEO.login.recarrega = true; i3GEO.login.dialogo.abreLogin('<?php echo ONDEI3GEO; ?>','template_mst_bt.html');" href="#topo" data-toggle="modal"
  391 + data-target="#modalLogin">
  392 + Login <i id="loginOff" style="display: none;" class="material-icons md-18">lock</i><i id="loginOn" style="display: none;" class="material-icons md-18">lock_open</i>
  393 + </a>
395 </li> 394 </li>
396 </ul> 395 </ul>
397 </div> 396 </div>
@@ -406,7 +405,7 @@ h2 small { @@ -406,7 +405,7 @@ h2 small {
406 <span aria-hidden="true">&times;</span> 405 <span aria-hidden="true">&times;</span>
407 </button> 406 </button>
408 </div> 407 </div>
409 - <div class="modal-body modal-lg" style=height:200px > 408 + <div class="modal-body modal-lg" style="height: 200px">
410 <!-- aqui entra o filtro --> 409 <!-- aqui entra o filtro -->
411 <div class="form-group"> 410 <div class="form-group">
412 <select title="{{{filtro}}}" title="{{{filtro}}}" onchange="i3GEOadmin.core.filtra(this)" id="filtro" class="form-control input-lg"> 411 <select title="{{{filtro}}}" title="{{{filtro}}}" onchange="i3GEOadmin.core.filtra(this)" id="filtro" class="form-control input-lg">
@@ -452,9 +451,7 @@ h2 small { @@ -452,9 +451,7 @@ h2 small {
452 <span aria-hidden="true">&times;</span> 451 <span aria-hidden="true">&times;</span>
453 </button> 452 </button>
454 </div> 453 </div>
455 - <div class="modal-body" id="i3GEOF_loginusuario">  
456 -  
457 - </div> 454 + <div class="modal-body" id="i3GEOF_loginusuario"></div>
458 </div> 455 </div>
459 </div> 456 </div>
460 </div> 457 </div>
admin1/index.php
@@ -46,7 +46,8 @@ include &quot;head.php&quot;; @@ -46,7 +46,8 @@ include &quot;head.php&quot;;
46 <script type="text/javascript" src="js/core.js"></script> 46 <script type="text/javascript" src="js/core.js"></script>
47 <script src="dicionario/principal.js"></script> 47 <script src="dicionario/principal.js"></script>
48 <script> 48 <script>
49 - $(document).ready(function(){ 49 + var inicia = function() {
  50 + i3GEOadmin.core.loginOn();
50 core_parseMustacheBody(i3GEOadmin.principal.dicionario); 51 core_parseMustacheBody(i3GEOadmin.principal.dicionario);
51 //vem de admin1/index.js 52 //vem de admin1/index.js
52 iniciaMenuPrincipal(); 53 iniciaMenuPrincipal();
@@ -58,7 +59,8 @@ include &quot;head.php&quot;; @@ -58,7 +59,8 @@ include &quot;head.php&quot;;
58 }); 59 });
59 $(".hidden").removeClass('hidden'); 60 $(".hidden").removeClass('hidden');
60 $.material.init(); 61 $.material.init();
61 - }); 62 + };
  63 + i3GEO.login.verificaOperacao("admin/html/identifica",i3GEO.configura.locaplic, inicia, "sessao" ,i3GEOadmin.core.erroLogin);
62 </script> 64 </script>
63 </body> 65 </body>
64 </html> 66 </html>
temas/_lbiomashp.map
1 -MAP  
2 - FONTSET "../symbols/fontes.txt"  
3 - SYMBOLSET "../symbols/simbolosv6.sym"  
4 - LAYER  
5 - CONNECTION ""  
6 - DATA "/var/www/i3geo/aplicmap/dados/biomas.shp"  
7 - METADATA  
8 - "TIP" "CD_LEGENDA"  
9 - "cache" "SIM"  
10 - "CLASSE" "sim"  
11 - "temporizador" ""  
12 - "permitekmz" "SIM"  
13 - "ITENSDESC" "Teste de acentuação"  
14 - "TILES" "SIM"  
15 - "ESCALA" "1000000"  
16 - "extensao" "-73.990940816816 -33.74827031115 -34.822855820777 5.272224303909"  
17 - "permitedownload" "SIM"  
18 - "permitecomentario" "NAO"  
19 - "escondido" "NAO"  
20 - "download" "SIM"  
21 - "itembuscarapida" "CD_LEGENDA"  
22 - "ITENS" "CD_LEGENDA"  
23 - "permitekml" "SIM"  
24 - "permiteogc" "SIM"  
25 - "transitioneffect" "NAO"  
26 - "TEMA" "Biomas shapefile (acentuação)"  
27 - "identifica" "sim"  
28 - "aplicaextensao" "NAO"  
29 - END # METADATA  
30 - NAME "_lbiomashp"  
31 - PROCESSING "ITEMS=CD_LEGENDA"  
32 - PROCESSING "LABEL_NO_CLIP=True"  
33 - PROCESSING "POLYLINE_NO_CLIP=True"  
34 - STATUS DEFAULT  
35 - TEMPLATE "none.htm"  
36 - TILEITEM "location"  
37 - OPACITY 90  
38 - TYPE POLYGON  
39 - UNITS METERS  
40 - CLASS  
41 - NAME "CAATINGA"  
42 - EXPRESSION ('[CD_LEGENDA]'eq'CAATINGA')  
43 - STYLE  
44 - COLOR 183 247 169  
45 - OUTLINECOLOR 255 255 255  
46 - END # STYLE  
47 - TITLE ""  
48 - END # CLASS  
49 - CLASS  
50 - NAME "PAMPA area > 5"  
51 - EXPRESSION ('[CD_LEGENDA]'eq'PAMPA area > 5')  
52 - STYLE  
53 - COLOR 239 22 152  
54 - OUTLINECOLOR 255 255 255  
55 - END # STYLE  
56 - TITLE ""  
57 - END # CLASS  
58 - CLASS  
59 - NAME "CERRADO"  
60 - EXPRESSION ('[CD_LEGENDA]'eq'CERRADO')  
61 - STYLE  
62 - COLOR 57 32 234  
63 - OUTLINECOLOR 255 255 255  
64 - END # STYLE  
65 - TITLE ""  
66 - END # CLASS  
67 - CLASS  
68 - NAME "PANTANAL"  
69 - EXPRESSION ('[CD_LEGENDA]'eq'PANTANAL')  
70 - STYLE  
71 - COLOR 214 107 232  
72 - OUTLINECOLOR 255 255 255  
73 - END # STYLE  
74 - TITLE ""  
75 - END # CLASS  
76 - CLASS  
77 - NAME "AMAZÔNIA"  
78 - EXPRESSION ('[CD_LEGENDA]'eq'AMAZÔNIA')  
79 - STYLE  
80 - COLOR 0 177 0  
81 - OUTLINECOLOR 255 255 255  
82 - END # STYLE  
83 - TITLE ""  
84 - END # CLASS  
85 - CLASS  
86 - NAME "MATA ATLÂNTICA"  
87 - EXPRESSION ('[CD_LEGENDA]'eq'MATA ATLÂNTICA')  
88 - STYLE  
89 - COLOR 44 215 49  
90 - OUTLINECOLOR 255 255 255  
91 - END # STYLE  
92 - TITLE ""  
93 - END # CLASS  
94 - END # LAYER  
95 -  
96 -END # MAP  
97 - 1 +MAP
  2 + FONTSET "../symbols/fontes.txt"
  3 + SYMBOLSET "../symbols/simbolosv6.sym"
  4 + LAYER
  5 + CONNECTION ""
  6 + DATA "/var/www/i3geo/aplicmap/dados/biomas.shp"
  7 + METADATA
  8 + "TIP" "CD_LEGENDA"
  9 + "cache" "SIM"
  10 + "CLASSE" "sim"
  11 + "permitekmz" "SIM"
  12 + "ITENSDESC" "Teste de acentuação"
  13 + "TILES" "SIM"
  14 + "ESCALA" "1000000"
  15 + "extensao" "-73.990940816816 -33.74827031115 -34.822855820777 5.272224303909"
  16 + "permitedownload" "SIM"
  17 + "permitecomentario" "NAO"
  18 + "escondido" "NAO"
  19 + "download" "SIM"
  20 + "itembuscarapida" "CD_LEGENDA"
  21 + "ITENS" "CD_LEGENDA"
  22 + "permitekml" "SIM"
  23 + "permiteogc" "SIM"
  24 + "transitioneffect" "NAO"
  25 + "TEMA" "Biomas shapefile (acentuação)"
  26 + "identifica" "sim"
  27 + "aplicaextensao" "NAO"
  28 + END # METADATA
  29 + NAME "_lbiomashp"
  30 + PROCESSING "ITEMS=CD_LEGENDA"
  31 + PROCESSING "LABEL_NO_CLIP=True"
  32 + PROCESSING "POLYLINE_NO_CLIP=True"
  33 + STATUS DEFAULT
  34 + TEMPLATE "none.htm"
  35 + TILEITEM "location"
  36 + OPACITY 90
  37 + TYPE POLYGON
  38 + UNITS METERS
  39 + CLASS
  40 + NAME "CAATINGA"
  41 + EXPRESSION ('[CD_LEGENDA]'eq'CAATINGA')
  42 + STYLE
  43 + COLOR 183 247 169
  44 + OUTLINECOLOR 255 255 255
  45 + END # STYLE
  46 + TITLE ""
  47 + END # CLASS
  48 + CLASS
  49 + NAME "PAMPA area > 5"
  50 + EXPRESSION ('[CD_LEGENDA]'eq'PAMPA area > 5')
  51 + STYLE
  52 + COLOR 239 22 152
  53 + OUTLINECOLOR 255 255 255
  54 + END # STYLE
  55 + TITLE ""
  56 + END # CLASS
  57 + CLASS
  58 + NAME "CERRADO"
  59 + EXPRESSION ('[CD_LEGENDA]'eq'CERRADO')
  60 + STYLE
  61 + COLOR 57 32 234
  62 + OUTLINECOLOR 255 255 255
  63 + END # STYLE
  64 + TITLE ""
  65 + END # CLASS
  66 + CLASS
  67 + NAME "PANTANAL"
  68 + EXPRESSION ('[CD_LEGENDA]'eq'PANTANAL')
  69 + STYLE
  70 + COLOR 214 107 232
  71 + OUTLINECOLOR 255 255 255
  72 + END # STYLE
  73 + TITLE ""
  74 + END # CLASS
  75 + CLASS
  76 + NAME "AMAZÔNIA"
  77 + EXPRESSION ('[CD_LEGENDA]'eq'AMAZÔNIA')
  78 + STYLE
  79 + COLOR 0 177 0
  80 + OUTLINECOLOR 255 255 255
  81 + END # STYLE
  82 + TITLE ""
  83 + END # CLASS
  84 + CLASS
  85 + NAME "MATA ATLÂNTICA"
  86 + EXPRESSION ('[CD_LEGENDA]'eq'MATA ATLÂNTICA')
  87 + STYLE
  88 + COLOR 44 215 49
  89 + OUTLINECOLOR 255 255 255
  90 + END # STYLE
  91 + TITLE ""
  92 + END # CLASS
  93 + END # LAYER
  94 +END # MAP
98 \ No newline at end of file 95 \ No newline at end of file
temas/teste.map
@@ -1,49 +0,0 @@ @@ -1,49 +0,0 @@
1 -MAP  
2 - FONTSET "../symbols/fontes.txt"  
3 - SYMBOLSET "../symbols/simbolos.sym"  
4 - LAYER  
5 - DATA "/var/www/i3geo/aplicmap/dados/mundo"  
6 - GROUP ""  
7 - METADATA  
8 - "TIP" "FIPS_CNTRY,GMI_CNTRY,CNTRY_NAME"  
9 - "cache" "nao"  
10 - "olopacity" "100"  
11 - "CLASSE" "SIM"  
12 - "ITENSDESC" "FIPS,GMI,Nome,Wikipedia"  
13 - "ITENSLINK" ",,,http://pt.wikipedia.org/wiki/[CNTRY_NAME]"  
14 - "TITULO" "Países do mundo"  
15 - "olstatus" "OFF"  
16 - "itembuscarapida" "LONG_NAME"  
17 - "ITENS" "FIPS_CNTRY,GMI_CNTRY,LONG_NAME,CNTRY_NAME"  
18 - "TEMA" "grafico de Países do mundo"  
19 - "permitedownload" "nao"  
20 - "download" "nao"  
21 - END # METADATA  
22 - NAME "teste"  
23 - PROCESSING "LABEL_NO_CLIP=True"  
24 - PROCESSING "POLYLINE_NO_CLIP=True"  
25 - PROCESSING "CHART_TYPE=PIE"  
26 - PROCESSING "CHART_SIZE=50"  
27 - STATUS DEFAULT  
28 - TEMPLATE "none.htm"  
29 - TILEITEM "location"  
30 - TYPE CHART  
31 - UNITS METERS  
32 - CLASS  
33 - NAME "SQKM"  
34 - STYLE  
35 - COLOR 75 43 106  
36 - OUTLINECOLOR 0 0 0  
37 - SIZE [SQKM]  
38 - END # STYLE  
39 - END # CLASS  
40 - CLASS  
41 - NAME "SQMI"  
42 - STYLE  
43 - COLOR 108 251 237  
44 - OUTLINECOLOR 0 0 0  
45 - SIZE [SQMI]  
46 - END # STYLE  
47 - END # CLASS  
48 - END # LAYER  
49 -END