diff --git a/Builder/IISMainHandler/build.txt b/Builder/IISMainHandler/build.txt index 6fb6e10..5b2b555 100644 --- a/Builder/IISMainHandler/build.txt +++ b/Builder/IISMainHandler/build.txt @@ -1 +1 @@ -1328 \ No newline at end of file +1340 \ No newline at end of file diff --git a/Common/dataobjects/Session.cs b/Common/dataobjects/Session.cs index 1f992c7..bca9fae 100644 --- a/Common/dataobjects/Session.cs +++ b/Common/dataobjects/Session.cs @@ -48,6 +48,7 @@ namespace FLocal.Common.dataobjects { public const string FIELD_SESSIONKEY = "SessionKey"; public const string FIELD_ACCOUNTID = "AccountId"; public const string FIELD_LASTACTIVITY = "LastActivity"; + public const string FIELD_LASTHUMANACTIVITY = "LastHumanActivity"; public const string FIELD_LASTURL = "LastUrl"; public const string FIELD_ISDELETED = "IsDeleted"; public static readonly TableSpec instance = new TableSpec(); @@ -87,6 +88,14 @@ namespace FLocal.Common.dataobjects { } } + private DateTime _lastHumanActivity; + public DateTime lastHumanActivity { + get { + this.LoadIfNotLoaded(); + return this._lastHumanActivity; + } + } + private string _lastUrl; public string lastUrl { get { @@ -105,7 +114,8 @@ namespace FLocal.Common.dataobjects { protected override void doFromHash(Dictionary data) { this._sessionKey = data[TableSpec.FIELD_SESSIONKEY]; - this._lastActivity = new DateTime(long.Parse(data[TableSpec.FIELD_LASTACTIVITY])); + this._lastActivity = Util.ParseDateTimeFromTimestamp(data[TableSpec.FIELD_LASTACTIVITY]).Value; + this._lastHumanActivity = Util.ParseDateTimeFromTimestamp(data[TableSpec.FIELD_LASTHUMANACTIVITY]).Value; this._accountId = int.Parse(data[TableSpec.FIELD_ACCOUNTID]); this._lastUrl = data[TableSpec.FIELD_LASTURL]; this._isDeleted = Util.string2bool(data[TableSpec.FIELD_ISDELETED]); @@ -117,17 +127,21 @@ namespace FLocal.Common.dataobjects { string _url = lastUrl.ToLower(); if(_url.StartsWith("/upload/item")) return; if(_url.StartsWith("/static")) return; + if(_url.StartsWith("/favicon.ico")) return; } try { + Dictionary dataToUpdate = new Dictionary(); + dataToUpdate[TableSpec.FIELD_LASTACTIVITY] = DateTime.Now.ToUTCString(); + if(lastUrl != null) { + dataToUpdate[TableSpec.FIELD_LASTURL] = lastUrl; + dataToUpdate[TableSpec.FIELD_LASTHUMANACTIVITY] = DateTime.Now.ToUTCString(); + } Config.Transactional(transaction => { Config.instance.mainConnection.update( transaction, TableSpec.instance, this.id.ToString(), - new Dictionary() { - { TableSpec.FIELD_LASTACTIVITY, DateTime.Now.ToUTCString() }, - { TableSpec.FIELD_LASTURL, (lastUrl != null) ? lastUrl : this.lastUrl }, - } + dataToUpdate ); }); } finally { @@ -154,6 +168,7 @@ namespace FLocal.Common.dataobjects { { TableSpec.FIELD_SESSIONKEY, key }, { TableSpec.FIELD_ACCOUNTID, account.id.ToString() }, { TableSpec.FIELD_LASTACTIVITY, DateTime.Now.ToUTCString() }, + { TableSpec.FIELD_LASTHUMANACTIVITY, DateTime.Now.ToUTCString() }, { TableSpec.FIELD_LASTURL, "" }, { TableSpec.FIELD_ISDELETED, "0" }, } @@ -181,7 +196,7 @@ namespace FLocal.Common.dataobjects { public XElement exportToXml(UserContext context) { return new XElement("session", - new XElement("lastActivity", this.lastActivity.ToXml()), + new XElement("lastActivity", this.lastHumanActivity.ToXml()), new XElement("sessionKey", this.sessionKey), this.account.user.exportToXmlForViewing(context), AccountIndicator.LoadByAccount(this.account).exportToXml(context) @@ -206,7 +221,7 @@ namespace FLocal.Common.dataobjects { new JoinSpec[0], new SortSpec[] { new SortSpec( - TableSpec.instance.getColumnSpec(TableSpec.FIELD_LASTACTIVITY), + TableSpec.instance.getColumnSpec(TableSpec.FIELD_LASTHUMANACTIVITY), false ) } diff --git a/IISMainHandler/WebContext.cs b/IISMainHandler/WebContext.cs index 81c7c86..d172f4c 100644 --- a/IISMainHandler/WebContext.cs +++ b/IISMainHandler/WebContext.cs @@ -99,13 +99,36 @@ namespace FLocal.IISHandler { public WebContext(HttpContext httpcontext) { this.httpcontext = httpcontext; this.requestTime = DateTime.Now; + + switch(this.httprequest.Url.Port % 1000) { + case 445: + this.design = new designs.Raw(); + break; + case 447: + this.design = new designs.Lite(); + break; + case 449: + this.design = new designs.Rss(); + break; + case 443: + default: + this.design = new designs.Classic(); + break; + } + HttpCookie sessionCookie = this.httprequest.Cookies["session"]; if(sessionCookie != null && sessionCookie.Value != null && sessionCookie.Value != "") { try { var session = Session.LoadByKey(sessionCookie.Value); var tmp = session.account; sessionCookie.Expires = DateTime.Now.AddDays(3); - session.updateLastActivity(this.httprequest.RequestType == "GET" ? this.httprequest.Path : null); + string lastUrl = null; + if(this.httprequest.RequestType == "GET") { + if(this.design.IsHuman) { + lastUrl = this.httprequest.Path; + } + } + session.updateLastActivity(lastUrl); this.httpresponse.AppendCookie(sessionCookie); this.session = session; } catch(NotFoundInDBException) { @@ -120,22 +143,6 @@ namespace FLocal.IISHandler { } else { this.userSettings = new AnonymousUserSettings(); } - - switch(this.httprequest.Url.Port % 1000) { - case 445: - this.design = new designs.Raw(); - break; - case 447: - this.design = new designs.Lite(); - break; - case 449: - this.design = new designs.Rss(); - break; - case 443: - default: - this.design = new designs.Classic(); - break; - } } public void WriteTransformResult(string templateName, System.Xml.Linq.XDocument data) { diff --git a/IISMainHandler/designs/Classic.cs b/IISMainHandler/designs/Classic.cs index 5288557..b022cc8 100644 --- a/IISMainHandler/designs/Classic.cs +++ b/IISMainHandler/designs/Classic.cs @@ -23,5 +23,11 @@ namespace FLocal.IISHandler.designs { } } + public bool IsHuman { + get { + return true; + } + } + } } diff --git a/IISMainHandler/designs/IDesign.cs b/IISMainHandler/designs/IDesign.cs index 5e2b179..9428662 100644 --- a/IISMainHandler/designs/IDesign.cs +++ b/IISMainHandler/designs/IDesign.cs @@ -12,5 +12,9 @@ namespace FLocal.IISHandler.designs { get; } + bool IsHuman { + get; + } + } } diff --git a/IISMainHandler/designs/Lite.cs b/IISMainHandler/designs/Lite.cs index 1ea8912..d2ecc08 100644 --- a/IISMainHandler/designs/Lite.cs +++ b/IISMainHandler/designs/Lite.cs @@ -23,5 +23,11 @@ namespace FLocal.IISHandler.designs { } } + public bool IsHuman { + get { + return true; + } + } + } } diff --git a/IISMainHandler/designs/Raw.cs b/IISMainHandler/designs/Raw.cs index 61cce64..64aa74a 100644 --- a/IISMainHandler/designs/Raw.cs +++ b/IISMainHandler/designs/Raw.cs @@ -20,5 +20,11 @@ namespace FLocal.IISHandler.designs { } } + public bool IsHuman { + get { + return false; + } + } + } } diff --git a/IISMainHandler/designs/Rss.cs b/IISMainHandler/designs/Rss.cs index 89d2db3..9afed1d 100644 --- a/IISMainHandler/designs/Rss.cs +++ b/IISMainHandler/designs/Rss.cs @@ -20,5 +20,11 @@ namespace FLocal.IISHandler.designs { } } + public bool IsHuman { + get { + return false; + } + } + } } diff --git a/IISMainHandler/handlers/BoardsHandler.cs b/IISMainHandler/handlers/BoardsHandler.cs index aba4e20..739bbb6 100644 --- a/IISMainHandler/handlers/BoardsHandler.cs +++ b/IISMainHandler/handlers/BoardsHandler.cs @@ -29,7 +29,7 @@ namespace FLocal.IISHandler.handlers { new XElement("sessions", Config.instance.mainConnection.GetCountByConditions( Session.TableSpec.instance, new ComparisonCondition( - Session.TableSpec.instance.getColumnSpec(Session.TableSpec.FIELD_LASTACTIVITY), + Session.TableSpec.instance.getColumnSpec(Session.TableSpec.FIELD_LASTHUMANACTIVITY), ComparisonType.GREATEROREQUAL, DateTime.Now.Subtract(Config.instance.ActivityThreshold).ToUTCString() ) diff --git a/IISMainHandler/handlers/response/AbstractUserGetHandler.cs b/IISMainHandler/handlers/response/AbstractUserGetHandler.cs index 3580837..13fe425 100644 --- a/IISMainHandler/handlers/response/AbstractUserGetHandler.cs +++ b/IISMainHandler/handlers/response/AbstractUserGetHandler.cs @@ -43,7 +43,7 @@ namespace FLocal.IISHandler.handlers.response { return new XElement[] { user.exportToXmlForViewing(context), (account == null) ? null : new XElement("accountId", account.id.ToString()), //for PM history, PM send etc - (lastSession == null) ? null : new XElement("lastActivity", lastSession.lastActivity.ToXml()), + (lastSession == null) ? null : new XElement("lastActivity", lastSession.lastHumanActivity.ToXml()), }.Union(this.getUserSpecificData(context, user)); } diff --git a/IISMainHandler/handlers/response/WhoIsOnlineHandler.cs b/IISMainHandler/handlers/response/WhoIsOnlineHandler.cs index b21c0b7..9547a1c 100644 --- a/IISMainHandler/handlers/response/WhoIsOnlineHandler.cs +++ b/IISMainHandler/handlers/response/WhoIsOnlineHandler.cs @@ -28,7 +28,7 @@ namespace FLocal.IISHandler.handlers.response { new ComplexCondition( ConditionsJoinType.AND, new ComparisonCondition( - Session.TableSpec.instance.getColumnSpec(Session.TableSpec.FIELD_LASTACTIVITY), + Session.TableSpec.instance.getColumnSpec(Session.TableSpec.FIELD_LASTHUMANACTIVITY), Core.DB.conditions.ComparisonType.GREATEROREQUAL, DateTime.Now.Subtract(Config.instance.ActivityThreshold).ToUTCString() ), @@ -47,7 +47,7 @@ namespace FLocal.IISHandler.handlers.response { where !account.isStatusHidden select account.user.exportToXmlForViewing( context, - new XElement("lastActivity", session.lastActivity.ToXml()), + new XElement("lastActivity", session.lastHumanActivity.ToXml()), !account.isDetailedStatusHidden ? new XElement("lastUrl", session.lastUrl) : null ) )