%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
'*** Pure ASP File Upload -----------------------------------------------------
' Copyright (c) 2001-2002 George Petrov, www.UDzone.com
' Process the upload
' Version: 2.0.9
'------------------------------------------------------------------------------
'*** File Upload to: """../newlistings/listings""", Extensions: "GIF,JPG,JPEG,BMP,PNG", Form: form1, Redirect: "", "file", "", "over", "false", "", "" , "", "", "", "", "600", "blueFlashProgress.htm", "300", "100"
Dim GP_redirectPage, RequestBin, UploadQueryString, GP_uploadAction, UploadRequest
PureUploadSetup
If (CStr(Request.QueryString("GP_upload")) <> "") Then
on error resume next
Dim reqPureUploadVersion, foundPureUploadVersion
reqPureUploadVersion = 2.09
foundPureUploadVersion = getPureUploadVersion()
if err or reqPureUploadVersion > foundPureUploadVersion then
Response.Write "You don't have latest version of ScriptLibrary/incPureUpload.asp uploaded on the server. "
Response.Write "This library is required for the current page. It is fully backwards compatible so old pages will work as well. "
Response.End
end if
on error goto 0
GP_redirectPage = ""
Server.ScriptTimeout = 600
RequestBin = Request.BinaryRead(Request.TotalBytes)
Set UploadRequest = CreateObject("Scripting.Dictionary")
BuildUploadRequest RequestBin, """../newlistings/listings""", "file", "", "over"
If (GP_redirectPage <> "" and not (CStr(UploadFormRequest("MM_insert")) <> "" or CStr(UploadFormRequest("MM_update")) <> "")) Then
If (InStr(1, GP_redirectPage, "?", vbTextCompare) = 0 And UploadQueryString <> "") Then
GP_redirectPage = GP_redirectPage & "?" & UploadQueryString
End If
Response.Redirect(GP_redirectPage)
end if
else
if UploadQueryString <> "" then
UploadQueryString = UploadQueryString & "&GP_upload=true"
else
UploadQueryString = "GP_upload=true"
end if
end if
' End Pure Upload
'------------------------------------------------------------------------------
%>
<%
' *** Edit Operations: (Modified for File Upload) declare variables
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (UploadQueryString <> "") Then
MM_editAction = MM_editAction & "?" & UploadQueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: (Modified for File Upload) set variables
If (CStr(UploadFormRequest("MM_insert")) = "form1") Then
MM_editConnection = MM_connFreitas_STRING
MM_editTable = "Listings"
MM_editRedirectUrl = "controlpanel.htm"
MM_fieldsStr = "txtMLSID|value|txtRealtor|value|selCategory|value|txtAddress|value|selCity|value|txtState|value|selZip|value|txtBeds|value|txtBaths|value|txtGarage|value|txtAcreage|value|txtSqFt|value|txtPrice|value|txtShortDescription|value|txtLongDescription|value|txtVirtualTourAddress|value|selStatus|value|fileImageSmall|value|fileImageLarge1|value|fileImageLarge2|value|fileImageLarge3|value|fileImageLarge4|value|fileImageLarge5|value|fileImageLarge6|value|fileImageLarge7|value|fileImageLarge8|value|fileImageLarge9|value"
MM_columnsStr = "MLSID|',none,''|Realtor|',none,''|Category|',none,''|Address|',none,''|City|',none,''|State|',none,''|Zip|',none,''|Beds|',none,''|Baths|',none,''|Garage|',none,''|Acreage|',none,''|SquareFt|',none,''|Price|none,none,NULL|ShortDescription|',none,''|LongDescription|',none,''|VirtualTourLink|',none,''|Status|',none,''|SmallImage|',none,''|LargeImage|',none,''|LargeImage2|',none,''|LargeImage3|',none,''|LargeImage4|',none,''|LargeImage5|',none,''|LargeImage6|',none,''|LargeImage7|',none,''|LargeImage8|',none,''|LargeImage9|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(UploadFormRequest(MM_fields(MM_i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And UploadQueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And UploadQueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & UploadQueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & UploadQueryString
End If
End If
End If
%>
<%
' *** Insert Record: (Modified for File Upload) construct a sql insert statement and execute it
Dim MM_tableValues
Dim MM_dbValues
If (CStr(UploadFormRequest("MM_insert")) <> "") Then
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<%
Dim rsListings
Dim rsListings_numRows
Set rsListings = Server.CreateObject("ADODB.Recordset")
rsListings.ActiveConnection = MM_connFreitas_STRING
rsListings.Source = "SELECT * FROM Listings"
rsListings.CursorType = 0
rsListings.CursorLocation = 2
rsListings.LockType = 1
rsListings.Open()
rsListings_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
rsListings_numRows = rsListings_numRows + Repeat1__numRows
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
Dim MM_keepNone
Dim MM_keepURL
Dim MM_keepForm
Dim MM_keepBoth
Dim MM_removeList
Dim MM_item
Dim MM_nextItem
' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then
MM_removeList = MM_removeList & "&" & MM_paramName & "="
End If
MM_keepURL=""
MM_keepForm=""
MM_keepBoth=""
MM_keepNone=""
' add the URL parameters to the MM_keepURL string
For Each MM_item In Request.QueryString
MM_nextItem = "&" & MM_item & "="
If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.QueryString(MM_item))
End If
Next
' add the Form variables to the MM_keepForm string
For Each MM_item In Request.Form
MM_nextItem = "&" & MM_item & "="
If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.Form(MM_item))
End If
Next
' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
If (MM_keepBoth <> "") Then
MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
End If
If (MM_keepURL <> "") Then
MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)
End If
If (MM_keepForm <> "") Then
MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
End If
' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
If (firstItem <> "") Then
MM_joinChar = "&"
Else
MM_joinChar = ""
End If
End Function
%>