Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 24th, 2012  |  syntax: ASP  |  size: 2.41 KB  |  hits: 33  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <%
  2.  
  3. Dim landing_page, host_url
  4. Dim fso, outfile, filename, dirname, myFolder
  5. Dim req_method, key, value
  6. Dim bErr, errStr, bEmpty
  7. On Error resume next
  8. bErr = false
  9. bEmpty = true
  10. errStr = ""
  11. Set fso = Server.CreateObject("Scripting.FileSystemObject")
  12. host_url = Request.ServerVariables("HTTP_HOST")
  13. req_method = Request.ServerVariables("REQUEST_METHOD")
  14. dtNow = Now()
  15. filename = Server.MapPath("\ssfm")
  16. dirname = filename
  17. filename = filename & "\gdform_" & DatePart("M", dtNow) & DatePart("D", dtNow) & DatePart("YYYY", dtNow) & DatePart("N", dtNow) & DatePart("S", dtNow)
  18.  
  19. Function FormatVariableLine(byval var_name, byVal var_value)
  20.         Dim tmpStr
  21.         tmpStr = tmpStr & "<GDFORM_VARIABLE NAME=" & var_name & " START>" & vbCRLF
  22.         tmpStr = tmpStr & var_value & vbCRLF
  23.         tmpStr = tmpStr & "<GDFORM_VARIABLE NAME=" & var_name & " END>"
  24.         FormatVariableLine = tmpStr
  25. end function
  26.  
  27. Sub OutputLine(byVal line)
  28.    outfile.WriteLine(line)
  29. end sub
  30.  
  31. if err.number = 0 then
  32.         Set outfile = fso.CreateTextFile(filename, true, false)
  33.         if err.number <> 0 then
  34.                         bErr = true
  35.                         errStr = "Error creating file! Directory may not be writable or may not exist.<br>Unable to process request."
  36.         else
  37.                 if(req_method = "GET") then
  38.                         for each Item in request.QueryString
  39.                                 if item <> "" then
  40.                                         bEmpty = false
  41.                                         key = item
  42.                                         value = Request.QueryString(item)
  43.                                         if(lcase(key) = "redirect") then
  44.                                                 landing_page = value
  45.                                         else
  46.                                                 line = FormatVariableLine(key, value)
  47.                                                 Call OutputLine(line)
  48.                                         end if
  49.                                 end if 
  50.                         next
  51.                 elseif (req_method = "POST") then
  52.                         for each Item in request.form
  53.                                 if item <> "" then
  54.                                         bEmpty = false
  55.                                         key = item
  56.                                         value = Request.form(item)
  57.                                         if(lcase(key) = "redirect") then
  58.                                                 landing_page = value
  59.                                         else
  60.                                                 line = FormatVariableLine(key, value)
  61.                                                 Call OutputLine(line)
  62.                                         end if
  63.                                 end if 
  64.                         next
  65.                 end if
  66.                 outfile.close
  67.         end if 
  68.         if(bEmpty = true) AND errStr = "" then
  69.                 bErr = true
  70.                 errStr = errStr & "<br>No variables sent to form! Unable to process request."
  71.         end if
  72.         if(bErr = false) then  
  73.                 if (landing_page <> "") then
  74.                         response.Redirect "http://" & host_url & "/" & landing_page
  75.                 else
  76.                         response.Redirect "http://" & host_url 
  77.                 end if
  78.         else
  79.                 Response.Write errStr
  80.         end if 
  81.         set fso = nothing
  82. else
  83.   Response.Write " An Error Occurred creating mail message. Unable to process form request at this time."
  84. end if
  85. %>