function processaPluginI3geo() { global $locaplic, $layer; $c = $layer->getmetadata("PLUGINI3GEO"); if ($c != "") { $cs = json_decode($c, true); if ($cs["plugin"] == "parametrossql") { $data = $layer->data; $cs = $cs["parametros"]; $chaves = array(); foreach ($cs as $c) { $chaves[] = $c["chave"]; } $chaves = implode(",", $chaves); $filtro = $layer->getFilterString(); $chaves = str_ireplace(array(" and ", " or ", "select", "from", "where", "update", "delete", "insert", "--"), "", $chaves); $chaves = explode(",", $chaves); $n = count($chaves); //a variavel $plugin vem da URL e contem os valores //que devem ser substituidos //se $plugin for vazio, usa o primeiro valor definido na configuracao do plugin //A ordem dos valores deve ser exatamente a ordem das chaves if (empty($plugin)) { $plugin = array(); foreach ($cs as $c) { if ($c["chave"] != "") { //valores definidos no plugin como uma string if ($c["valores"] != "") { $temp = explode(",", $c["valores"]); $plugin[] = $temp[0]; } elseif ($c["prog"] != "") { $plugin[] = execProg($c["prog"]); } } } $plugin = implode(",", $plugin); } $layer->setmetadata("TEMA", $layer->getmetadata("TEMA") . " - " . $plugin); $valores = str_ireplace(array(" and ", " or ", "select", "from", "where", "update", "delete", "insert", "--"), "", $plugin); $valores = explode(",", strip_tags($valores)); for ($i = 0; $i < $n; $i++) { if ($chaves[$i] != "") { $v = $valores[$i]; $data = str_replace($chaves[$i], $v, $data); if ($filtro != "") { $filtro = str_replace($chaves[$i], $v, $filtro); } } } if ($filtro != "") { $layer->setfilter($filtro); } $layer->set("data", $data); } } }
$chaves = explode(",", $chaves); $n = count($chaves); //a variavel $plugin vem da URL e contem os valores //que devem ser substituidos //se $plugin for vazio, usa o primeiro valor definido na configuracao do plugin //A ordem dos valores deve ser exatamente a ordem das chaves if (empty($plugin)) { $plugin = array(); foreach ($cs as $c) { if ($c["chave"] != "") { //valores definidos no plugin como uma string if ($c["valores"] != "") { $temp = explode(",", $c["valores"]); $plugin[] = $temp[0]; } elseif ($c["prog"] != "") { $plugin[] = execProg($c["prog"]); } } } $plugin = implode(",", $plugin); } $l->setmetadata("TEMA", $l->getmetadata("TEMA") . " - " . $plugin); $valores = str_ireplace(array(" and ", " or ", "select", "from", "where", "update", "delete", "insert", "--"), "", $plugin); $valores = explode(",", strip_tags($valores)); for ($i = 0; $i < $n; $i++) { if ($chaves[$i] != "") { $v = $valores[$i]; $data = str_replace($chaves[$i], $v, $data); if ($filtro != "") { $filtro = str_replace($chaves[$i], $v, $filtro); }