File: D:/web/circ.itp/referrers.asp
<%Option Explicit%>
<!--#include file="dbfunctions.asp"-->
<!--#include file="apputils.asp"-->
<html>
<head>
<title>Referrers</title>
<link href="referrers.css" rel="stylesheet" type="text/css">
</head>
<body>
<form name="frmMain" action="referrers.asp">
<%
' (SS,29/6/07) added end date, changed search to search in referrer and querystring fields too
OpenDatabase
' Had problems GetQueryValue when DISTINCT and Date functions used '
' e.g. DATE_FORMAT(DateTime, '%d/%m/%Y') AS DateOfReferrer '
' GetQueryValue("DateOfReferrer") would return ????? '
' So decided to add a new Date field '
Dim LSQL
LSQL = ("SELECT DISTINCT Date FROM referrers ORDER BY Date")
Dim LStartDate, LEndDate
LStartDate = Request("startdate")
If LStartDate = "" Then LStartDate = Date
LEndDate = Request("enddate")
If LEndDate = "" Then LEndDate = LStartDate
Response.Write(GetLookupCombo(LSQL, "Date", "", LStartDate, False, "startdate", " onchange=""this.form.submit()""", ""))
Response.Write(GetLookupCombo(LSQL, "Date", "", LEndDate, False, "enddate", " onchange=""this.form.submit()""", ""))
%>
<input type="text" name="search" value="<%=Request("search")%>">
<input type="submit" name="btnSubmit" value="Submit">
</form>
<%
If LStartDate <> "" Then
Dim LStartMySQLDate, LEndMySQLDate
LStartMySQLDate = Year(LStartDate) & "-" & Month(LStartDate) & "-" & Day(LStartDate)
LEndMySQLDate = Year(LEndDate) & "-" & Month(LEndDate) & "-" & Day(LEndDate)
LSQL = "SELECT * FROM referrers WHERE Date >= '" & LStartMySQLDate & "' AND Date <= '" & LEndMySQLDate & "'"
If Request("search") <> "" Then
LSQL = LSQL + " AND (UserAgent LIKE '%" + CleanSQLStr(Request("search")) + "%' "
' (SS,28/6/07) added search in Referrer and QueryString as well
LSQL = LSQL + "OR Referrer LIKE '%" + CleanSQLStr(Request("search")) + "%' "
LSQL = LSQL + "OR QueryString LIKE '%" + CleanSQLStr(Request("search")) + "%')"
End If
LSQL = LSQL + " ORDER BY DateTime"
OpenQuery(LSQL)
%>
<table>
<%
Response.Write("<tr>")
Response.Write("<td nowrap><b>" & "Date Time" & "</b></td>")
Response.Write("<td nowrap><b>" & "Referrer" & "</b></td>")
Response.Write("<td nowrap><b>" & "URL" & "</b></td>")
Response.Write("<td nowrap><b>" & "QueryString" & "</b></td>")
Response.Write("<td nowrap><b>" & "UserAgent" & "</b></td>")
Response.Write("<td nowrap><b>" & "SessionID" & "</b></td>")
Response.Write("<td nowrap><b>" & "IPAddress" & "</b></td>")
Response.Write("</tr>")
%>
<%
Dim LCount
LCount = 0
Do While Not EndOfQuery
LCount = LCount + 1
Response.Write("<tr>")
Response.Write("<td nowrap>" & GetQueryValue("DateTime") & "</td>")
Response.Write("<td nowrap>" & GetQueryValue("Referrer") & "</td>")
Response.Write("<td nowrap>" & GetQueryValue("URL") & "</td>")
Response.Write("<td nowrap>" & GetQueryValue("QueryString") & "</td>")
Response.Write("<td nowrap>" & GetQueryValue("UserAgent") & "</td>")
Response.Write("<td nowrap>" & GetQueryValue("SessionID") & "</td>")
Response.Write("<td nowrap>" & GetQueryValue("IPAddress") & "</td>")
Response.Write("</tr>")
NextQueryRecord
Loop
Response.Write("<tr><td nowrap colspan=7>")
Response.Write("Total Records: <b>" & LCount& "</b>")
Response.Write("</td></tr>")
%>
</table>
<%
CloseQuery
End If
CloseDatabase
%>
</body>
</html>