Commit 0165c046e603b47feba159b0e49e3a8837a71a47

Authored by Edmar Moretti
1 parent 21d5d2f1

Ativacao da funcao parametrossql e correção no endereço da aplicação no testamapfile.php

aplicmap/dados/listaano.php
... ... @@ -26,4 +26,5 @@ $retorno = array(
26 26 "v" => "1990"
27 27 )
28 28 );
  29 +echo json_encode($retorno);
29 30 ?>
30 31 \ No newline at end of file
... ...
classesphp/sani_request.php
... ... @@ -3,7 +3,7 @@ if (basename(__FILE__) == basename($_SERVER['SCRIPT_FILENAME'])){
3 3 exit;
4 4 }
5 5 error_reporting(0);
6   -$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",";");
  6 +$bl = array("exec ","exec(","password","select","_decode","passthru","shell_exec","escapeshellarg","escapeshellcmd","proc_close","proc_open","dl","popen","contents","delete","drop","update","insert","system",";");
7 7 if (isset($_GET)){
8 8 foreach(array_keys($_GET) as $k) {
9 9 $k = str_ireplace($bl,"",$k);
... ... @@ -16,7 +16,6 @@ if (isset($_GET)){
16 16 }
17 17 }
18 18 //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" }
19   -
20 19 if (isset($_POST)){
21 20 if (isset($_POST["cpaint_argument"]) && $_POST["cpaint_argument"][0] != "")
22 21 {
... ... @@ -28,7 +27,6 @@ if (isset($_POST)){
28 27 else{
29 28 $argumento_ = str_replace("\"","",$argumento_);
30 29 }
31   -
32 30 $argumento_ = explode('"',$argumento_);
33 31 $argumento_ = implode("&",$argumento_);
34 32 $parametros_ = explode("&",$argumento_);
... ...
ferramentas/parametrossql/exec.php
1 1 <?php
2   -exit;
3   -include_once(dirname(__FILE__)."/../inicia.php");
  2 +include(dirname(__FILE__)."/../safe.php");
  3 +verificaBlFerramentas(basename(dirname(__FILE__)),$i3geoBlFerramentas,false);
  4 +$tema = basename($_GET["tema"]);
4 5 //
5 6 //faz a busca da fun&ccedil;&atilde;o que deve ser executada
6 7 //
... ... @@ -130,19 +131,19 @@ switch (strtoupper($funcao))
130 131 * Utilizado para pegar a lista de valores que sera apresentada ao usuario
131 132 */
132 133 case "INCLUDEPROG":
133   - //evita redirecoina o programa para algum lugar indevido
134   - $prog = str_replace(".php","",$prog);
135   - $prog = str_replace(".","",$prog).".php";
136   - if(file_exists($locaplic."/".$prog)){
137   - include($locaplic."/".$prog);
138   - }
  134 + $protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']);
  135 + $protocolo = $protocolo[0];
  136 + $protocolo1 = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'];
  137 + $protocolo = strtolower($protocolo) . '://'.$_SERVER['SERVER_NAME'] .":". $_SERVER['SERVER_PORT'];
  138 + $urli3geo = str_replace("/ferramentas/parametrossql/exec.php","",$protocolo.$_SERVER["PHP_SELF"]);
  139 + $handle = curl_init();
  140 + curl_setopt( $handle, CURLOPT_URL, $urli3geo."/".$_GET["prog"]);
  141 + curl_setopt( $handle, CURLOPT_HEADER, false );
  142 + curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
  143 + $retorno = curl_exec( $handle );
  144 + curl_close( $handle );
  145 + $retorno = json_decode($retorno,true);
139 146 break;
140 147 }
141   -if (!connection_aborted()){
142   - cpjson($retorno);
143   -}
144   -else{
145   - exit();
146   -}
147   -
  148 +cpjson($retorno);
148 149 ?>
... ...
ferramentas/parametrossql/ogc.php
1 1 <?php
2   -exit;
3 2 /**
4 3 Esse programa e uma adaptacao do codigo i3geo/ogc.php
5 4 E utilizado no mashup (i3geo/mashup) nas camadas que sao configuradas cm o plugin parametrossql
... ... @@ -9,10 +8,12 @@ A diferenca e que esse servico processa o parametro &quot;plugin&quot;, aplicando os filtr
9 8 no plugin parametrossql
10 9 */
11 10 $cache = true;
12   -include(dirname(__FILE__)."/classesphp/sani_request.php");
  11 +include(dirname(__FILE__)."/../../classesphp/sani_request.php");
  12 +include_once (dirname(__FILE__)."/../../classesphp/carrega_ext.php");
13 13 include(dirname(__FILE__)."/../../ms_configura.php");
14 14 include(dirname(__FILE__)."/../../classesphp/funcoes_gerais.php");
15 15 $_GET = array_merge($_GET,$_POST);
  16 +$plugin = $_GET["plugin"];
16 17 $projDefault = pegaProjecaoDefault();
17 18  
18 19 $tema = basename($_GET["tema"]);
... ... @@ -156,7 +157,7 @@ else{
156 157 }
157 158 }
158 159 //aplica os parametros especificos do plugin
159   - $data = $l->data;
  160 + $data = $l->data;
160 161 $c = $l->getmetadata("PLUGINI3GEO");
161 162 if($c != ""){
162 163 $cs = json_decode($c,true);
... ... @@ -167,7 +168,6 @@ else{
167 168 }
168 169 $chaves = implode(",",$chaves);
169 170 $filtro = $l->getFilterString();
170   -
171 171 $chaves = str_ireplace(array(" and ", " or ", "select","from","where","update","delete","insert","--"),"",$chaves);
172 172 $chaves = explode(",",$chaves);
173 173 $n = count($chaves);
... ... @@ -185,7 +185,7 @@ else{
185 185 $plugin[] = $temp[0];
186 186 }
187 187 elseif ($c["prog"] != ""){
188   - $plugin[] = execProg($locaplic."/".$c["prog"]);
  188 + $plugin[] = execProg($c["prog"]);
189 189 }
190 190 }
191 191 }
... ... @@ -206,7 +206,6 @@ else{
206 206 if($filtro != ""){
207 207 $l->setfilter($filtro);
208 208 }
209   -
210 209 $l->set("data",$data);
211 210 //acrecenta-se um md5 apos o nome caso seja necessario gerar cache
212 211 if($cache == true){
... ... @@ -577,11 +576,17 @@ function salvaCacheImagem($cachedir,$map,$tms, $plugin, $tema){
577 576 exit;
578 577 }
579 578 function execProg($prog){
580   - $prog = str_replace(".php","",$prog);
581   - $prog = str_replace(".","",$prog).".php";
582   - include($prog);
583 579 //$retorno variavel deve ser retornada pelo programa $prog
584 580 //veja como exemplo i3geo/aplicmap/daods/listaano.php
  581 + global $urli3geo;
  582 + $u = str_replace("/ferramentas/parametrossql","",$urli3geo);
  583 + $handle = curl_init();
  584 + curl_setopt( $handle, CURLOPT_URL, $u."/".$prog);
  585 + curl_setopt( $handle, CURLOPT_HEADER, false );
  586 + curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
  587 + $str = curl_exec( $handle );
  588 + curl_close( $handle );
  589 + $retorno = json_decode($str,true);
585 590 return $retorno[0]["v"];
586 591 }
587 592 ?>
... ...
json.php
... ... @@ -440,7 +440,7 @@ function processaPluginI3geo(){
440 440 $plugin[] = $temp[0];
441 441 }
442 442 elseif ($c["prog"] != ""){
443   - $plugin[] = execProg($locaplic."/".$c["prog"]);
  443 + $plugin[] = execProg($c["prog"]);
444 444 }
445 445 }
446 446 }
... ... @@ -467,9 +467,16 @@ function processaPluginI3geo(){
467 467 }
468 468 //utilizada para obter os dados default quando se utiliza o plugin parametrossql
469 469 function execProg($prog){
470   - include($prog);
471 470 //$retorno variavel deve ser retornada pelo programa $prog
472 471 //veja como exemplo i3geo/aplicmap/daods/listaano.php
  472 + global $urli3geo;
  473 + $handle = curl_init();
  474 + curl_setopt( $handle, CURLOPT_URL, $urli3geo."/".$prog);
  475 + curl_setopt( $handle, CURLOPT_HEADER, false );
  476 + curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
  477 + $str = curl_exec( $handle );
  478 + curl_close( $handle );
  479 + $retorno = json_decode($str,true);
473 480 return $retorno[0]["v"];
474 481 }
475 482 function converteenc($texto){
... ...
ogc.php
... ... @@ -78,6 +78,7 @@ ogc.php?tema=/var/www/i3geo/aplicmap/geral1debianv6.map&amp;layers=mundo
78 78  
79 79 */
80 80 include(dirname(__FILE__)."/classesphp/sani_request.php");
  81 +include_once (dirname(__FILE__)."/classesphp/carrega_ext.php");
81 82 include(dirname(__FILE__)."/ms_configura.php");
82 83 $_GET = array_merge($_GET,$_POST);
83 84  
... ... @@ -768,7 +769,6 @@ else{
768 769 $oMap->setSymbolSet($locaplic."/symbols/".basename($oMap->symbolsetfilename));
769 770 $oMap->setFontSet($locaplic."/symbols/".basename($oMap->fontsetfilename));
770 771 //verifica se existem layers com plugin definido e processa conforme o tipo de plugin
771   -
772 772 processaPluginI3geo();
773 773 //
774 774 //caso seja download ou json ou csv
... ... @@ -1455,7 +1455,7 @@ function exportaCsv(){
1455 1455 $linhas[] = implode(",",$items).",wkt";
1456 1456 }
1457 1457 for ($i = 0; $i < $res_count; $i++){
1458   - if($versao == 6){
  1458 + if($versao >= 6){
1459 1459 $shape = $layer->getShape($layer->getResult($i));
1460 1460 }
1461 1461 else{
... ... @@ -1497,7 +1497,7 @@ function exportaGeojson(){
1497 1497  
1498 1498 $features = array();
1499 1499 for ($i = 0; $i < $res_count; $i++){
1500   - if($versao == 6){
  1500 + if($versao >= 6){
1501 1501 $shape = $layer->getShape($layer->getResult($i));
1502 1502 }
1503 1503 else{
... ... @@ -1540,14 +1540,13 @@ function converteenc($texto){
1540 1540 }
1541 1541 function processaPluginI3geo(){
1542 1542 global $oMap, $locaplic;
1543   - return;
1544 1543 $numlayers = $oMap->numlayers;
1545 1544 for ($i=0;$i < $numlayers;$i++){
1546   - $l = $oMap->getlayer($i);
1547   - $c = $l->getmetadata("PLUGINI3GEO");
  1545 + $l = $oMap->getlayer($i);
  1546 + $c = $l->getmetadata("PLUGINI3GEO");
1548 1547 if($c != ""){
1549 1548 $cs = json_decode($c,true);
1550   - if($cs["plugin"] == "parametrossql"){
  1549 + if($cs["plugin"] == "parametrossql"){
1551 1550 $data = $l->data;
1552 1551 $cs = $cs["parametros"];
1553 1552 $chaves = array();
... ... @@ -1572,8 +1571,8 @@ function processaPluginI3geo(){
1572 1571 $temp = explode(",",$c["valores"]);
1573 1572 $plugin[] = $temp[0];
1574 1573 }
1575   - elseif ($c["prog"] != ""){
1576   - $plugin[] = execProg($locaplic."/".$c["prog"]);
  1574 + elseif ($c["prog"] != ""){
  1575 + $plugin[] = execProg($c["prog"]);
1577 1576 }
1578 1577 }
1579 1578 }
... ... @@ -1593,7 +1592,7 @@ function processaPluginI3geo(){
1593 1592 }
1594 1593 if($filtro != ""){
1595 1594 $l->setfilter($filtro);
1596   - }
  1595 + }
1597 1596 $l->set("data",$data);
1598 1597 }
1599 1598 }
... ... @@ -1601,10 +1600,16 @@ function processaPluginI3geo(){
1601 1600 }
1602 1601 //utilizada para obter os dados default quando se utiliza o plugin parametrossql
1603 1602 function execProg($prog){
1604   - return;
1605   - include($prog);
1606   - //$retorno variavel deve ser retornada pelo programa $prog
1607   - //veja como exemplo i3geo/aplicmap/daods/listaano.php
  1603 + //$retorno variavel deve ser retornada pelo programa $prog
  1604 + //veja como exemplo i3geo/aplicmap/daods/listaano.php
  1605 + global $urli3geo;
  1606 + $handle = curl_init();
  1607 + curl_setopt( $handle, CURLOPT_URL, $urli3geo."/".$prog);
  1608 + curl_setopt( $handle, CURLOPT_HEADER, false );
  1609 + curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
  1610 + $str = curl_exec( $handle );
  1611 + curl_close( $handle );
  1612 + $retorno = json_decode($str,true);
1608 1613 return $retorno[0]["v"];
1609 1614 }
1610 1615 ?>
... ...
testamapfile.php
... ... @@ -104,7 +104,7 @@ if ($tipo == &quot;&quot;)
104 104 echo '<script>';
105 105 echo 'function roda(){window.location.href = "?map="+document.getElementById("nomemap").value;}';
106 106 echo 'function rodaTabela(){window.location.href = window.location.href+"&tabela";}';
107   - echo 'i3GEO.configura.locaplic = i3GEO.util.protocolo() + "://" + window.location.host + "/i3geo";';
  107 + echo 'i3GEO.configura.locaplic = i3GEO.util.protocolo() + "://" + window.location.host + "/'.basename(dirname(__FILE__)).'";';
108 108 echo '</script>';
109 109 echo '<script src="admin/js/core.js"></script>';
110 110 echo '<script src="admin/dicionario/core.js"></script>';
... ...