mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Fixed Visitor Data not being pulled correctly.
Fixed a couple Context null reference possibilities with the Config and Pre-Send Headers event.
This commit is contained in:
parent
73403551d6
commit
c099076d8e
@ -53,12 +53,16 @@ namespace Teknik
|
|||||||
|
|
||||||
protected void Application_PreSendRequestHeaders(object sender, EventArgs e)
|
protected void Application_PreSendRequestHeaders(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// Don't server HSTS over HTTP
|
if (HttpContext.Current != null)
|
||||||
if (HttpContext.Current.Request.Url.Scheme != "https")
|
{
|
||||||
HttpContext.Current.Response.Headers.Remove("strict-transport-security");
|
HttpContext context = HttpContext.Current;
|
||||||
|
// Don't server HSTS over HTTP
|
||||||
|
if (context.Request.Url.Scheme != "https")
|
||||||
|
HttpContext.Current.Response.Headers.Remove("strict-transport-security");
|
||||||
|
|
||||||
// Remove stupid headers
|
// Remove stupid headers
|
||||||
HttpContext.Current.Response.Headers.Remove("Server");
|
context.Response.Headers.Remove("Server");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void Application_EndRequest(object sender, EventArgs e)
|
protected void Application_EndRequest(object sender, EventArgs e)
|
||||||
|
@ -171,12 +171,13 @@ namespace Teknik.Configuration
|
|||||||
public static Config Load()
|
public static Config Load()
|
||||||
{
|
{
|
||||||
HttpContext context = HttpContext.Current;
|
HttpContext context = HttpContext.Current;
|
||||||
_Config = (Config)context.Cache[_ConfigCacheKey];
|
if (context != null)
|
||||||
|
_Config = (Config)context.Cache[_ConfigCacheKey];
|
||||||
if (_Config == null)
|
if (_Config == null)
|
||||||
{
|
{
|
||||||
string path = AppDomain.CurrentDomain.GetData("DataDirectory").ToString();
|
string path = AppDomain.CurrentDomain.GetData("DataDirectory").ToString();
|
||||||
_Config = Load(path);
|
_Config = Load(path);
|
||||||
context.Cache.Insert(_ConfigCacheKey, _Config, new CacheDependency(path));
|
context?.Cache.Insert(_ConfigCacheKey, _Config, new CacheDependency(path));
|
||||||
}
|
}
|
||||||
return _Config;
|
return _Config;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using Piwik.Analytics;
|
using Piwik.Analytics;
|
||||||
using Piwik.Analytics.Date;
|
using Piwik.Analytics.Date;
|
||||||
using Piwik.Analytics.Modules;
|
using Piwik.Analytics.Modules;
|
||||||
using System;
|
using System;
|
||||||
@ -32,51 +32,57 @@ namespace Teknik.Piwik
|
|||||||
|
|
||||||
foreach (string period in results.Keys)
|
foreach (string period in results.Keys)
|
||||||
{
|
{
|
||||||
Hashtable result = (Hashtable)results[period];
|
|
||||||
// Create a new object to return
|
// Create a new object to return
|
||||||
VisitorData data = new VisitorData();
|
VisitorData data = new VisitorData();
|
||||||
|
|
||||||
|
// Set Period Date
|
||||||
DateTime date = new DateTime(1900, 1, 1);
|
DateTime date = new DateTime(1900, 1, 1);
|
||||||
DateTime.TryParse(period, out date);
|
DateTime.TryParse(period, out date);
|
||||||
data.Date = date;
|
data.Date = date;
|
||||||
|
|
||||||
int UniqueVisitors = 0;
|
// Pull Out Data
|
||||||
int.TryParse(result["nb_uniq_visitors"].ToString(), out UniqueVisitors);
|
if (results[period].GetType() == typeof(Hashtable))
|
||||||
data.UniqueVisitors = UniqueVisitors;
|
{
|
||||||
|
Hashtable result = (Hashtable) results[period];
|
||||||
|
|
||||||
int visits = 0;
|
int UniqueVisitors = 0;
|
||||||
int.TryParse(result[VisitsSummary.NB_VISITS].ToString(), out visits);
|
int.TryParse(result["nb_uniq_visitors"].ToString(), out UniqueVisitors);
|
||||||
data.Visits = visits;
|
data.UniqueVisitors = UniqueVisitors;
|
||||||
|
|
||||||
int VisitsConverted = 0;
|
int visits = 0;
|
||||||
int.TryParse(result[VisitsSummary.NB_VISITS_CONVERTED].ToString(), out VisitsConverted);
|
int.TryParse(result[VisitsSummary.NB_VISITS].ToString(), out visits);
|
||||||
data.VisitsConverted = VisitsConverted;
|
data.Visits = visits;
|
||||||
|
|
||||||
int Actions = 0;
|
int VisitsConverted = 0;
|
||||||
int.TryParse(result[VisitsSummary.NB_ACTIONS].ToString(), out Actions);
|
int.TryParse(result[VisitsSummary.NB_VISITS_CONVERTED].ToString(), out VisitsConverted);
|
||||||
data.Actions = Actions;
|
data.VisitsConverted = VisitsConverted;
|
||||||
|
|
||||||
decimal ActionsPerVisit = 0;
|
int Actions = 0;
|
||||||
decimal.TryParse(result[VisitsSummary.NB_ACTIONS_PER_VISIT].ToString(), out ActionsPerVisit);
|
int.TryParse(result[VisitsSummary.NB_ACTIONS].ToString(), out Actions);
|
||||||
data.ActionsPerVisit = ActionsPerVisit;
|
data.Actions = Actions;
|
||||||
|
|
||||||
int MaxActions = 0;
|
decimal ActionsPerVisit = 0;
|
||||||
int.TryParse(result[VisitsSummary.MAX_ACTIONS].ToString(), out MaxActions);
|
decimal.TryParse(result[VisitsSummary.NB_ACTIONS_PER_VISIT].ToString(), out ActionsPerVisit);
|
||||||
data.MaxActions = MaxActions;
|
data.ActionsPerVisit = ActionsPerVisit;
|
||||||
|
|
||||||
int BounceCount = 0;
|
int MaxActions = 0;
|
||||||
int.TryParse(result[VisitsSummary.BOUNCE_COUNT].ToString(), out BounceCount);
|
int.TryParse(result[VisitsSummary.MAX_ACTIONS].ToString(), out MaxActions);
|
||||||
data.BounceCount = BounceCount;
|
data.MaxActions = MaxActions;
|
||||||
|
|
||||||
data.BounceRate = result[VisitsSummary.BOUNCE_RATE].ToString();
|
|
||||||
|
|
||||||
int AverageTimeOnSite = 0;
|
int BounceCount = 0;
|
||||||
int.TryParse(result[VisitsSummary.AVG_TIME_ON_SITE].ToString(), out AverageTimeOnSite);
|
int.TryParse(result[VisitsSummary.BOUNCE_COUNT].ToString(), out BounceCount);
|
||||||
data.AverageTimeOnSite = AverageTimeOnSite;
|
data.BounceCount = BounceCount;
|
||||||
|
|
||||||
int VisitLengthTotal = 0;
|
data.BounceRate = result[VisitsSummary.BOUNCE_RATE].ToString();
|
||||||
int.TryParse(result[VisitsSummary.SUM_VISIT_LENGTH].ToString(), out VisitLengthTotal);
|
|
||||||
data.VisitLengthTotal = VisitLengthTotal;
|
int AverageTimeOnSite = 0;
|
||||||
|
int.TryParse(result[VisitsSummary.AVG_TIME_ON_SITE].ToString(), out AverageTimeOnSite);
|
||||||
|
data.AverageTimeOnSite = AverageTimeOnSite;
|
||||||
|
|
||||||
|
int VisitLengthTotal = 0;
|
||||||
|
int.TryParse(result[VisitsSummary.SUM_VISIT_LENGTH].ToString(), out VisitLengthTotal);
|
||||||
|
data.VisitLengthTotal = VisitLengthTotal;
|
||||||
|
}
|
||||||
|
|
||||||
visitorData.Add(data);
|
visitorData.Add(data);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -19,5 +19,20 @@ namespace Teknik.Piwik
|
|||||||
public string BounceRate { get; set; }
|
public string BounceRate { get; set; }
|
||||||
public int AverageTimeOnSite { get; set; }
|
public int AverageTimeOnSite { get; set; }
|
||||||
public int VisitLengthTotal { get; set; }
|
public int VisitLengthTotal { get; set; }
|
||||||
|
|
||||||
|
public VisitorData()
|
||||||
|
{
|
||||||
|
Date = DateTime.Now;
|
||||||
|
UniqueVisitors = 0;
|
||||||
|
Visits = 0;
|
||||||
|
VisitsConverted = 0;
|
||||||
|
Actions = 0;
|
||||||
|
ActionsPerVisit = 0;
|
||||||
|
MaxActions = 0;
|
||||||
|
BounceCount = 0;
|
||||||
|
BounceRate = string.Empty;
|
||||||
|
AverageTimeOnSite = 0;
|
||||||
|
VisitLengthTotal = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user