set_data(importarXmlWS()); $cp->return_data(); break; } /* Function: alterarWS Altera o registro de um WS */ function alterarWS() { global $id_ws,$desc_ws,$nome_ws,$link_ws,$autor_ws,$tipo_ws; try { require_once("conexao.php"); //$nome = mb_convert_encoding($nome,"UTF-8","ISO-8859-1"); //$desc = mb_convert_encoding($desc,"UTF-8","ISO-8859-1"); //$autor = mb_convert_encoding($autor,"UTF-8","ISO-8859-1"); if($id_ws != "") { $dbhw->query("UPDATE i3geoadmin_ws SET desc_ws = '$desc_ws',nome_ws = '$nome_ws', link_ws = '$link_ws', autor_ws = '$autor_ws', tipo_ws = '$tipo_ws' WHERE id_ws = $id_ws"); $retorna = $id_ws; } else { $dbhw->query("INSERT INTO i3geoadmin_ws (nome_ws,desc_ws,autor_ws,tipo_ws,link_ws) VALUES ('','','','','')"); $id = $dbhw->query("SELECT id_ws FROM i3geoadmin_ws"); $id = $id->fetchAll(); $id = intval($id[count($id)-1]['id_ws']); $retorna = $id; } $dbhw = null; $dbh = null; return $retorna; } catch (PDOException $e) { return "Error!: " . $e->getMessage(); } } function excluirWS() { global $id; try { include("conexao.php"); $dbhw->query("DELETE from i3geoadmin_ws WHERE id_ws = $id"); $dbhw = null; $dbh = null; return "ok"; } catch (PDOException $e) { return "Error!: " . $e->getMessage(); } } function importarXmlWS() { global $xml,$tipo; if(!file_exists($xml)) {return "
Arquivo $xml não encontrado";} include_once("../../classesphp/funcoes_gerais.php"); include("conexao.php"); $xml = simplexml_load_file($xml); // //importa os grupos // $wsExistentes = array(); $q = $dbhw->query("select * from i3geoadmin_ws"); $resultado = $q->fetchAll(); foreach($resultado as $r) {$wsExistentes[$r["nome_ws"]] = 0;} foreach($xml->channel as $c) { foreach($c->item as $item) { $descricao = ixml($item,"description"); $nome = ixml($item,"title"); $autor = ixml($item,"author"); $link = ixml($item,"link"); if(!isset($wsExistentes[$nome])) $dbhw->query("INSERT INTO i3geoadmin_ws (nome_ws,desc_ws,autor_ws,link_ws,tipo_ws) VALUES ('$nome','$desc','$autor','$link','$tipo')"); $wsExistentes[$nome] = 0; } } $dbhw = null; $dbh = null; return "Dados importados."; } ?>