Here is the whole code.
any suggestions would be helpfull
<%
dim dsDebugging, dsMailText
Server.ScriptTimeout = 1000
dsDebugging = "yes"
dsCheckBoxFlag = false
dsThumbNailer = true
dsMaxWidth = 4000
' Initialize external objects
set dsFSO = Server.CreateObject("Scripting.FileSystemObject")
if dsThumbNailer then
set dsSF = Server.CreateObject("SfImageResize.ImageResize")
dsSFPro = false
dsSFVer = dsSF.about()
if inStr(dsSFVer, "Professional") then
dsImgCompression = 30
dsImgAlgorithm = 6
dsSFPro = true
end if
end if
dsMappath = server.mappath("uploads\") & "\"
ae = request.querystring("ae")
tID = request.querystring("tID")
pID = request.querystring("pID")
cID = request.querystring("cID")
rID = request.querystring("rID")
dsAnother = cbool(request.form("dsAddAnother"))
' Get the table's title
rst.open "select [Title] from " & dsWebName & "Tables where " & dsWebName & "TablesID = " & tID, cnn, 1, 2
if not rst.eof then
dsTablesTitle = rst("Title")
end if
rst.close
' Open table to add or edit
if (ae = "add") then
' Get the rank of the last record
rst.open "select * from " & dsTablesTitle & " order by Rank desc", cnn, 1, 2
if not rst.eof then
dsRank = rst("Rank")
end if
rst.close
rst.open "select * from " & dsTablesTitle, cnn, 1, 2
rst.addnew
rst("Rank") = dsRank + 1
rst.update
eID = rst(dsTablesTitle & "ID")
rst.close
rst.open "select * from " & dsTablesTitle & " where " & dsTablesTitle & "ID = " & eID, cnn, 1, 2
else
rst.open "select * from " & dsTablesTitle & " where " & dsTablesTitle & "ID = " & pID, cnn, 1, 2
eID = pID
end if
rst("Active") = "yes"
dsLog(ae & " " & eID & " " & tID)
dsIndex = 1
'Open fields
rst2.open "select * from " & dsWebName & "Fields where " & dsWebName & "TablesID = " & tID & " and Display = 'yes' order by Rank, " & dsWebName & "FieldsID", cnn, 1, 2
do while not rst2.eof
dsFieldsTitle = rst2("Title")
dsFieldsDesc = rst2("Desc")
dsFieldsData = request.form(rst2("Required") & ":" & rst2("Type") & ":" & rst2("Title"))
if (rst2("Type") = "username") then
sqltext = "select [" & dsTablesTitle & "ID] from " & dsTablesTitle & " WHERE " & dsFieldsTitle & " = '" & dsFieldsData & "'"
if (ae = "edit") then
sqltext = sqltext & " and " & dsTablesTitle & "ID <> " & pID
end if
rstd.open sqltext, cnn, 1, 2
if not rstd.EOF then
dsNameInUse = true
else
rst(dsFieldsTitle) = dsFieldsData
end if
rstd.close
elseif (rst2("Type") = "image") then
if dsThumbNailer then
if ((ae = "add") or (ae = "edit" and rst(dsFieldsTitle) <> dsFieldsData)) then
dsImageIndex = 0
rstd.open "select [Title] from " & dsWebName & "Fields where " & dsWebName & "TablesID = " & tID & " and Display = 'yes' and Type = 'image'", cnn, 1, 2
do while not rstd.eof
dsImageIndex = dsImageIndex + 1
if (rstd("Title") = dsFieldsTitle) then
rstd.movelast
end if
rstd.movenext
loop
rstd.close
dsThumbName = "thumb_" & tID & "_" & eID & "_" & dsImageIndex & "_"
if (dsFieldsData <> "No File") then
dsSF.LoadFromFile dsMappath & dsFieldsData
if (dsSF.Width >= rst2("Size")) then
dsSF.Width = rst2("Size")
if dsSFPro then
dsSF.Compression = dsImgCompression
dsSF.Algorithm = dsImgAlgorithm
end if
dsSF.DoResize
end if
dsSF.SaveToFile dsMappath & dsThumbName & dsFieldsData
dsLog(ae & " uploads/" & dsThumbName & dsFieldsData)
end if
if (ae = "edit") then
dsPath = dsMappath & dsThumbName & rst(dsFieldsTitle)
if (dsFSO.FileExists(dsPath) = true) then
dsFSO.DeleteFile dsPath, false
end if
end if
end if
end if
rst(dsFieldsTitle) = dsFieldsData
elseif (rst2("Type") = "checkbox") then
'Get Data table information
dsDataTablesTitle = dsFieldsTitle
'Get Dropdown table information
dsDropTablesID = rst2(dsWebName & "RelatedID")
rstd.open "select [Title] from " & dsWebName & "Tables where " & dsWebName & "TablesID = " & dsDropTablesID & " and Active = 'yes'", cnn, 1, 2
if not rstd.eof then
dsDropTablesTitle = rstd("Title")
end if
rstd.close
' Delete existing records
if ae = "edit" then
rstd.open "delete from " & dsDataTablesTitle & " where " & dsTablesTitle & "ID = " & pID, cnn, 1, 2
end if
' Get Form data
dsCheckboxData = split(dsFieldsData, ", ")
dsRankIndex = 1
rstd.open "select [Active], [Rank], [" & dsDropTablesTitle & "ID], [" & dsTablesTitle & "ID] from " & dsDataTablesTitle, cnn, 1, 2
for i = 0 to UBound(dsCheckboxData)
rstd.addnew
rstd("Active") = "yes"
rstd("Rank") = dsRankIndex
rstd(dsDropTablesTitle & "ID") = dsCheckboxData(i)
rstd(dsTablesTitle & "ID") = eID
rstd.update
dsRankIndex = dsRankIndex + 1
next
rstd.close
elseif (rst2("Type") = "modifier") then
dsNewModifiers = dsFieldsData
dsMod = split(dsFieldsTitle, ",")
if (uBound(dsMod) = 3) then
dsModGroup = dsMod(0)
dsModTable = dsMod(1)
dsModPrices = dsMod(2)
dsModCombo = dsMod(3)
end if
if (ae = "edit") then
dsOldModifiers = rst(dsModTable)
if (dsOldModifiers <> "") then
dsOldModArray = split(dsOldModifiers, ",")
else
dim dsOldModArray(0)
dsOldModArray(0) = 0
end if
for i = 0 to uBound(dsOldModArray)
if (instr(" " & dsNewModifiers & ",", " " & cint(dsOldModArray(i)) & ",") = 0) then
rstd.open "select * from " & dsModTable & " where " & dsModGroup & "ID = " & dsOldModArray(i) & " and Active = 'yes' order by Rank", cnn, 1, 2
do while not rstd.eof
cnn.execute ("delete from " & dsModPrices & " where " & dsTablesTitle & "ID = " & eID & " and " & dsModTable & "ID = " & rstd(dsModTable & "ID"))
rstd.movenext
loop
rstd.close
end if
next
end if
if dsNewModifiers <> "" then
dsModifiers = true
end if
rst(dsModTable) = dsNewModifiers
elseif (rst2("Type") = "ftext") then
dsCleanText = replace(dsFieldsData, "<PRE>", "")
dsCleanText = replace(dsCleanText, "</PRE>", "")
dsMailText = dsMailText & dsFieldsDesc & ": " & dsCleanText & vbcrlf
rst(dsFieldsTitle) = dsCleanText
else
dsMailText = dsMailText & dsFieldsDesc & ": " & dsFieldsData & vbcrlf
If not isempty(rstat) then
rst(dsFieldsTitle) = dsFieldsData
end if
if dsDebugging = "yes" then ' If Debugging is on
response.write dsIndex & ") dsFieldsTitle: " & dsFieldsTitle & "<br>dsFieldsData: " & dsFieldsData & "<br><br>"
end if
dsIndex = dsIndex + 1
rst2.movenext
rst2.close
rst.update
rst.close
if (dsThumbNailer) then
set dsSF = nothing
end if
set dsFSO = nothing
cnn.close
if dsModifiers then
response.redirect "ds_modifiers.asp?tID=" & tID & "&pID=" & eID & "&rID=" & rID & "&cID=" & cID & "&an=" & dsAnother
elseif tID = 0 then
Set dsMailer = Server.CreateObject("SMTPsvg.Mailer")
' dsMailer.RemoteHost = "mssql.ixwebhosting.com"
dsMailer.RemoteHost = "69.49.230.7"
dsMailer.FromName = ""
dsMailer.FromAddress = "
[email protected]"
dsMailer.AddRecipient "", "
[email protected]"
' dsMailer.AddRecipient "", "
[email protected]"
dsMailer.Subject = "Contact Form"
dsMailer.BodyText = dsMailText
if dsMailer.SendMail then
dsEmail = "sent"
else
response.write dsMailer.Response
end if
response.redirect "p_changed.asp"
elseif dsNameInUse then ' Existing username
response.redirect "ds_ae.asp?change=true&ae=edit&pID=" & eID & "&tID=" & tID & "&cID=" & cID & "&rID=" & rID
else if dsAnother then
response.redirect "ds_ae.asp?an=true&ae=add&tID=" & tID & "&rID=" & rID & "&pID=" & cID & "&cID=" & cID
else
response.redirect "ds_view.asp?tID=" & tID & "&rID=" & rID & "&pID=" & cID
end if
end if
%>