From 4ca2a1cbb000cf03707cb65cbd456387bb39146b Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Fri, 8 Dec 2017 10:54:49 -0200 Subject: [PATCH] Modificações na função de geração do mapfile, baseado no sistema de metadados estatísticos, para evitar passagem de parâmetros inválidos na criação do SQL --- classesphp/metaestat_controle.php | 20 +++++++++++++++++++- ferramentas/metaestat/index.js | 12 +++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/classesphp/metaestat_controle.php b/classesphp/metaestat_controle.php index f18f2c2..ca0bfd4 100755 --- a/classesphp/metaestat_controle.php +++ b/classesphp/metaestat_controle.php @@ -198,7 +198,6 @@ switch (strtoupper($funcao)) { break; case "MAPFILEMEDIDAVARIAVEL": // $filtro usa aspas duplas para enviar os parametros - $_pg["filtro"] = str_replace('"', "'", $_pg["filtro"]); $m = new MetaestatInfo(); if (! isset($_pg["codigo_tipo_regiao"])) { $_pg["codigo_tipo_regiao"] = ""; @@ -211,6 +210,25 @@ switch (strtoupper($funcao)) { } else { $_pg["cachemapfile"] = true; } + //valida o filtro + + if(!empty($_pg["filtro"])){ + $_pg["filtro"] = str_replace('"', "'", $_pg["filtro"]); + $final = array(); + $sepands = explode("|",$_pg["filtro"]); + foreach($sepands as $sepand){ + $linhas = explode("*",$sepand); + if(!is_numeric(str_replace(array("'",","),"",$linhas[1]))){ + exit; + } + if(count(explode(",",$linhas[1])) == 1){ + $final[] = $linhas[0]." = ". $linhas[1]; + } else { + $final[] = $linhas[0]." IN (".$linhas[1].")"; + } + } + $_pg["filtro"] = implode(" and ", $final); + } if ($_pg["formato"] == "json") { 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"])); } diff --git a/ferramentas/metaestat/index.js b/ferramentas/metaestat/index.js index 77c699c..f4bd639 100755 --- a/ferramentas/metaestat/index.js +++ b/ferramentas/metaestat/index.js @@ -583,7 +583,8 @@ i3GEOF.metaestat = { } }; if(v != true){ - i3GEO.janela.tempoMsg("erro: "+v); + i3GEOF.metaestat.comum.aguarde("hidden"); + i3GEO.janela.tempoMsg("erro: "+v); return; } //e necessario obter os parametros nessa interface @@ -696,18 +697,20 @@ i3GEOF.metaestat = { c = $i("comboparametro_"+dados[i].id_parametro_medida+"_"+dados[i].id_pai); if(c){ if(c.value != "" && i3GEOF.metaestat.MULTIPARAMETROS === false){ - t.push(dados[i].coluna+'="'+c.value+'"'); + //t.push(dados[i].coluna+'="'+c.value+'"'); + t.push(dados[i].coluna+'*"'+c.value+'"'); } else{ val = i3GEO.util.valoresCheckCombo(c.id); if(val.length > 0){ - t.push(dados[i].coluna+' IN ("'+val.join('","')+'")'); + //t.push(dados[i].coluna+' IN ("'+val.join('","')+'")'); + t.push(dados[i].coluna+' * "'+val.join('","')+'"'); } } } } if(t.length > 0){ - return t.join(" and "); + return t.join("|"); } else{ return ""; @@ -1414,7 +1417,6 @@ i3GEOF.metaestat = { var temp = function(dados){ i3GEOF.metaestat.parametros.dados = dados; i3GEOF.metaestat.parametros.combos("0"); - i3GEOF.metaestat.comum.aguarde("hidden"); }; i3GEO.php.listaParametrosMedidaVariavel(id_medida_variavel,temp); }, -- libgit2 0.21.2