Пример #1
0
        public void AddUrlLog()
        {
            try
            {
                UrlLogInfo objUrlLog;
                var        objUrlLogs = new UrlLogController();

                //iterate through buffered UrlLog items and insert into database
                int intIndex;
                for (intIndex = 0; intIndex <= UrlLog.Count - 1; intIndex++)
                {
                    objUrlLog = (UrlLogInfo)UrlLog[intIndex];
                    switch (UrlLogStorage)
                    {
                    case "D":     //database
                        DataProvider.Instance().ExecuteNonQuery("AddUrlLog",
                                                                objUrlLog.DateTime,
                                                                objUrlLog.PortalId,
                                                                objUrlLog.UserId,
                                                                objUrlLog.Referrer,
                                                                objUrlLog.URL,
                                                                objUrlLog.OriginalURL,
                                                                objUrlLog.RedirectURL,
                                                                objUrlLog.UserAgent,
                                                                objUrlLog.UserHostAddress,
                                                                objUrlLog.UserHostName,
                                                                objUrlLog.TabId,
                                                                objUrlLog.StatusCode);
                        break;

                    case "F":     //file system
                        objUrlLogs.W3CExtendedLog(objUrlLog.DateTime,
                                                  objUrlLog.PortalId,
                                                  objUrlLog.UserId,
                                                  objUrlLog.Referrer,
                                                  objUrlLog.URL,
                                                  objUrlLog.OriginalURL,
                                                  objUrlLog.RedirectURL,
                                                  objUrlLog.UserAgent,
                                                  objUrlLog.UserHostAddress,
                                                  objUrlLog.UserHostName,
                                                  objUrlLog.TabId,
                                                  objUrlLog.StatusCode);
                        break;
                    }
                }
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
            }
        }
Пример #2
0
        public void AddUrlLog()
        {
            try
            {
                UrlLogInfo objUrlLog;
                var objUrlLogs = new UrlLogController();

                //iterate through buffered UrlLog items and insert into database
                int intIndex;
                for (intIndex = 0; intIndex <= UrlLog.Count - 1; intIndex++)
                {
                    objUrlLog = (UrlLogInfo) UrlLog[intIndex];
                    switch (UrlLogStorage)
                    {
                        case "D": //database
                            DataProvider.Instance().ExecuteNonQuery("AddUrlLog",
                                                               objUrlLog.DateTime,
                                                               objUrlLog.PortalId,
                                                               objUrlLog.UserId,
                                                               objUrlLog.Referrer,
                                                               objUrlLog.URL,
                                                               objUrlLog.OriginalURL,
                                                               objUrlLog.RedirectURL,
                                                               objUrlLog.UserAgent,
                                                               objUrlLog.UserHostAddress,
                                                               objUrlLog.UserHostName,
                                                               objUrlLog.TabId,
                                                               objUrlLog.StatusCode);
                            break;
                        case "F": //file system
                            objUrlLogs.W3CExtendedLog(objUrlLog.DateTime,
                                                       objUrlLog.PortalId,
                                                       objUrlLog.UserId,
                                                       objUrlLog.Referrer,
                                                       objUrlLog.URL,
                                                       objUrlLog.OriginalURL,
                                                       objUrlLog.RedirectURL,
                                                       objUrlLog.UserAgent,
                                                       objUrlLog.UserHostAddress,
                                                       objUrlLog.UserHostName,
                                                       objUrlLog.TabId,
                                                       objUrlLog.StatusCode);
                            break;
                    }
                }
            }
            catch (Exception exc)
            {
                DotNetNuke.Instrumentation.DnnLog.Error(exc);

            }
        }
