<% If Request("id") <> "" Then FileID = Cint(Request("id")) End If 'Assume they have downloaded the file before hasdownloaded = True ' Now, do we have a cookie? if yes set up file download If Request.Cookies("Visited") <> "" then Set m_rs = Server.CreateObject("ADODB.Recordset") sql = "SELECT * FROM Users where userid=" & Request.Cookies("Visited") m_rs.Open sql, OpenConn, adOpenStatic, adLockOptimistic, adCmdText if not m_rs.bof and not m_rs.eof then hascookie = true UserID = m_rs("userid") Response.Cookies("Visited").Expires = DateAdd("yyyy", 1, Now) end if m_rs.close set m_rs = nothing else hascookie = false End If 'If there was no cookie found and the form has been submitted If not hascookie and Request("submit") <> "" Then Set m_rs = Server.CreateObject("ADODB.Recordset") sql = "SELECT * FROM Users where Firstname='" & Replace(Request("firstname"),"'","''") & "' AND lastname='" & Replace(Request("lastname"),"'","''") & "' AND company='" & Replace(Request("company"),"'","''") & "' AND email='" & Replace(Request("email"),"'","''") & "'" m_rs.Open sql, OpenConn, adOpenStatic, adLockOptimistic, adCmdText if not m_rs.bof and not m_rs.eof then 'User exists set cookie Response.Cookies("Visited").Expires = DateAdd("yyyy", 1, Now) Response.Cookies("Visited") = m_rs("userid") UserID= m_rs("userid") hascookie=true else 'create user and setup a cookie m_rs.addnew m_rs("firstname") = Request("firstname") m_rs("lastname") = Request("lastname") m_rs("company") = Request("company") m_rs("email") = Request("email") m_rs.update m_rs.close 'setup the cookie sql = "SELECT IDENT_CURRENT('Users') AS insertid" m_rs.Open sql, OpenConn, adOpenStatic, adLockReadOnly, adCmdText Response.Cookies("Visited").Expires = DateAdd("yyyy", 1, Now) Response.Cookies("Visited") = m_rs("insertid") UserID = m_rs("insertid") hascookie = True m_rs.close end if set m_rs = nothing End If If hascookie or Request("submit") <> "" Then 'Check to see if this user has downloaded the file before Set m_rs = Server.CreateObject("ADODB.Recordset") sql = "SELECT * FROM Downloads where fileid=" & FileID & " AND userid=" & UserID 'response.write sql m_rs.Open sql, OpenConn, adOpenStatic, adLockOptimistic, adCmdText if not m_rs.bof and not m_rs.eof then 'User has already downloaded the file hasdownloaded = true else m_rs.addnew m_rs("fileid") = FileID m_rs("userid") = UserID m_rs("downloaddate") = now m_rs.update hasdownloaded = false end if m_rs.close set m_rs = nothing End If 'Update the File download count and download date if user hasn't already downloaded If not hasdownloaded Then Set m_rs = Server.CreateObject("ADODB.Recordset") sql = "SELECT * FROM Files where fileid=" & FileID m_rs.Open sql, OpenConn, adOpenStatic, adLockOptimistic, adCmdText if not m_rs.bof and not m_rs.eof then m_rs("lastdownloaddate") = now m_rs("Downloadcount") = m_rs("Downloadcount") +1 m_rs.update end if m_rs.close set m_rs = nothing End If 'Grab the filename so we can link to the file If hascookie or Request("submit") <> "" Then Set m_rs = Server.CreateObject("ADODB.Recordset") sql = "SELECT * FROM Files where fileid=" & FileID m_rs.Open sql, OpenConn, adOpenStatic, adLockOptimistic, adCmdText if not m_rs.bof and not m_rs.eof then 'User has already downloaded the file Filename = m_rs("filename") end if m_rs.close set m_rs = nothing End If ' Draw a form to fill out if no cookie is present If not hascookie Then %>
"/>
Please enter your information to proceed with the download.
First Name: " />
Last Name: " />
Company/University: " />
Email: " />
Note: By submitting your email address and information to SIA you are consenting to receive future email communications from SIA. For more information on this Opt-In email service and the details of what you are consenting to, click here. Thank you.
Don't worry we will honor your request for completely opting out, or, for limiting the types of communications should you wish to do that at a later time, via our preference page.
 
<% Else %>

Click Here to download the file.

<% End If %>