Commit 4ca2a1cbb000cf03707cb65cbd456387bb39146b
1 parent
df8dbdd2
Exists in
master
and in
6 other branches
Modificações na função de geração do mapfile, baseado no sistema de metadados es…
…tatísticos, para evitar passagem de parâmetros inválidos na criação do SQL
Showing
2 changed files
with
26 additions
and
6 deletions
Show diff stats
classesphp/metaestat_controle.php
| @@ -198,7 +198,6 @@ switch (strtoupper($funcao)) { | @@ -198,7 +198,6 @@ switch (strtoupper($funcao)) { | ||
| 198 | break; | 198 | break; |
| 199 | case "MAPFILEMEDIDAVARIAVEL": | 199 | case "MAPFILEMEDIDAVARIAVEL": |
| 200 | // $filtro usa aspas duplas para enviar os parametros | 200 | // $filtro usa aspas duplas para enviar os parametros |
| 201 | - $_pg["filtro"] = str_replace('"', "'", $_pg["filtro"]); | ||
| 202 | $m = new MetaestatInfo(); | 201 | $m = new MetaestatInfo(); |
| 203 | if (! isset($_pg["codigo_tipo_regiao"])) { | 202 | if (! isset($_pg["codigo_tipo_regiao"])) { |
| 204 | $_pg["codigo_tipo_regiao"] = ""; | 203 | $_pg["codigo_tipo_regiao"] = ""; |
| @@ -211,6 +210,25 @@ switch (strtoupper($funcao)) { | @@ -211,6 +210,25 @@ switch (strtoupper($funcao)) { | ||
| 211 | } else { | 210 | } else { |
| 212 | $_pg["cachemapfile"] = true; | 211 | $_pg["cachemapfile"] = true; |
| 213 | } | 212 | } |
| 213 | + //valida o filtro | ||
| 214 | + | ||
| 215 | + if(!empty($_pg["filtro"])){ | ||
| 216 | + $_pg["filtro"] = str_replace('"', "'", $_pg["filtro"]); | ||
| 217 | + $final = array(); | ||
| 218 | + $sepands = explode("|",$_pg["filtro"]); | ||
| 219 | + foreach($sepands as $sepand){ | ||
| 220 | + $linhas = explode("*",$sepand); | ||
| 221 | + if(!is_numeric(str_replace(array("'",","),"",$linhas[1]))){ | ||
| 222 | + exit; | ||
| 223 | + } | ||
| 224 | + if(count(explode(",",$linhas[1])) == 1){ | ||
| 225 | + $final[] = $linhas[0]." = ". $linhas[1]; | ||
| 226 | + } else { | ||
| 227 | + $final[] = $linhas[0]." IN (".$linhas[1].")"; | ||
| 228 | + } | ||
| 229 | + } | ||
| 230 | + $_pg["filtro"] = implode(" and ", $final); | ||
| 231 | + } | ||
| 214 | if ($_pg["formato"] == "json") { | 232 | if ($_pg["formato"] == "json") { |
| 215 | retornaJSON($m->mapfileMedidaVariavel($_pg["id_medida_variavel"], $_pg["filtro"], $_GET["todasascolunas"], $_GET["tipolayer"], $_GET["titulolayer"], $_pg["id_classificacao"], $_GET["agruparpor"], $_pg["codigo_tipo_regiao"], $_GET["opacidade"], false, $_GET["cachemapfile"])); | 233 | retornaJSON($m->mapfileMedidaVariavel($_pg["id_medida_variavel"], $_pg["filtro"], $_GET["todasascolunas"], $_GET["tipolayer"], $_GET["titulolayer"], $_pg["id_classificacao"], $_GET["agruparpor"], $_pg["codigo_tipo_regiao"], $_GET["opacidade"], false, $_GET["cachemapfile"])); |
| 216 | } | 234 | } |
ferramentas/metaestat/index.js
| @@ -583,7 +583,8 @@ i3GEOF.metaestat = { | @@ -583,7 +583,8 @@ i3GEOF.metaestat = { | ||
| 583 | } | 583 | } |
| 584 | }; | 584 | }; |
| 585 | if(v != true){ | 585 | if(v != true){ |
| 586 | - i3GEO.janela.tempoMsg("erro: "+v); | 586 | + i3GEOF.metaestat.comum.aguarde("hidden"); |
| 587 | + i3GEO.janela.tempoMsg("erro: "+v); | ||
| 587 | return; | 588 | return; |
| 588 | } | 589 | } |
| 589 | //e necessario obter os parametros nessa interface | 590 | //e necessario obter os parametros nessa interface |
| @@ -696,18 +697,20 @@ i3GEOF.metaestat = { | @@ -696,18 +697,20 @@ i3GEOF.metaestat = { | ||
| 696 | c = $i("comboparametro_"+dados[i].id_parametro_medida+"_"+dados[i].id_pai); | 697 | c = $i("comboparametro_"+dados[i].id_parametro_medida+"_"+dados[i].id_pai); |
| 697 | if(c){ | 698 | if(c){ |
| 698 | if(c.value != "" && i3GEOF.metaestat.MULTIPARAMETROS === false){ | 699 | if(c.value != "" && i3GEOF.metaestat.MULTIPARAMETROS === false){ |
| 699 | - t.push(dados[i].coluna+'="'+c.value+'"'); | 700 | + //t.push(dados[i].coluna+'="'+c.value+'"'); |
| 701 | + t.push(dados[i].coluna+'*"'+c.value+'"'); | ||
| 700 | } | 702 | } |
| 701 | else{ | 703 | else{ |
| 702 | val = i3GEO.util.valoresCheckCombo(c.id); | 704 | val = i3GEO.util.valoresCheckCombo(c.id); |
| 703 | if(val.length > 0){ | 705 | if(val.length > 0){ |
| 704 | - t.push(dados[i].coluna+' IN ("'+val.join('","')+'")'); | 706 | + //t.push(dados[i].coluna+' IN ("'+val.join('","')+'")'); |
| 707 | + t.push(dados[i].coluna+' * "'+val.join('","')+'"'); | ||
| 705 | } | 708 | } |
| 706 | } | 709 | } |
| 707 | } | 710 | } |
| 708 | } | 711 | } |
| 709 | if(t.length > 0){ | 712 | if(t.length > 0){ |
| 710 | - return t.join(" and "); | 713 | + return t.join("|"); |
| 711 | } | 714 | } |
| 712 | else{ | 715 | else{ |
| 713 | return ""; | 716 | return ""; |
| @@ -1414,7 +1417,6 @@ i3GEOF.metaestat = { | @@ -1414,7 +1417,6 @@ i3GEOF.metaestat = { | ||
| 1414 | var temp = function(dados){ | 1417 | var temp = function(dados){ |
| 1415 | i3GEOF.metaestat.parametros.dados = dados; | 1418 | i3GEOF.metaestat.parametros.dados = dados; |
| 1416 | i3GEOF.metaestat.parametros.combos("0"); | 1419 | i3GEOF.metaestat.parametros.combos("0"); |
| 1417 | - i3GEOF.metaestat.comum.aguarde("hidden"); | ||
| 1418 | }; | 1420 | }; |
| 1419 | i3GEO.php.listaParametrosMedidaVariavel(id_medida_variavel,temp); | 1421 | i3GEO.php.listaParametrosMedidaVariavel(id_medida_variavel,temp); |
| 1420 | }, | 1422 | }, |