Commit 2dcd28f857ecd0ffbc07c8fadcc1df8add1aba59
1 parent
de05365d
Exists in
master
and in
7 other branches
Inclusão de log de transações #62
Showing
3 changed files
with
127 additions
and
113 deletions
Show diff stats
admin/admin.db
No preview for this file type
admin/php/usuarios.php
| ... | ... | @@ -136,7 +136,9 @@ function enviarSenhaEmail(){ |
| 136 | 136 | $dados = pegaDados("select * from ".$esquemaadmin."i3geousr_usuarios where id_usuario = $id_usuario and ativo = 1"); |
| 137 | 137 | if(count($dados) > 0){ |
| 138 | 138 | $senha = md5($novaSenha); |
| 139 | - $dbhw->query("UPDATE ".$esquemaadmin."i3geousr_usuarios SET senha='$senha' WHERE id_usuario = $id_usuario"); | |
| 139 | + $sql = "UPDATE ".$esquemaadmin."i3geousr_usuarios SET senha='$senha' WHERE id_usuario = $id_usuario"; | |
| 140 | + $dbhw->query($sql); | |
| 141 | + i3GeoAdminInsertLog($dbhw,$sql); | |
| 140 | 142 | $to = $dados[0]["email"]; |
| 141 | 143 | $subject = 'senha i3geo'; |
| 142 | 144 | $message = $novaSenha; |
| ... | ... | @@ -162,28 +164,30 @@ function alterarUsuarios() |
| 162 | 164 | if(count($dados) > 0){ |
| 163 | 165 | $retorna = false; |
| 164 | 166 | } |
| 167 | + $dataCol = array( | |
| 168 | + "nome_usuario" => $nome_usuario, | |
| 169 | + "login" => $login, | |
| 170 | + "email" => $email, | |
| 171 | + "ativo" => $ativo, | |
| 172 | + "data_cadastro" => $data_cadastro | |
| 173 | + ); | |
| 165 | 174 | //se a senha foi enviada, ela sera trocada |
| 166 | 175 | if($senha != ""){ |
| 167 | - $senha = md5($senha); | |
| 168 | - $dbhw->query("UPDATE ".$esquemaadmin."i3geousr_usuarios SET senha='$senha',nome_usuario='$nome_usuario',login='$login',email='$email',ativo=$ativo,data_cadastro='$data_cadastro' WHERE id_usuario = $id_usuario"); | |
| 169 | - } | |
| 170 | - else{ | |
| 171 | - $dbhw->query("UPDATE ".$esquemaadmin."i3geousr_usuarios SET nome_usuario='$nome_usuario',login='$login',email='$email',ativo=$ativo,data_cadastro='$data_cadastro' WHERE id_usuario = $id_usuario"); | |
| 176 | + $dataCol["senha"] = md5($senha); | |
| 172 | 177 | } |
| 178 | + i3GeoAdminUpdate($dbhw,"i3geousr_usuarios",$dataCol,"WHERE id_usuario = $id_usuario"); | |
| 173 | 179 | $retorna = $id_usuario; |
| 174 | 180 | } |
| 175 | 181 | else{ |
| 176 | - $idtemp = rand (9000,1000000) * -1; | |
| 177 | - if($senha == ""){ | |
| 178 | - $senha = md5($idtemp); | |
| 179 | - } | |
| 180 | - //echo "INSERT INTO ".$esquemaadmin."i3geousr_usuarios (senha,nome_usuario,ativo) VALUES ('$senha','$idtemp',0)";exit; | |
| 181 | - $dbhw->query("INSERT INTO ".$esquemaadmin."i3geousr_usuarios (login,senha,nome_usuario,ativo) VALUES ('$idtemp','$senha','$idtemp',0)"); | |
| 182 | - $id = $dbh->query("SELECT id_usuario FROM ".$esquemaadmin."i3geousr_usuarios WHERE nome_usuario = '$idtemp'"); | |
| 183 | - $id = $id->fetchAll(); | |
| 184 | - $id = $id[0]['id_usuario']; | |
| 185 | - //$dbhw->query("UPDATE ".$esquemaadmin."i3geousr_usuarios SET nome_usuario = '' WHERE id_usuario = $id AND nome_usuario = '$idtemp'"); | |
| 186 | - $retorna = $id; | |
| 182 | + $dataCol = array( | |
| 183 | + "nome_usuario" => '', | |
| 184 | + "login" => '', | |
| 185 | + "email" => '', | |
| 186 | + "ativo" => 0, | |
| 187 | + "data_cadastro" => '', | |
| 188 | + "senha" => '' | |
| 189 | + ); | |
| 190 | + $retorna = i3GeoAdminInsertUnico($dbhw,"i3geousr_usuarios",$dataCol,"nome_usuario","id_usuario"); | |
| 187 | 191 | } |
| 188 | 192 | $dbhw = null; |
| 189 | 193 | $dbh = null; |
| ... | ... | @@ -195,10 +199,13 @@ function alterarUsuarios() |
| 195 | 199 | } |
| 196 | 200 | function adicionaPapelUsuario(){ |
| 197 | 201 | global $id_usuario,$id_papel; |
| 198 | - try | |
| 199 | - { | |
| 202 | + try { | |
| 200 | 203 | include(dirname(__FILE__)."/conexao.php"); |
| 201 | - $dbhw->query("INSERT INTO ".$esquemaadmin."i3geousr_papelusuario (id_usuario,id_papel) VALUES ($id_usuario,$id_papel)"); | |
| 204 | + $dataCol = array( | |
| 205 | + "id_usuario" => $id_usuario, | |
| 206 | + "id_papel" => $id_papel | |
| 207 | + ); | |
| 208 | + i3GeoAdminInsert($dbhw,"i3geousr_papelusuario",$dataCol); | |
| 202 | 209 | $dbhw = null; |
| 203 | 210 | $dbh = null; |
| 204 | 211 | return "ok"; |
| ... | ... | @@ -207,37 +214,33 @@ function adicionaPapelUsuario(){ |
| 207 | 214 | return "Error!: " . $e->getMessage(); |
| 208 | 215 | } |
| 209 | 216 | } |
| 210 | -function excluirUsuario() | |
| 211 | -{ | |
| 217 | +function excluirUsuario(){ | |
| 212 | 218 | global $id_usuario; |
| 213 | - try | |
| 214 | - { | |
| 219 | + try { | |
| 215 | 220 | include(dirname(__FILE__)."/conexao.php"); |
| 216 | - //echo "DELETE from ".$esquemaadmin."i3geousr_usuarios WHERE id_usuario = $id_usuario";exit; | |
| 217 | - $dbhw->query("DELETE FROM ".$esquemaadmin."i3geousr_usuarios WHERE id_usuario = $id_usuario "); | |
| 221 | + $sql = "DELETE FROM ".$esquemaadmin."i3geousr_usuarios WHERE id_usuario = $id_usuario "; | |
| 222 | + $dbhw->query($sql); | |
| 223 | + i3GeoAdminInsertLog($dbhw,$sql); | |
| 218 | 224 | $dbhw = null; |
| 219 | 225 | $dbh = null; |
| 220 | 226 | return "ok"; |
| 221 | 227 | } |
| 222 | - catch (PDOException $e) | |
| 223 | - { | |
| 228 | + catch (PDOException $e) { | |
| 224 | 229 | return "Error!: " . $e->getMessage(); |
| 225 | 230 | } |
| 226 | 231 | } |
| 227 | -function excluirPapelUsuario() | |
| 228 | -{ | |
| 232 | +function excluirPapelUsuario(){ | |
| 229 | 233 | global $id_usuario,$id_papel; |
| 230 | - try | |
| 231 | - { | |
| 234 | + try { | |
| 232 | 235 | include(dirname(__FILE__)."/conexao.php"); |
| 233 | - //echo "DELETE from ".$esquemaadmin."i3geousr_usuarios WHERE id_usuario = $id_usuario";exit; | |
| 234 | - $dbhw->query("DELETE FROM ".$esquemaadmin."i3geousr_papelusuario WHERE id_usuario = $id_usuario AND id_papel = $id_papel "); | |
| 236 | + $sql = "DELETE FROM ".$esquemaadmin."i3geousr_papelusuario WHERE id_usuario = $id_usuario AND id_papel = $id_papel "; | |
| 237 | + $dbhw->query($sql); | |
| 238 | + i3GeoAdminInsertLog($dbhw,$sql); | |
| 235 | 239 | $dbhw = null; |
| 236 | 240 | $dbh = null; |
| 237 | 241 | return "ok"; |
| 238 | 242 | } |
| 239 | - catch (PDOException $e) | |
| 240 | - { | |
| 243 | + catch (PDOException $e) { | |
| 241 | 244 | return "Error!: " . $e->getMessage(); |
| 242 | 245 | } |
| 243 | 246 | } | ... | ... |
admin/php/webservices.php
| 1 | 1 | <?php |
| 2 | 2 | /* |
| 3 | -Title: webservices.php | |
| 3 | + Title: webservices.php | |
| 4 | 4 | |
| 5 | 5 | Funções utilizadas pelo editor do cadastro de Web Services |
| 6 | 6 | |
| ... | ... | @@ -24,7 +24,7 @@ por&eacute;m, SEM NENHUMA GARANTIA; nem mesmo a garantia impl&iacute;cita |
| 24 | 24 | de COMERCIABILIDADE OU ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. |
| 25 | 25 | Consulte a Licença Pública Geral do GNU para mais detalhes. |
| 26 | 26 | Você deve ter recebido uma cópia da Licença Pública Geral do |
| 27 | -GNU junto com este programa; se não, escreva para a | |
| 27 | + GNU junto com este programa; se não, escreva para a | |
| 28 | 28 | Free Software Foundation, Inc., no endereço |
| 29 | 29 | 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. |
| 30 | 30 | |
| ... | ... | @@ -59,12 +59,12 @@ ob_clean(); |
| 59 | 59 | switch (strtoupper($funcao)) |
| 60 | 60 | { |
| 61 | 61 | /* |
| 62 | - Note: | |
| 62 | + Note: | |
| 63 | 63 | |
| 64 | 64 | Valores que o parâmetro &funcao pode receber. Os parâmetros devem ser enviados na requisição em AJAX. |
| 65 | 65 | */ |
| 66 | 66 | /* |
| 67 | - Valor: PEGAWS | |
| 67 | + Valor: PEGAWS | |
| 68 | 68 | |
| 69 | 69 | Lista de serviços cadastrados |
| 70 | 70 | |
| ... | ... | @@ -74,114 +74,117 @@ switch (strtoupper($funcao)) |
| 74 | 74 | */ |
| 75 | 75 | case "PEGAWS": |
| 76 | 76 | if(isset($tipows) && $tipows != "") |
| 77 | - {$sql = "SELECT id_ws,nome_ws,tipo_ws from ".$esquemaadmin."i3geoadmin_ws where tipo_ws = '".strtoupper($tipows)."' order by tipo_ws,nome_ws ";} | |
| 77 | + { | |
| 78 | + $sql = "SELECT id_ws,nome_ws,tipo_ws from ".$esquemaadmin."i3geoadmin_ws where tipo_ws = '".strtoupper($tipows)."' order by tipo_ws,nome_ws "; | |
| 79 | + } | |
| 78 | 80 | else |
| 79 | - {$sql = "SELECT id_ws,nome_ws,tipo_ws from ".$esquemaadmin."i3geoadmin_ws order by tipo_ws,nome_ws";} | |
| 81 | + {$sql = "SELECT id_ws,nome_ws,tipo_ws from ".$esquemaadmin."i3geoadmin_ws order by tipo_ws,nome_ws"; | |
| 82 | + } | |
| 80 | 83 | retornaJSON(pegaDados($sql)); |
| 81 | 84 | exit; |
| 82 | - break; | |
| 83 | - /* | |
| 84 | - Valor: PEGADADOS | |
| 85 | + break; | |
| 86 | + /* | |
| 87 | + Valor: PEGADADOS | |
| 85 | 88 | |
| 86 | - Dados de um servico | |
| 89 | + Dados de um servico | |
| 87 | 90 | |
| 88 | - Parametro: | |
| 91 | + Parametro: | |
| 89 | 92 | |
| 90 | - id_ws {string} | |
| 93 | + id_ws {string} | |
| 91 | 94 | |
| 92 | - Retorno: | |
| 95 | + Retorno: | |
| 93 | 96 | |
| 94 | - {JSON} | |
| 95 | - */ | |
| 97 | + {JSON} | |
| 98 | + */ | |
| 96 | 99 | case "PEGADADOS": |
| 97 | 100 | retornaJSON(pegaDados("SELECT * from ".$esquemaadmin."i3geoadmin_ws where id_ws='$id_ws'")); |
| 98 | 101 | exit; |
| 99 | - break; | |
| 100 | - /* | |
| 101 | - Valor: ALTERARWS | |
| 102 | + break; | |
| 103 | + /* | |
| 104 | + Valor: ALTERARWS | |
| 102 | 105 | |
| 103 | - Altera um registro | |
| 106 | + Altera um registro | |
| 104 | 107 | |
| 105 | - Parametros: | |
| 108 | + Parametros: | |
| 106 | 109 | |
| 107 | - id_ws | |
| 110 | + id_ws | |
| 108 | 111 | |
| 109 | - desc_ws | |
| 112 | + desc_ws | |
| 110 | 113 | |
| 111 | - nome_ws | |
| 114 | + nome_ws | |
| 112 | 115 | |
| 113 | - link_ws | |
| 116 | + link_ws | |
| 114 | 117 | |
| 115 | - autor_ws | |
| 118 | + autor_ws | |
| 116 | 119 | |
| 117 | - tipo_ws | |
| 120 | + tipo_ws | |
| 118 | 121 | |
| 119 | - Retorno: | |
| 122 | + Retorno: | |
| 120 | 123 | |
| 121 | - {JSON} | |
| 122 | - */ | |
| 124 | + {JSON} | |
| 125 | + */ | |
| 123 | 126 | case "ALTERARWS": |
| 124 | 127 | $novo = alterarWS(); |
| 125 | 128 | $sql = "SELECT * from ".$esquemaadmin."i3geoadmin_ws WHERE id_ws = '".$novo."'"; |
| 126 | 129 | retornaJSON(pegaDados($sql)); |
| 127 | 130 | exit; |
| 128 | - break; | |
| 129 | - /* | |
| 130 | - Valor: EXCLUIR | |
| 131 | + break; | |
| 132 | + /* | |
| 133 | + Valor: EXCLUIR | |
| 131 | 134 | |
| 132 | - Exclui um registro | |
| 135 | + Exclui um registro | |
| 133 | 136 | |
| 134 | - Parametro: | |
| 137 | + Parametro: | |
| 135 | 138 | |
| 136 | - id {string} | |
| 139 | + id {string} | |
| 137 | 140 | |
| 138 | - Retorno: | |
| 141 | + Retorno: | |
| 139 | 142 | |
| 140 | - {JSON} | |
| 141 | - */ | |
| 143 | + {JSON} | |
| 144 | + */ | |
| 142 | 145 | case "EXCLUIR": |
| 143 | 146 | retornaJSON(excluirWS()); |
| 144 | 147 | exit; |
| 145 | - break; | |
| 148 | + break; | |
| 146 | 149 | |
| 147 | 150 | } |
| 148 | 151 | /* |
| 149 | -Altera o registro de um WS | |
| 152 | + Altera o registro de um WS | |
| 150 | 153 | */ |
| 151 | 154 | function alterarWS() |
| 152 | 155 | { |
| 153 | 156 | global $esquemaadmin,$id_ws,$desc_ws,$nome_ws,$link_ws,$autor_ws,$tipo_ws; |
| 154 | 157 | try |
| 155 | 158 | { |
| 156 | - require_once("conexao.php"); | |
| 159 | + require_once("conexao.php"); | |
| 157 | 160 | if($convUTF) |
| 158 | 161 | { |
| 159 | 162 | $nome_ws = utf8_encode($nome_ws); |
| 160 | 163 | $desc_ws = utf8_encode($desc_ws); |
| 161 | 164 | $autor_ws = utf8_encode($autor_ws); |
| 162 | 165 | } |
| 163 | - if($id_ws != "") | |
| 164 | - { | |
| 165 | - $dbhw->query("UPDATE ".$esquemaadmin."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"); | |
| 166 | - $retorna = $id_ws; | |
| 167 | - } | |
| 168 | - else | |
| 169 | - { | |
| 170 | - $idtemp = (rand (9000,10000)) * -1; | |
| 166 | + if($id_ws != "") | |
| 167 | + { | |
| 168 | + $dbhw->query("UPDATE ".$esquemaadmin."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"); | |
| 169 | + $retorna = $id_ws; | |
| 170 | + } | |
| 171 | + else | |
| 172 | + { | |
| 173 | + $idtemp = (rand (9000,10000)) * -1; | |
| 171 | 174 | $dbhw->query("INSERT INTO ".$esquemaadmin."i3geoadmin_ws (nome_ws,desc_ws,autor_ws,tipo_ws,link_ws,nacessos,nacessosok) VALUES ('$idtemp','','','','',0,0)"); |
| 172 | 175 | $id = $dbh->query("SELECT id_ws FROM ".$esquemaadmin."i3geoadmin_ws WHERE nome_ws = '$idtemp'"); |
| 173 | 176 | $id = $id->fetchAll(); |
| 174 | 177 | $id = $id[0]['id_ws']; |
| 175 | 178 | $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_ws SET nome_ws = '' WHERE id_ws = $id AND nome_ws = '$idtemp'"); |
| 176 | 179 | $retorna = $id; |
| 177 | - } | |
| 178 | - $dbhw = null; | |
| 179 | - $dbh = null; | |
| 180 | - return $retorna; | |
| 180 | + } | |
| 181 | + $dbhw = null; | |
| 182 | + $dbh = null; | |
| 183 | + return $retorna; | |
| 181 | 184 | } |
| 182 | 185 | catch (PDOException $e) |
| 183 | 186 | { |
| 184 | - return "Error!: " . $e->getMessage(); | |
| 187 | + return "Error!: " . $e->getMessage(); | |
| 185 | 188 | } |
| 186 | 189 | } |
| 187 | 190 | function excluirWS() |
| ... | ... | @@ -189,15 +192,15 @@ function excluirWS() |
| 189 | 192 | global $id,$esquemaadmin; |
| 190 | 193 | try |
| 191 | 194 | { |
| 192 | - include("conexao.php"); | |
| 193 | - $dbhw->query("DELETE from ".$esquemaadmin."i3geoadmin_ws WHERE id_ws = $id"); | |
| 194 | - $dbhw = null; | |
| 195 | - $dbh = null; | |
| 196 | - return "ok"; | |
| 195 | + include("conexao.php"); | |
| 196 | + $dbhw->query("DELETE from ".$esquemaadmin."i3geoadmin_ws WHERE id_ws = $id"); | |
| 197 | + $dbhw = null; | |
| 198 | + $dbh = null; | |
| 199 | + return "ok"; | |
| 197 | 200 | } |
| 198 | 201 | catch (PDOException $e) |
| 199 | 202 | { |
| 200 | - return "Error!: " . $e->getMessage(); | |
| 203 | + return "Error!: " . $e->getMessage(); | |
| 201 | 204 | } |
| 202 | 205 | } |
| 203 | 206 | function adicionaAcesso($id_ws,$sucesso) |
| ... | ... | @@ -205,26 +208,34 @@ function adicionaAcesso($id_ws,$sucesso) |
| 205 | 208 | global $esquemaadmin; |
| 206 | 209 | try |
| 207 | 210 | { |
| 208 | - if($id_ws == ""){return;} | |
| 209 | - include("conexao.php"); | |
| 210 | - $dados = pegaDados("select * from ".$esquemaadmin."i3geoadmin_ws WHERE id_ws = $id_ws"); | |
| 211 | - if(count($dados) == 0){return;}; | |
| 212 | - if($dados[0]["nacessos"] == ""){$dados[0]["nacessos"] = 0;} | |
| 213 | - $acessos = $dados[0]["nacessos"] + 1; | |
| 214 | - | |
| 215 | - if($sucesso) | |
| 216 | - $ok = $dados[0]["nacessosok"] + 1; | |
| 217 | - else | |
| 218 | - $ok = $dados[0]["nacessosok"]; | |
| 219 | - | |
| 220 | - if($ok == ""){$ok = 0;} | |
| 221 | - $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_ws SET nacessos = '$acessos',nacessosok = '$ok' WHERE id_ws = $id_ws"); | |
| 222 | - $dbhw = null; | |
| 223 | - $dbh = null; | |
| 211 | + if($id_ws == ""){ | |
| 212 | + return; | |
| 213 | + } | |
| 214 | + include("conexao.php"); | |
| 215 | + $dados = pegaDados("select * from ".$esquemaadmin."i3geoadmin_ws WHERE id_ws = $id_ws"); | |
| 216 | + if(count($dados) == 0){ | |
| 217 | + return; | |
| 218 | + }; | |
| 219 | + if($dados[0]["nacessos"] == ""){ | |
| 220 | + $dados[0]["nacessos"] = 0; | |
| 221 | + } | |
| 222 | + $acessos = $dados[0]["nacessos"] + 1; | |
| 223 | + | |
| 224 | + if($sucesso) | |
| 225 | + $ok = $dados[0]["nacessosok"] + 1; | |
| 226 | + else | |
| 227 | + $ok = $dados[0]["nacessosok"]; | |
| 228 | + | |
| 229 | + if($ok == ""){ | |
| 230 | + $ok = 0; | |
| 231 | + } | |
| 232 | + $dbhw->query("UPDATE ".$esquemaadmin."i3geoadmin_ws SET nacessos = '$acessos',nacessosok = '$ok' WHERE id_ws = $id_ws"); | |
| 233 | + $dbhw = null; | |
| 234 | + $dbh = null; | |
| 224 | 235 | } |
| 225 | 236 | catch (PDOException $e) |
| 226 | 237 | { |
| 227 | - return "Error!: " . $e->getMessage(); | |
| 238 | + return "Error!: " . $e->getMessage(); | |
| 228 | 239 | } |
| 229 | 240 | } |
| 230 | 241 | ?> |
| 231 | 242 | \ No newline at end of file | ... | ... |