<%@ page import="javax.naming.*" %> <%@ page import="javax.sql.*" %> <%@ page import="java.sql.Connection" %> <%@ page import="com.hlt.sql.Statement" %> <%@ page import="com.hlt.sql.Query" %> <%@ page import="com.hlt.sql.SysError" %> <%@ page import="com.hlt.util.*" %> <%@ page import="java.util.ArrayList" %> <%@ page import="java.util.Date"%> <%@ page import="br.com.relato.EntryPoint" %> <%! private void incluiNovaRejeicao(String cCodCliente, int nIdEmail, long nIdLog, Connection con ) { //SQLQuery = "INSERT INTO rejeicoes (id_email, cod_cliente, id_log, data_inclusao ) VALUES (" & cId_Email & ", '" & cCod_Cliente & "', " & cIdLog & ", now() )" if(cCodCliente.length() == 0 || nIdEmail <= 0 || nIdLog <= 0) return; Statement stmt = new Statement(con); ArrayList prm = new ArrayList(); ArrayList cps = new ArrayList(); cps.add("id_email"); cps.add("cod_cliente"); cps.add("id_log"); cps.add("data_inclusao"); cps.add("origem"); prm.add("?"); prm.add("?"); prm.add("?"); prm.add("?"); prm.add("?"); String prmt[] = (String[])prm.toArray(new String[prm.size()]); String cpos[] = (String[])cps.toArray(new String[cps.size()]); // Insere registro stmt.insert("rejeicoes").fields(cpos).values(prmt); stmt.buildParams(); stmt.setParamInt(1, nIdEmail); stmt.setParamString(2, cCodCliente); stmt.setParamLong(3, nIdLog); stmt.setParamDate(4, new Date()); stmt.setParamString(5, "j"); stmt.execute(); } %> E X P R E S S E M A I L

<% Query qr = null; Context ctx; DataSource ds; Connection con = null; String cCodCliente = request.getParameter("cod"); int nIdEmail = -1; long nIdLog = -1; try { String EMAIL = request.getParameter("email"); if(EMAIL != null) { int i = 0; while(i < EMAIL.length() && !Character.isDigit(EMAIL.charAt(i))) ++i; int j = i; for(; j < EMAIL.length() && Character.isDigit(EMAIL.charAt(j)); ++j); nIdEmail = Integer.parseInt(EMAIL.substring(i, j)); } String LOG = request.getParameter("log"); if(LOG != null) { int i = 0; while(i < LOG.length() && !Character.isDigit(LOG.charAt(i))) ++i; int j = i; for(; j < LOG.length() && Character.isDigit(LOG.charAt(j)); ++j); nIdLog = Long.parseLong(LOG.substring(i, j)); } }catch(Exception e) {} SysError.clear(); %> <% if(cCodCliente == null || cCodCliente.length() == 0 || nIdEmail <= 0 || nIdLog <= 0) { %>
Parametro inválido1.

<% } else { //try { // ctx = new InitialContext(); // if (ctx != null) { // ds = (DataSource) ctx.lookup("java:comp/env/jdbc/ExpressEmail"); // if (ds != null) { //con = util.ConnHelper.getConnection(ds, this, request, response); //if(con == null) return; // con = ds.getConnection(); // if(con == null) // log("não foi possivel adquirir uma conecção do pool"); con = EntryPoint.getConnection(); if (con != null) { do { qr = new Query(con); //verificamos se esse log realmente existe //logo checkamos se eof é verdadeiro qr.command("SELECT idemail FROM logs WHERE idemail = " +nIdEmail+ " and id = "+nIdLog); if(qr.open()) { if(qr.eof()) { %>
Parametro inválido2.

<% break; } } qr.close(); //verificamos se esse email ja foi descadastrado //logo checkamos se eof eh falso qr.command("SELECT id_email, cod_cliente FROM rejeicoes WHERE id_email = " + nIdEmail + " AND cod_cliente = " + cCodCliente); if(qr.open()) { if(!qr.eof()) { %>
Este email já foi excluido previamente.

<% break; } } qr.close(); String conta = "", dominio = ""; qr.command("SELECT conta, dominio FROM emails WHERE id = " + nIdEmail); if(qr.open()) { conta = qr.getString(1); dominio = qr.getString(2); qr.close(); } else { %>
Parametro inválido3.

<% break; } incluiNovaRejeicao(cCodCliente, nIdEmail, nIdLog, con); %>
O seu email foi excluído com sucesso.
Your email was removed successfully.
<%=conta%>@<%=dominio%>
<% } while(false); if(qr != null) qr.close(); } //if con //} //if ds //} //if ctx //} //try //catch(org.apache.commons.dbcp.DbcpException x) { // log("erro ao se conectar ao banco", x); // response.sendRedirect("jam.html"); //}catch(Exception e) { //log("erro de processamento", e); %> <% //} //catch //finally //{ //if(con != null) con.close(); //if(qr != null) qr.close(); } //} //else params %>