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 = html_entity_decode(ixml($item,"description"));
$nome = html_entity_decode(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.";
}
?>