Пример #3
0
        private void DoPurgeUrlLog()
        {
            //var objUrlLog = new UrlLogController();
            var        objPortals = new PortalController();
            ArrayList  arrPortals = objPortals.GetPortals();
            PortalInfo objPortal;
            DateTime   PurgeDate;
            int        intIndex;

            for (intIndex = 0; intIndex <= arrPortals.Count - 1; intIndex++)
            {
                objPortal = (PortalInfo)arrPortals[intIndex];
                int UrlLogHistory = 10;
                if (UrlLogHistory > 0)
                {
                    PurgeDate = DateTime.Now.AddDays(-(UrlLogHistory));
                    UrlLogController.DeleteUrlLog(PurgeDate, objPortal.PortalID);
                }
            }
        }
        public void OnEndRequest(object s, EventArgs e)
        {
            if (s == null)
            {
                return;
            }
            var app = (HttpApplication)s;
            #if DEBUG
            try
            {
                Stopwatch timer = (Stopwatch)HttpContext.Current.Items["UrlRewrite:Timer"];
                app.Response.AddHeader("X-OpenUrlRewriter-OnEndRequest", timer.Elapsed.TotalMilliseconds.ToString());
            }
            catch
            {
            }
            #endif
            int PortalId = -1;
            try
            {
                PortalId = (int)HttpContext.Current.Items["UrlRewrite:PortalId"];
            }
            catch { }

            if (PortalId == -1)
            {
                return;
            }

            if (!UrlRewiterSettings.IsLogEnabled(PortalId))
            {
                return;
            }

            var server = app.Server;
            var request = app.Request;
            var response = app.Response;
            var requestedPath = app.Request.Url.AbsoluteUri;

            if (RewriterUtils.OmitFromRewriteProcessing(request.Url.LocalPath))
            {
                return;
            }

            if (request.Url.LocalPath.ToLower().EndsWith("/install/install.aspx")
                || request.Url.LocalPath.ToLower().EndsWith("/install/upgradewizard.aspx")
                || request.Url.LocalPath.ToLower().EndsWith("/install/installwizard.aspx")
                || request.Url.LocalPath.ToLower().EndsWith("captcha.aspx")
                || request.Url.LocalPath.ToLower().EndsWith("scriptresource.axd")
                || request.Url.LocalPath.ToLower().EndsWith("webresource.axd"))
            {
                return;
            }

            try
            {
                string originalurl = "";
                try
                {
                    originalurl = HttpContext.Current.Items["UrlRewrite:OriginalUrl"].ToString();
                }
                catch { }

                int TabId = -1;
                try
                {
                    TabId = (int)HttpContext.Current.Items["UrlRewrite:TabId"];
                }
                catch
                {
                }
                string RedirectUrl = "";
                try
                {
                    RedirectUrl = HttpContext.Current.Items["UrlRewrite:RedirectUrl"].ToString();
                }
                catch
                {
                }

                string RewriteUrl = request.Url.ToString();
                try
                {
                    RewriteUrl = HttpContext.Current.Items["UrlRewrite:RewriteUrl"].ToString();
                }
                catch
                {
                }

                var statusCode = response.StatusCode;
                var httpContext = HttpContext.Current;
                if (httpContext.Server.GetLastError() != null && httpContext.Server.GetLastError().GetBaseException() != null)
                {
                    var lastException = HttpContext.Current.Server.GetLastError().GetBaseException();
                    var httpException = lastException as HttpException;
                    if (httpException != null)
                    {
                        statusCode = httpException.GetHttpCode();
                    }
                }
                //DnnLog.Error("{0} : {1}", httpContext.Request.Url.AbsoluteUri, statusCode);
                //System.Diagnostics.Debug.WriteLine(originalurl + " : " + statusCode);

                string strSiteLogStorage = "D"; // Host.SiteLogStorage;
                int intSiteLogBuffer = 1; //  Host.SiteLogBuffer;

                //int PortalId = PortalSettings.Current.PortalId;
                //int TabId = PortalSettings.Current.ActiveTab.TabID;

                string urlReferrer = "";
                if (request.UrlReferrer != null)
                {
                    urlReferrer = request.UrlReferrer.ToString();
                }

                //log visit
                bool DoLog = true;
                if (PortalId == -1)
                {
                    DoLog = false;
                }

                UserInfo objUserInfo = UserController.GetCurrentUserInfo();
                if (!UrlRewiterSettings.IsLogAuthentificatedUsers(PortalId) && objUserInfo != null && objUserInfo.UserID != -1)
                {
                    DoLog = false;
                }

                if (!UrlRewiterSettings.IsLogStatusCode200(PortalId) && statusCode == 200)
                {
                    DoLog = false;
                }

                if (DoLog)
                {
                    if (PortalId != -1 && UrlRewiterSettings.IsLogEachUrlOneTime(PortalId))
                    {
                        //var UrlLogLst = UrlLogController.GetUrlLogByOriginalUrl(PortalId, originalurl);
                        UrlLogController.DeleteUrlLogByOriginalUrl(PortalId, originalurl);
                    }

                    var objSiteLogs = new UrlLogController();
                    objSiteLogs.AddUrlLog(PortalId, objUserInfo.UserID, urlReferrer, RewriteUrl, originalurl, RedirectUrl,
                                       request.UserAgent, request.UserHostAddress, request.UserHostName,
                                       TabId, statusCode,
                                       intSiteLogBuffer, strSiteLogStorage);
                }
            }
            catch (Exception exc)
            {
                DnnLog.Error(exc);
            }
        }