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 { $idtemp = (rand (9000,10000)) * -1; $dbhw->query("INSERT INTO i3geoadmin_ws (nome_ws,desc_ws,autor_ws,tipo_ws,link_ws,nacessos,nacessosok) VALUES ('$idtemp','','','','',0,0)"); $id = $dbh->query("SELECT id_ws FROM i3geoadmin_ws WHERE nome_ws = '$idtemp'"); $id = $id->fetchAll(); $id = $id[0]['id_ws']; $dbhw->query("UPDATE i3geoadmin_ws SET nome_ws = '' WHERE id_ws = $id AND nome_ws = '$idtemp'"); $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 adicionaAcesso($id_ws,$sucesso) { try { if($id_ws == ""){return;} include("conexao.php"); $dados = pegaDados("select * from i3geoadmin_ws WHERE id_ws = $id_ws"); if(count($dados) == 0){return;}; if($dados[0]["nacessos"] == ""){$dados[0]["nacessos"] = 0;} $acessos = $dados[0]["nacessos"] + 1; if($sucesso) $ok = $dados[0]["nacessosok"] + 1; else $ok = $dados[0]["nacessosok"]; if($ok == ""){$ok = 0;} $dbhw->query("UPDATE i3geoadmin_ws SET nacessos = '$acessos',nacessosok = '$ok' WHERE id_ws = $id_ws"); $dbhw = null; $dbh = null; } catch (PDOException $e) { return "Error!: " . $e->getMessage(); } } function importarXmlWS() { global $xml,$tipo; set_time_limit(180); 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 = $dbh->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) { $desc = html_entity_decode(ixml($item,"description")); $nome = html_entity_decode(ixml($item,"title")); $autor = html_entity_decode(ixml($item,"author")); $link = ixml($item,"link"); if($convUTF) { $nome = utf8_encode($nome); $desc = utf8_encode($desc); $autor = utf8_encode($autor); } if(!isset($wsExistentes[$nome])) $dbhw->query("INSERT INTO i3geoadmin_ws (nome_ws,desc_ws,autor_ws,link_ws,tipo_ws,nacessos,nacessosok) VALUES ('$nome','$desc','$autor','$link','$tipo',0,0)"); $wsExistentes[$nome] = 0; } } $dbhw = null; $dbh = null; return "Dados importados."; } ?>