From 0165c046e603b47feba159b0e49e3a8837a71a47 Mon Sep 17 00:00:00 2001 From: Edmar Moretti Date: Wed, 31 Aug 2016 19:01:44 -0300 Subject: [PATCH] Ativacao da funcao parametrossql e correção no endereço da aplicação no testamapfile.php --- aplicmap/dados/listaano.php | 1 + classesphp/sani_request.php | 4 +--- ferramentas/parametrossql/exec.php | 31 ++++++++++++++++--------------- ferramentas/parametrossql/ogc.php | 23 ++++++++++++++--------- json.php | 11 +++++++++-- ogc.php | 33 +++++++++++++++++++-------------- testamapfile.php | 2 +- 7 files changed, 61 insertions(+), 44 deletions(-) diff --git a/aplicmap/dados/listaano.php b/aplicmap/dados/listaano.php index 855a190..ae2a4f4 100755 --- a/aplicmap/dados/listaano.php +++ b/aplicmap/dados/listaano.php @@ -26,4 +26,5 @@ $retorno = array( "v" => "1990" ) ); +echo json_encode($retorno); ?> \ No newline at end of file diff --git a/classesphp/sani_request.php b/classesphp/sani_request.php index 9bd0511..fc2eaff 100755 --- a/classesphp/sani_request.php +++ b/classesphp/sani_request.php @@ -3,7 +3,7 @@ if (basename(__FILE__) == basename($_SERVER['SCRIPT_FILENAME'])){ exit; } error_reporting(0); -$bl = array("password","select","_decode","php","eval","passthru","shell_exec","escapeshellarg","escapeshellcmd","proc_close","proc_open","dl","popen","contents","delete","drop","update","insert","exec","system",";"); +$bl = array("exec ","exec(","password","select","_decode","passthru","shell_exec","escapeshellarg","escapeshellcmd","proc_close","proc_open","dl","popen","contents","delete","drop","update","insert","system",";"); if (isset($_GET)){ foreach(array_keys($_GET) as $k) { $k = str_ireplace($bl,"",$k); @@ -16,7 +16,6 @@ if (isset($_GET)){ } } //array(3) { ["cpaint_function"]=> string(8) "criaMapa" ["cpaint_argument"]=> array(1) { [0]=> string(54) ""funcao=criaMapa&&desligar=mundo&interface=openlayers"" } ["cpaint_response_type"]=> string(4) "JSON" } - if (isset($_POST)){ if (isset($_POST["cpaint_argument"]) && $_POST["cpaint_argument"][0] != "") { @@ -28,7 +27,6 @@ if (isset($_POST)){ else{ $argumento_ = str_replace("\"","",$argumento_); } - $argumento_ = explode('"',$argumento_); $argumento_ = implode("&",$argumento_); $parametros_ = explode("&",$argumento_); diff --git a/ferramentas/parametrossql/exec.php b/ferramentas/parametrossql/exec.php index 65d0330..23f9b7a 100755 --- a/ferramentas/parametrossql/exec.php +++ b/ferramentas/parametrossql/exec.php @@ -1,6 +1,7 @@ diff --git a/ferramentas/parametrossql/ogc.php b/ferramentas/parametrossql/ogc.php index 457aa2d..dba1338 100755 --- a/ferramentas/parametrossql/ogc.php +++ b/ferramentas/parametrossql/ogc.php @@ -1,5 +1,4 @@ data; + $data = $l->data; $c = $l->getmetadata("PLUGINI3GEO"); if($c != ""){ $cs = json_decode($c,true); @@ -167,7 +168,6 @@ else{ } $chaves = implode(",",$chaves); $filtro = $l->getFilterString(); - $chaves = str_ireplace(array(" and ", " or ", "select","from","where","update","delete","insert","--"),"",$chaves); $chaves = explode(",",$chaves); $n = count($chaves); @@ -185,7 +185,7 @@ else{ $plugin[] = $temp[0]; } elseif ($c["prog"] != ""){ - $plugin[] = execProg($locaplic."/".$c["prog"]); + $plugin[] = execProg($c["prog"]); } } } @@ -206,7 +206,6 @@ else{ if($filtro != ""){ $l->setfilter($filtro); } - $l->set("data",$data); //acrecenta-se um md5 apos o nome caso seja necessario gerar cache if($cache == true){ @@ -577,11 +576,17 @@ function salvaCacheImagem($cachedir,$map,$tms, $plugin, $tema){ exit; } function execProg($prog){ - $prog = str_replace(".php","",$prog); - $prog = str_replace(".","",$prog).".php"; - include($prog); //$retorno variavel deve ser retornada pelo programa $prog //veja como exemplo i3geo/aplicmap/daods/listaano.php + global $urli3geo; + $u = str_replace("/ferramentas/parametrossql","",$urli3geo); + $handle = curl_init(); + curl_setopt( $handle, CURLOPT_URL, $u."/".$prog); + curl_setopt( $handle, CURLOPT_HEADER, false ); + curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); + $str = curl_exec( $handle ); + curl_close( $handle ); + $retorno = json_decode($str,true); return $retorno[0]["v"]; } ?> diff --git a/json.php b/json.php index fe48c1d..7f3085e 100755 --- a/json.php +++ b/json.php @@ -440,7 +440,7 @@ function processaPluginI3geo(){ $plugin[] = $temp[0]; } elseif ($c["prog"] != ""){ - $plugin[] = execProg($locaplic."/".$c["prog"]); + $plugin[] = execProg($c["prog"]); } } } @@ -467,9 +467,16 @@ function processaPluginI3geo(){ } //utilizada para obter os dados default quando se utiliza o plugin parametrossql function execProg($prog){ - include($prog); //$retorno variavel deve ser retornada pelo programa $prog //veja como exemplo i3geo/aplicmap/daods/listaano.php + global $urli3geo; + $handle = curl_init(); + curl_setopt( $handle, CURLOPT_URL, $urli3geo."/".$prog); + curl_setopt( $handle, CURLOPT_HEADER, false ); + curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); + $str = curl_exec( $handle ); + curl_close( $handle ); + $retorno = json_decode($str,true); return $retorno[0]["v"]; } function converteenc($texto){ diff --git a/ogc.php b/ogc.php index 353f8d8..a34bef0 100755 --- a/ogc.php +++ b/ogc.php @@ -78,6 +78,7 @@ ogc.php?tema=/var/www/i3geo/aplicmap/geral1debianv6.map&layers=mundo */ include(dirname(__FILE__)."/classesphp/sani_request.php"); +include_once (dirname(__FILE__)."/classesphp/carrega_ext.php"); include(dirname(__FILE__)."/ms_configura.php"); $_GET = array_merge($_GET,$_POST); @@ -768,7 +769,6 @@ else{ $oMap->setSymbolSet($locaplic."/symbols/".basename($oMap->symbolsetfilename)); $oMap->setFontSet($locaplic."/symbols/".basename($oMap->fontsetfilename)); //verifica se existem layers com plugin definido e processa conforme o tipo de plugin - processaPluginI3geo(); // //caso seja download ou json ou csv @@ -1455,7 +1455,7 @@ function exportaCsv(){ $linhas[] = implode(",",$items).",wkt"; } for ($i = 0; $i < $res_count; $i++){ - if($versao == 6){ + if($versao >= 6){ $shape = $layer->getShape($layer->getResult($i)); } else{ @@ -1497,7 +1497,7 @@ function exportaGeojson(){ $features = array(); for ($i = 0; $i < $res_count; $i++){ - if($versao == 6){ + if($versao >= 6){ $shape = $layer->getShape($layer->getResult($i)); } else{ @@ -1540,14 +1540,13 @@ function converteenc($texto){ } function processaPluginI3geo(){ global $oMap, $locaplic; - return; $numlayers = $oMap->numlayers; for ($i=0;$i < $numlayers;$i++){ - $l = $oMap->getlayer($i); - $c = $l->getmetadata("PLUGINI3GEO"); + $l = $oMap->getlayer($i); + $c = $l->getmetadata("PLUGINI3GEO"); if($c != ""){ $cs = json_decode($c,true); - if($cs["plugin"] == "parametrossql"){ + if($cs["plugin"] == "parametrossql"){ $data = $l->data; $cs = $cs["parametros"]; $chaves = array(); @@ -1572,8 +1571,8 @@ function processaPluginI3geo(){ $temp = explode(",",$c["valores"]); $plugin[] = $temp[0]; } - elseif ($c["prog"] != ""){ - $plugin[] = execProg($locaplic."/".$c["prog"]); + elseif ($c["prog"] != ""){ + $plugin[] = execProg($c["prog"]); } } } @@ -1593,7 +1592,7 @@ function processaPluginI3geo(){ } if($filtro != ""){ $l->setfilter($filtro); - } + } $l->set("data",$data); } } @@ -1601,10 +1600,16 @@ function processaPluginI3geo(){ } //utilizada para obter os dados default quando se utiliza o plugin parametrossql function execProg($prog){ - return; - include($prog); - //$retorno variavel deve ser retornada pelo programa $prog - //veja como exemplo i3geo/aplicmap/daods/listaano.php + //$retorno variavel deve ser retornada pelo programa $prog + //veja como exemplo i3geo/aplicmap/daods/listaano.php + global $urli3geo; + $handle = curl_init(); + curl_setopt( $handle, CURLOPT_URL, $urli3geo."/".$prog); + curl_setopt( $handle, CURLOPT_HEADER, false ); + curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); + $str = curl_exec( $handle ); + curl_close( $handle ); + $retorno = json_decode($str,true); return $retorno[0]["v"]; } ?> diff --git a/testamapfile.php b/testamapfile.php index 443e45f..b58b47e 100755 --- a/testamapfile.php +++ b/testamapfile.php @@ -104,7 +104,7 @@ if ($tipo == "") echo ''; echo ''; echo ''; -- libgit2 0.21.2