-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathCached.aspx.cs
More file actions
105 lines (94 loc) · 4.52 KB
/
Cached.aspx.cs
File metadata and controls
105 lines (94 loc) · 4.52 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
#region License : arachnode.net
// // Copyright (c) 2015 http://arachnode.net, arachnode.net, LLC
// //
// // Permission is hereby granted, upon purchase, to any person
// // obtaining a copy of this software and associated documentation
// // files (the "Software"), to deal in the Software without
// // restriction, including without limitation the rights to use,
// // copy, merge and modify copies of the Software, and to permit persons
// // to whom the Software is furnished to do so, subject to the following
// // conditions:
// //
// // LICENSE (ALL VERSIONS/EDITIONS): http://arachnode.net/r.ashx?3
// //
// // The above copyright notice and this permission notice shall be
// // included in all copies or substantial portions of the Software.
// //
// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// // OTHER DEALINGS IN THE SOFTWARE.
#endregion
#region
using System;
using System.IO;
using System.Text;
using System.Web;
using System.Web.UI;
using Arachnode.Configuration;
using Arachnode.DataAccess;
using Arachnode.DataAccess.Value.Interfaces;
using Arachnode.DataSource;
using Arachnode.Security;
using Arachnode.SiteCrawler.Managers;
using Arachnode.SiteCrawler.Value.Enums;
#endregion
namespace Arachnode.Web
{
public partial class Cached : PageBase
{
/// <summary>
/// Handles the Load event of the Page control.
/// </summary>
/// <param name = "sender">The source of the event.</param>
/// <param name = "e">The <see cref = "System.EventArgs" /> instance containing the event data.</param>
protected void Page_Load(object sender, EventArgs e)
{
EnableViewState = false;
try
{
if (Request.QueryString.Count == 5 && Request.QueryString.AllKeys[0] == "discoveryID" && Request.QueryString.AllKeys[1] == "absoluteUri" && Request.QueryString.AllKeys[2] == "webPage" && Request.QueryString.AllKeys[3] == "codePage" && Request.QueryString.AllKeys[4] == "fullTextIndexType")
{
string source = null;
if(File.Exists(Encryption.DecryptRijndaelManaged(Request.QueryString["webPage"])))
{
source = File.ReadAllText(Encryption.DecryptRijndaelManaged(Request.QueryString["webPage"]), Encoding.GetEncoding(int.Parse(Request.QueryString["codePage"])));
}
else
{
ArachnodeDataSet.WebPagesRow webPagesRow = ArachnodeDAO.GetWebPage(Request.QueryString["discoveryID"]);
if (webPagesRow != null && webPagesRow.Source.Length != 0)
{
source = Encoding.GetEncoding(webPagesRow.CodePage).GetString(webPagesRow.Source);
}
}
if (source != null)
{
//ANODET: Should this be a configuration setting? Perhaps - hotlinking isn't exactly polite, but does provide the best user experience. (Version 1.5)
uxLWebPage.Text = HtmlManager.CreateHtmlDocument(Request.QueryString["absoluteUri"], Request.QueryString["fullTextIndexType"], source, UriQualificationType.AbsoluteWhenDownloadedDiscoveryIsUnavailable, ArachnodeDAO, false).DocumentNode.OuterHtml;
}
else
{
uxLWebPage.Text = "The WebPage source was not found in the database or on disk.";
try
{
throw new Exception("The WebPage source for " + HttpUtility.UrlDecode(Request.QueryString["absoluteUri"]) + " was not found in the database or on disk.");
}
catch (Exception exception)
{
ArachnodeDAO.InsertException(null, null, exception, false);
}
}
}
}
catch (Exception exception)
{
ArachnodeDAO.InsertException(null, null, exception, false);
}
}
}
}