%@ LANGUAGE = VBScript %><% %><% on error resume next PilotInitialize Dim rsCheck, rs, rsCust, fileName, Reseller, secureURL, rsM, bManuf bManuf = False 'Get secure URL for later and current login info secureURL = g.secureURL 'Get file name i = Decrypt(Request.QueryString("i")) Set rs = cnPILOT.Execute("SELECT DOWNLOAD_FILENAME FROM TBLINVENTORY WHERE ITEMID = "&i&";") fileName = rs("Download_Filename") rs.Close: Set rs = Nothing 'If no file name, redirect back to Gateway If Trim(fileName&"X") = "X" Then 'Do clean up PilotShutOffEngine Response.Redirect"pilot.asp?pg=gateway" Else If Request.QueryString("type") = "c" Then If Not GetCurrentCustomer Then Response.Redirect"pilot.asp?pg=gateway" 'Check to see if customer has purchased and paid for the file strSQL = "SELECT * FROM (tblOrders tord INNER JOIN tblOrdersItems toi ON tord.OrderID" _ & " = toi.OrderID) INNER JOIN tblLogins tlg ON tord.CustID = tlg.CustID " _ & "WHERE tord.CustID = "&cid&" AND toi.ItemID = "&i Set rsCheck = OpenFastRs(strSQL) Paid = False Do Until rsCheck.EOF If rsCheck("Status") = "Ready for Download" Or rsCheck("Status") = "Shipped" Then Paid = True rsCheck.MoveNext Loop rsCheck.Close: Set rsCheck = Nothing 'Is customer a Reseller? Set rsCust = GetCurrentCustomerRs Reseller = False If rsCust("Reseller") Then Reseller = True rsCust.Close: Set rsCust = Nothing If Not Paid And Not Reseller Then Response.Redirect"pilot.asp?pg=gateway" '' see if they've purchased this item in any of their orders placed. this will need to be modified for items with modifiers. '' this is just for digital goods, which don't have modifiers. if we add digital goods with modifiers, we will also have to modify '' the download_filename field in the DB. (design process required) ElseIf Request.QueryString("type") = "m" Then If Not GetCurrentManuf Then Response.Redirect"manufgateway.asp" 'Is this manufacturer who is trying to download one of their products? strSQL = "SELECT ACTUAL_MANUF FROM TBLINVENTORY WHERE ITEMID = "&i Set rsM = OpenFastRs(strSQL) If hasRecords(rsM) Then If rsM(0) = s_lngManufID Then bManuf = True End If rsM.Close: Set rsM = Nothing If Not bManuf Then Response.Redirect "manufgateway.asp" Else Response.Redirect"pilot.asp?pg=gateway" End If 'Do clean up PilotShutOffEngine 'If customer has paid for file or is a reseller, initialize download If Not Paid And Not Reseller And Not bManuf Then Response.Redirect"pilot.asp?pg=gateway" Else Response.ContentType = "application/x-zip" Response.Redirect secureURL&"ftproot/"&filename End If End If %>