forked from kipusoep/UrlTracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUrlTrackerSettings.cs
More file actions
217 lines (207 loc) · 8.07 KB
/
UrlTrackerSettings.cs
File metadata and controls
217 lines (207 loc) · 8.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using umbraco;
namespace InfoCaster.Umbraco.UrlTracker
{
public static class UrlTrackerSettings
{
public const string TableName = "icUrlTracker";
public const string OldTableName = "infocaster301";
public const string HttpModuleCheck = "890B748D-E226-49FA-A0D7-9AFD3A359F88";
/// <summary>
/// Returns wether or not the UrlTracker is disabled
/// </summary>
/// <remarks>
/// appSetting: 'urlTracker:disabled'
/// </remarks>
public static bool IsDisabled
{
get
{
if (!_isDisabled.HasValue)
{
bool isDisabled = false;
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["urlTracker:disabled"]))
{
bool parsedAppSetting;
if (bool.TryParse(ConfigurationManager.AppSettings["urlTracker:disabled"], out parsedAppSetting))
isDisabled = parsedAppSetting;
}
_isDisabled = isDisabled;
}
return _isDisabled.Value;
}
}
/// <summary>
/// Returns wether or not logging for the UrlTracker is enabled
/// </summary>
/// <remarks>
/// appSettings: 'urlTracker:enableLogging' & 'umbracoDebugMode'
/// </remarks>
public static bool EnableLogging
{
get
{
if (!_enableLogging.HasValue)
{
bool enableLogging = false;
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["urlTracker:enableLogging"]))
{
bool parsedAppSetting;
if (bool.TryParse(ConfigurationManager.AppSettings["urlTracker:enableLogging"], out parsedAppSetting))
enableLogging = parsedAppSetting;
}
_enableLogging = enableLogging;
}
return _enableLogging.Value && GlobalSettings.DebugMode;
}
}
/// <summary>
/// Returns the URLs to ignore for 404 Not Found logging
/// </summary>
/// <remarks>
/// appSetting: 'urlTracker:404UrlsToIgnore'
/// </remarks>
public static string[] NotFoundUrlsToIgnore
{
get
{
if (_notFoundUrlsToIgnore == null)
{
_notFoundUrlsToIgnore = new string[] { "favicon.ico" };
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["urlTracker:404UrlsToIgnore"]))
_notFoundUrlsToIgnore = _notFoundUrlsToIgnore.Union(ConfigurationManager.AppSettings["urlTracker:404UrlsToIgnore"].Split(',')).ToArray();
}
return _notFoundUrlsToIgnore;
}
}
/// <summary>
/// Returns the regex patterns for NotFound urls to ignore
/// </summary>
public static Regex[] RegexNotFoundUrlsToIgnore
{
get
{
return new Regex[] { new Regex("__browserLink/requestData/.*", RegexOptions.Compiled), new Regex("[^/]/arterySignalR/ping", RegexOptions.Compiled) };
}
}
/// <summary>
/// Returns the UrlTracker UI URL to ignore as referrer
/// </summary>
public static string ReferrerToIgnore
{
get { return "Umbraco/UrlTracker/InfoCaster.Umbraco.UrlTracker.UI"; }
}
/// <summary>
/// Returns wether or not tracking URL changes is disabled
/// </summary>
/// <remarks>
/// appSetting: 'urlTracker:trackingDisabled'
/// </remarks>
public static bool IsTrackingDisabled
{
get
{
if (!_isTrackingDisabled.HasValue)
{
bool isTrackingDisabled = false;
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["urlTracker:trackingDisabled"]))
{
bool parsedAppSetting;
if (bool.TryParse(ConfigurationManager.AppSettings["urlTracker:trackingDisabled"], out parsedAppSetting))
isTrackingDisabled = parsedAppSetting;
}
_isTrackingDisabled = isTrackingDisabled;
}
return _isTrackingDisabled.Value;
}
}
/// <summary>
/// Returns wether or not not found (404) tracking is disabled
/// </summary>
/// <remarks>
/// appSetting: 'urlTracker:notFoundTrackingDisabled'
/// </remarks>
public static bool IsNotFoundTrackingDisabled
{
get
{
if (!_isNotFoundTrackingDisabled.HasValue)
{
bool isNotFoundTrackingDisabled = false;
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["urlTracker:notFoundTrackingDisabled"]))
{
bool parsedAppSetting;
if (bool.TryParse(ConfigurationManager.AppSettings["urlTracker:notFoundTrackingDisabled"], out parsedAppSetting))
isNotFoundTrackingDisabled = parsedAppSetting;
}
_isNotFoundTrackingDisabled = isNotFoundTrackingDisabled;
}
return _isNotFoundTrackingDisabled.Value;
}
}
/// <summary>
/// Gets a value indicating whether or not to append port numbers to URLs. Default is true.
/// </summary>
/// <value>
/// <c>true</c> if we are to append the port number; otherwise, <c>false</c>.
/// </value>
public static bool AppendPortNumber
{
get
{
if (!_appendPortNumber.HasValue)
{
bool appendPortNumber = true;
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["urlTracker:appendPortNumber"]))
{
bool parsedAppSetting;
if (bool.TryParse(
ConfigurationManager.AppSettings["urlTracker:appendPortNumber"],
out parsedAppSetting))
{
appendPortNumber = parsedAppSetting;
}
}
_appendPortNumber = appendPortNumber;
}
return _appendPortNumber.Value;
}
}
/// <summary>
/// Returns wether or not a child node has a domain configured
/// </summary>
/// <remarks>
/// appSetting: 'urlTracker:hasDomainOnChildNode'
/// </remarks>
public static bool HasDomainOnChildNode
{
get
{
if (!_hasDomainOnChildNode.HasValue)
{
var hasDomainOnChildNode = false;
if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["urlTracker:hasDomainOnChildNode"]))
{
bool parsedAppSetting;
if (bool.TryParse(ConfigurationManager.AppSettings["urlTracker:hasDomainOnChildNode"], out parsedAppSetting))
hasDomainOnChildNode = parsedAppSetting;
}
_hasDomainOnChildNode = hasDomainOnChildNode;
}
return _hasDomainOnChildNode.Value;
}
}
static bool? _isDisabled;
static bool? _enableLogging;
static string[] _notFoundUrlsToIgnore;
static bool? _isTrackingDisabled;
static bool? _isNotFoundTrackingDisabled;
static bool? _appendPortNumber;
static bool? _hasDomainOnChildNode;
}
}