<% /****************************************************************************** * Copyright (c) 2000-2004 e-Deal * * e-Deal S.A. * 55 rue Brillat Savarin * 75013 Paris * France * * T: +33 (0)1 53 80 80 30 * F: +33 (0)1 73 01 69 77 * http://www.e-deal.com * * La diffusion de ce code source sous quelque forme que ce soit sans * l'autorisation de E-DEAL est interdite. * * Vous êtes autorisés à modifier ce code source uniquement pour votre usage * propre et sous réserve que les mentions de copyright demeurent intactes. * * Ce code est fourni en l'état. Aucune garantie d'aucune sorte, explicite ou * implicite n'est donnée. En aucun cas E-DEAL ne pourra être tenu pour * responsable des dommages pouvant résulter de l'utilisation de ce code * source. * * ******************************************************************************/ %><%@ page language="java"%><%@ page import="com.edeal.frontline.navigation.FlRequest" %><%@ page import="com.edeal.frontline.grid.GridData" %><%@ page import="com.edeal.frontline.Utils" %><%@ page import="com.edeal.frontline.InBoundLogBean" %><%@ page import="java.util.Vector"%><%@ page import="com.edeal.frontline.FlContext"%><%@ page import="com.edeal.frontline.DataDictionary" %><%@ page import="com.edeal.frontline.PersonBean" %><%@ page import="com.edeal.frontline.SilhouetteBean" %><%@ page import="java.util.Hashtable" %><%@ page import="java.util.Date" %><%@taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl"%><% final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(getClass()); FlRequest flRequest = new FlRequest(request); FlContext context = flRequest.getContext(); String lineSep = (String)System.getProperty("line.separator"); String defEncoding = context.getContextParameter("DefaultOutputEncoding"); if (defEncoding == null) { defEncoding = ""; } //response.setHeader("Content-Disposition", "attachment;filename=logsWeb.xls"); Vector vectQuery = new Vector(); String pID = Utils.getRequestParameter(context, request, "id"); String pDelay = flRequest.getRequestParameterOrAttribute("delay") ; long delay = 1; if(pDelay != null) { try { delay = Long.parseLong(pDelay); } catch (Exception ex) { } } long timeDelay = (new Date()).getTime() - (delay * 7 * 24 * 60 * 60 * 1000); timeDelay -= timeDelay % (24 * 60 * 60 * 1000); Date today = new Date(timeDelay); vectQuery.addElement("IblDate >= " + Utils.formatToSQL(context, today)); String pageName = flRequest.getRequestParameterOrAttribute("pageName") ; if (pageName != null) vectQuery.addElement("IblPageName = " + Utils.formatToSQL(context,pageName)); if(pID != null) { vectQuery.addElement("IblVisitorID = " + Utils.formatToSQL(context, pID)); } Vector objs = null; String[] fields = {"IblID", "IblOriID", "IblBrowser", "IblPageName", "IblRemoteIP", "IblTyvID", "IblVisitorID", "IblWopID", "IblOri", "IblCookie", "IblDestination", "IblDate", "IblOriID:OriName", "IblWopID:WopNam"}; String[] orderBy = {"IblDate DESC"}; if(vectQuery.size() > 0) { String[][] query = {{null}}; query[0] = (String[])vectQuery.toArray(new String[1]); objs = InBoundLogBean.listSummary(session, fields, query, orderBy); } else { objs = InBoundLogBean.listSummary(session, fields, orderBy); } boolean hasEntries = objs.size() > 0; DataDictionary dico = context.getDataDictionary(); String personID = Utils.getTableID(context, "Person"); Hashtable vis = new Hashtable(); if(hasEntries) { Vector silID = new Vector(); Vector perID = new Vector(); for(int i = 0; i < objs.size(); i++) { Hashtable row = (Hashtable)objs.elementAt(i); String visType = (String)row.get("IblTyvID"); String visID = (String)row.get("IblVisitorID"); if(personID.equals(visType) && !perID.contains(visID)) { perID.addElement(visID); } else if(visType != null && !silID.contains(visID)) { silID.addElement(visID); } } if(perID.size() > 0) { String[] perFields = {"PerID", "PerFstName", "PerName"}; String[][] query = new String[perID.size()][1]; for(int i = 0; i < perID.size(); i++) { query[i][0] = "PerID = " + Utils.formatToSQL(context, (String)perID.elementAt(i)); } Vector per = PersonBean.listSummary(session, perFields, query); for(int i = 0; i < per.size(); i++) { Hashtable row = (Hashtable)per.elementAt(i); String visName = ""; visName += row.get("PerFstName") == null ? "" : (String)row.get("PerFstName") + " "; visName += row.get("PerName") == null ? "" : (String)row.get("PerName"); String[] visNfo = {visName.trim(), "Person"}; vis.put((String)row.get("PerID"), visNfo); } } if(silID.size() > 0) { String[] silFields = {"SilID", "SilFstName", "SilName"}; String[][] query = new String[silID.size()][1]; for(int i = 0; i < silID.size(); i++) { query[i][0] = "SilID = " + Utils.formatToSQL(context, (String)silID.elementAt(i)); } Vector sil = SilhouetteBean.listSummary(session, silFields, query); for(int i = 0; i < sil.size(); i++) { Hashtable row = (Hashtable)sil.elementAt(i); String visName = ""; visName += row.get("SilFstName") == null ? "" : (String)row.get("SilFstName") + " "; visName += row.get("SilName") == null ? "" : (String)row.get("SilName"); String[] visNfo = {visName.trim(), "Silhouette"}; vis.put((String)row.get("SilID"), visNfo); } } } response.setHeader("Content-Disposition", "attachment;filename=logsWeb.csv"); response.setHeader("Content-Type", "text/plain; charset=" + defEncoding); response.setHeader("Content-Encoding", defEncoding); String[][] labels = {{"F2019", "Date"}, {"F000F", "Heure"}, {"F0013", "Nom de page"}, {"F202A", "Origine"}, {"F0015", "Origine connue"}, {"F0016", "Destination"}, {"F0017", "Opération web"}, {"F0018", "Visiteur"}, {"F001B", "Type de visiteur"}, {"F001C", "Cookie"}, {"F0019", "Adresse IP"}, {"F001A", "Navigateur"}}; for(int i = 0; i < labels.length; i++) { out.write((i == 0 ? "" : ";") + Utils.getMessage(session, labels[i][0], false, true, labels[i][1])); } out.write("\n"); for(int i = 0; i < objs.size(); i++) { Hashtable obj = (Hashtable)objs.elementAt(i); String[] visNfo = null; String visID = (String)obj.get("IblVisitorID"); if(visID != null) { visNfo = (String[])vis.get(visID); } out.write(Utils.formatToWebDate(session, (Date)obj.get("IblDate"), true) + ";"); out.write(Utils.formatToWebTime(session, (Date)obj.get("IblDate"), true) + ";"); out.write((obj.get("IblPageName") == null ? "" : (String)obj.get("IblPageName")) + ";"); out.write((obj.get("IblOri") == null ? "" : (String)obj.get("IblOri")) + ";"); out.write((obj.get("IblOriID:OriName") == null ? "" : (String)obj.get("IblOriID:OriName")) + ";"); out.write((obj.get("IblDestination") == null ? "" : (String)obj.get("IblDestination")) + ";"); out.write((obj.get("IblWopID:WopNam") == null ? "" : obj.get("IblWopID:WopNam")) + ";"); if(visNfo != null) { out.write((visNfo[0] == null ? "" : visNfo[0]) + ";"); out.write((visNfo[1] == null ? "" : visNfo[1]) + ";"); } else { out.write(";"+";"); } out.write((obj.get("IblCookie") == null ? "" : (String)obj.get("IblCookie")) + ";"); out.write((obj.get("IblRemoteIP") == null ? "" : (String)obj.get("IblRemoteIP")) + ";"); out.write((obj.get("IblBrowser") == null ? "" : (String)obj.get("IblBrowser")) + "\n"); } %><% /****************************************************************************** * CVS Log File - This is no longer maintained! * * Revision 1.1 2004/07/23 18:20:04 brian * Initial Revision * *****************************************************************************/ %>