<!--#include file="admin/config.asp"-->
<!--#include file="admin/inc_prefs.asp"-->
<%
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Spd E-Letter v4
' © 2001, 2002 PensaWorks, inc.
' For help with this program, please visit http://www.pensaworks.com
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
on error resume next
mlConn.execute("UPDATE ML_Subscribers SET numClicks = 0 WHERE numClicks IS NULL")
if isnumeric(request("l")) then urlID = clng(request("l")) else urlID = 0
if isnumeric(request("i")) then subID = clng(request("i")) else subID = 0
if urlID > 0 then
set urlRecord = mlConn.execute("SELECT * FROM ML_URLs WHERE urlID = " & urlID)
if not urlRecord.eof then
url = trim(urlRecord("urlRedirect")) : 	mesID = urlRecord("MessageID") : urlRecord.Close() : set urlRecord = nothing
mlConn.Execute("UPDATE ML_URLs SET urlClicks = (urlClicks + 1), urlClickedDate = " & cfgDate & " WHERE urlID = " & urlID)
if subID > 0 then
set subRecord = mlConn.execute("SELECT * FROM ML_Subscribers WHERE SubscriberID = " & subID)
if not subRecord.EOF then
subFormat = lcase(trim(left(subRecord("Format"), 1))) : subRecord.Close() : set subRecord = nothing
mlConn.execute("UPDATE ML_Subscribers SET numClicks = (numClicks + 1) WHERE SubscriberID = " & subID)
if prefClicks = 1 then
set chkRecord = mlConn.execute("SELECT * FROM ML_Clicks WHERE clkSubscriberID = " & subID & " AND clkURLID = " & urlID)
if chkRecord.EOF then
mlConn.execute("INSERT INTO ML_Clicks (clkSubscriberID, clkURLID, clkNumTimes, clkLastDate) VALUES (" & subID & "," & urlID & ",1," & cfgDate & ")")
else
mlConn.execute("UPDATE ML_Clicks SET clkNumTimes = (clkNumTimes + 1), clkLastDate = " & cfgDate & " WHERE clkSubscriberID = " & subID & " AND clkURLID = " & urlID)
end if
chkRecord.Close() : set chkRecord = nothing
end if
if prefReads = 1  and lcase(subFormat) = "t" then
set chkRecord = mlConn.execute("SELECT * FROM ML_Reads WHERE readSubscriberID = " & subID & " AND readMessageID = " & mesID)
if chkRecord.EOF then
mlConn.execute("INSERT INTO ML_Reads (readSubscriberID, readMessageID, readNumTimes, readLastDate) VALUES (" & subID & "," & mesID & ",1," & cfgDate & ")")
mlConn.execute("UPDATE ML_Subscribers SET numReads = (numReads + 1) WHERE SubscriberID = " & subID)
else
if DateDiff("s", chkRecord("readLast"), Now) > 600 then
mlConn.execute("UPDATE ML_Reads SET readNumTimes = (readNumTimes + 1), readLastDate = " & cfgDate & " WHERE readSubscriberID = " & subID & " AND readMessageID = " & mesID)
mlConn.execute("UPDATE ML_Subscribers SET numReads = (numReads + 1) WHERE SubscriberID = " & subID)
end if
end if
chkRecord.Close() : set chkRecord = nothing
end if
end if
end if
end if
end if
url = replace(url, "#subscriberid#", subID, 1, -1, 1)
if (trim(url) <> "") then response.redirect url
response.redirect rootURL
%>
<title>Error: Cannot Redirect</title><meta http-equiv="refresh" content="0;URL=<%=RootURL%>">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">There has been an error and you will be redirected momentarily. If this page does not automatically refresh, please click <a href="<%=RootURL%>">here</a>. If this error continues, please notify the list <a href="mailto:<%=DefaultEmail%>">administrator</a>.</font>