%@ Language=VBScript %>
<%
'*************************************************************************
' DO NOT MODIFY THIS SCRIPT IF YOU WANT UPDATES TO WORK!
' Function : Create/Modify Accounts
' Product : CandyPress Store Frontend
' Version : 2.5
' Modified : February 2004
' Copyright: Copyright (C) 2004 CandyPress.Com
' See "license.txt" for this product for details regarding
' licensing, usage, disclaimers, distribution and general
' copyright requirements. If you don't have a copy of this
' file, you may request one at webmaster@candypress.com
'*************************************************************************
Option explicit
Response.Buffer = true
%>
<%
'Work fields
dim f
dim arrayErrors
dim action
dim formID
'Customer
dim status
dim Name
dim LastName
dim CustomerCompany
dim Phone
dim Email
dim Password
dim Address
dim City
dim Zip
dim locState
dim locState2
dim locCountry
dim paymentType
dim shippingName
dim shippingLastName
dim shippingPhone
dim shippingAddress
dim ShippingCity
dim shippingZip
dim shippingLocState
dim shippingLocState2
dim shippingLocCountry
dim futureMail
dim taxExempt
dim affiliate
'Locations
dim locName
'Database
dim mySQL
dim conntemp
dim rstemp
dim rstemp2
'Session
dim idOrder
dim idCust
'*************************************************************************
'Open Database Connection
call openDb()
'Store Configuration
if loadConfig() = false then
call errorDB(langErrConfig,"")
end if
'Get/Set Cart/Order Session
idOrder = sessionCart()
'Get/Set Customer Session
idCust = sessionCust()
'Check action indicator
action = lCase(Request("action"))
if action <> "newacc" _
and action <> "newaff" _
and action <> "modify" _
and action <> "save" _
and action <> "checkout" then
response.redirect "sysMsg.asp?errMsg=" & server.URLEncode(langErrAction)
end if
'If Checkout or Save, do some validations.
if action = "checkout" or action = "save" then
'Check if the session is still active
if isNull(idOrder) then
response.redirect "sysMsg.asp?errMsg=" & server.URLEncode(langErrCartEmpty)
end if
'Check if cart has any items
if cartQty(idOrder) = 0 then
response.redirect "sysMsg.asp?errMsg=" & server.URLEncode(langErrCartEmpty)
end if
'Check if minimum order amount has been met (checkout only)
if action = "checkout" then
if cartTotal(idOrder,0) < pMinCartAmount then
response.redirect "sysMsg.asp?errMsg=" & server.URLEncode(langErrMinPrice & pCurrencySign & moneyS(pMinCartAmount))
end if
end if
end if
'If Modify, do some validations.
if action = "modify" then
'Check that Customer is logged on
if isNull(idCust) then
response.redirect "sysMsg.asp?errMsg=" & server.URLEncode(langErrNotLoggedIn)
end if
end if
'Get Form ID
formID = trim(Request.Form("formID"))
'Get State and Country arrays
call getStateArray()
call getCountryArray()
'Check Country array
if not isArray(countryArr) then
response.redirect "sysMsg.asp?errMsg=" & server.URLEncode(langErrCountry)
end if
'Before we display the form, see if we can pre-populate some fields
if formID = "" then
'Default Country Code
locCountry = defaultCountryCode
'Check if user is already logged on
if not isNull(idCust) then
'Retrieve field values from DB
mySQL = "SELECT Name,LastName,CustomerCompany,Phone,Email," _
& " Password,Address,City,Zip,locCountry,locState," _
& " locState2,paymentType,shippingName,shippingLastName," _
& " shippingPhone,shippingAddress,ShippingCity," _
& " shippingZip,shippingLocCountry,shippingLocState," _
& " shippingLocState2,futureMail " _
& "FROM customer " _
& "WHERE idCust = " & validSQL(idCust,"I")
set rsTemp = openRSexecute(mySQL)
if not rsTemp.EOF then
Name = trim(rstemp("name")&"")
LastName = trim(rstemp("LastName")&"")
CustomerCompany = trim(rstemp("CustomerCompany")&"")
Phone = trim(rstemp("Phone")&"")
Email = trim(rstemp("Email")&"")
Password = trim(EnDeCrypt(Hex2Ascii(rstemp("Password")),rc4Key)&"")
Address = trim(rstemp("Address")&"")
City = trim(rstemp("City")&"")
Zip = trim(rstemp("Zip")&"")
locState = trim(rstemp("locState")&"")
locState2 = trim(rstemp("locState2")&"")
locCountry = trim(rstemp("locCountry")&"")
paymentType = trim(rstemp("paymentType")&"")
shippingName = trim(rstemp("shippingName")&"")
shippingLastName = trim(rstemp("shippingLastName")&"")
shippingPhone = trim(rstemp("shippingPhone")&"")
shippingAddress = trim(rstemp("shippingAddress")&"")
ShippingCity = trim(rstemp("ShippingCity")&"")
shippingZip = trim(rstemp("shippingZip")&"")
shippingLocState = trim(rstemp("shippingLocState")&"")
shippingLocState2 = trim(rstemp("shippingLocState2")&"")
shippingLocCountry = trim(rstemp("shippingLocCountry")&"")
futureMail = trim(rstemp("futureMail")&"")
else
'No Customer Record on DB (which is highly unlikely because
'Customer record has already been tested in sessionCust()
'at the beginning of this script).
response.redirect "sysMsg.asp?errMsg=" & server.URLEncode(langErrInvCustAcc)
end if
call closeRS(rsTemp)
end if
end if
'Check if the Customer clicked the "Next" button
if formID = "01" then
Name = validHTML(request.form("name"))
LastName = validHTML(request.form("LastName"))
CustomerCompany = validHTML(request.form("CustomerCompany"))
Phone = validHTML(request.form("Phone") & request.form("Phone8"))
Email = validHTML(request.form("Email"))
if isEmpty(idCust) or not IsNumeric(idCust) Then
Password = generatePassword(8)
else
Password = validHTML(request.form("Password"))
end if
Address = validHTML(request.form("Address"))
City = validHTML(request.form("City"))
Zip = validHTML(request.form("Zip") & request.form("Zip3"))
locState = validHTML(request.form("locState"))
locState2 = validHTML(request.form("locState2"))
locCountry = validHTML(request.form("locCountry"))
paymentType = validHTML(request.form("paymentType"))
shippingName = validHTML(request.form("shippingName"))
shippingLastName = validHTML(request.form("shippingLastName"))
shippingPhone = validHTML(request.form("shippingPhone") & request.form("shippingPhone8"))
shippingAddress = validHTML(request.form("shippingAddress"))
ShippingCity = validHTML(request.form("ShippingCity"))
shippingZip = validHTML(request.form("shippingZip") & request.form("shippingZip3"))
shippingLocState = validHTML(request.form("shippingLocState"))
shippingLocState2 = validHTML(request.form("shippingLocState2"))
shippingLocCountry = validHTML(request.form("shippingLocCountry"))
futureMail = validHTML(request.form("futureMail"))
'Name
if len(name) = 0 then
arrayErrors = arrayErrors & "|name"
end if
'LastName
if len(lastname) = 0 then
arrayErrors = arrayErrors & "|lastname"
else
if invalidChar(lastname,2,"") then
arrayErrors = arrayErrors & "|lastname"
end if
end if
Dim strCpf, s, x, ch, ElCpf
strCpf = lastname
'Tira letras do campo CPF
s=""
for x=1 to len(strCpf)
ch=mid(strCpf,x,1)
if asc(ch)>=48 and asc(ch)<=57 then
s=s & ch
end if
next
strCpf = s
'Valida o CPF
Dim Numero(11), soma, resultado1, resultado2
if strCpf = "" then
strCpf = "inv"
end if
if len(strCpf) <> 11 then
strCpf = "inv"
elseif strCpf = "00000000000" then
strCpf = "inv"
elseif strCpf = "11111111111" then
strCpf = "inv"
elseif strCpf = "01234567890" then
strCpf = "inv"
elseif strCpf = "22222222222" then
strCpf = "inv"
elseif strCpf = "33333333333" then
strCpf = "inv"
elseif strCpf = "44444444444" then
strCpf = "inv"
elseif strCpf = "55555555555" then
strCpf = "inv"
elseif strCpf = "66666666666" then
strCpf = "inv"
elseif strCpf = "77777777777" then
strCpf = "inv"
elseif strCpf = "88888888888" then
strCpf = "inv"
elseif strCpf = "99999999999" then
strCpf = "inv"
elseif strCpf = "12345678909" then
strCpf = "inv"
else
Numero(1) = Cint(Mid(strCpf,1,1))
Numero(2) = Cint(Mid(strCpf,2,1))
Numero(3) = Cint(Mid(strCpf,3,1))
Numero(4) = Cint(Mid(strCpf,4,1))
Numero(5) = Cint(Mid(strCpf,5,1))
Numero(6) = CInt(Mid(strCpf,6,1))
Numero(7) = Cint(Mid(strCpf,7,1))
Numero(8) = Cint(Mid(strCpf,8,1))
Numero(9) = Cint(Mid(strCpf,9,1))
Numero(10) = Cint(Mid(strCpf,10,1))
Numero(11) = Cint(Mid(strCpf,11,1))
soma = 10 * Numero(1) + 9 * Numero(2) + 8 * Numero(3) + 7 * Numero(4) + 6 * Numero(5) + 5 * Numero(6) + 4 * Numero(7) + 3 * Numero(8) + 2 * Numero(9)
soma = soma -(11 * (int(soma / 11)))
if soma = 0 or soma = 1 then
resultado1 = 0
else
resultado1 = 11 - soma
end if
if resultado1 = Numero(10) then
soma = Numero(1) * 11 + Numero(2) * 10 + Numero(3) * 9 + Numero(4) * 8 + Numero(5) * 7 + Numero(6) * 6 + Numero(7) * 5 + Numero(8) * 4 + Numero(9) * 3 + Numero(10) * 2
soma = soma -(11 * (int(soma / 11)))
if soma = 0 or soma = 1 then
resultado2 = 0
else
resultado2 = 11 - soma
end if
if resultado2 = Numero(11) then
else
strCpf = "inv"
end if
else
strCpf = "inv"
end if
end if
'Valida o CPF e retorna a transação na loja
ElCpf = lastname
if strCpf = "inv" then
strCpf = ElCpf
end if
s=""
for x=1 to len(ElCpf)
ch=mid(ElCpf,x,1)
if asc(ch)>=48 and asc(ch)<=57 then
s=s & ch
end if
next
ElCpf = s
if ElCpf = "" then
arrayErrors = arrayErrors & "|lastname"
end if
if len(ElCpf) <> 11 then
arrayErrors = arrayErrors & "|lastname"
elseif ElCpf = "00000000000" then
arrayErrors = arrayErrors & "|lastname"
elseif ElCpf = "11111111111" then
arrayErrors = arrayErrors & "|lastname"
elseif ElCpf = "01234567890" then
arrayErrors = arrayErrors & "|lastname"
elseif ElCpf = "22222222222" then
arrayErrors = arrayErrors & "|lastname"
elseif ElCpf = "33333333333" then
arrayErrors = arrayErrors & "|lastname"
elseif ElCpf = "44444444444" then
arrayErrors = arrayErrors & "|lastname"
elseif ElCpf = "55555555555" then
arrayErrors = arrayErrors & "|lastname"
elseif ElCpf = "66666666666" then
arrayErrors = arrayErrors & "|lastname"
elseif ElCpf = "77777777777" then
arrayErrors = arrayErrors & "|lastname"
elseif ElCpf = "88888888888" then
arrayErrors = arrayErrors & "|lastname"
elseif ElCpf = "99999999999" then
arrayErrors = arrayErrors & "|lastname"
elseif ElCpf = "12345678909" then
arrayErrors = arrayErrors & "|lastname"
else
Numero(1) = Cint(Mid(ElCpf,1,1))
Numero(2) = Cint(Mid(ElCpf,2,1))
Numero(3) = Cint(Mid(ElCpf,3,1))
Numero(4) = Cint(Mid(ElCpf,4,1))
Numero(5) = Cint(Mid(ElCpf,5,1))
Numero(6) = CInt(Mid(ElCpf,6,1))
Numero(7) = Cint(Mid(ElCpf,7,1))
Numero(8) = Cint(Mid(ElCpf,8,1))
Numero(9) = Cint(Mid(ElCpf,9,1))
Numero(10) = Cint(Mid(ElCpf,10,1))
Numero(11) = Cint(Mid(ElCpf,11,1))
soma = 10 * Numero(1) + 9 * Numero(2) + 8 * Numero(3) + 7 * Numero(4) + 6 * Numero(5) + 5 * Numero(6) + 4 * Numero(7) + 3 * Numero(8) + 2 * Numero(9)
soma = soma -(11 * (int(soma / 11)))
if soma = 0 or soma = 1 then
resultado1 = 0
else
resultado1 = 11 - soma
end if
if resultado1 = Numero(10) then
soma = Numero(1) * 11 + Numero(2) * 10 + Numero(3) * 9 + Numero(4) * 8 + Numero(5) * 7 + Numero(6) * 6 + Numero(7) * 5 + Numero(8) * 4 + Numero(9) * 3 + Numero(10) * 2
soma = soma -(11 * (int(soma / 11)))
if soma = 0 or soma = 1 then
resultado2 = 0
else
resultado2 = 11 - soma
end if
if resultado2 = Numero(11) then
resultado2 = lastname
else
arrayErrors = arrayErrors & "|lastname"
end if
else
arrayErrors = arrayErrors & "|lastname"
end if
end if
'Phone
if len(phone) = 0 OR left(request.form("Phone8"),1) = 7 OR left(request.form("Phone8"),1) = 8 OR left(request.form("Phone8"),1) = 9 then
arrayErrors = arrayErrors & "|phone"
else
if invalidChar(phone,2,"") then
arrayErrors = arrayErrors & "|phone"
end if
end if
'Email
if len(email) = 0 then
arrayErrors = arrayErrors & "|email"
else
if inStr(email,"@") = 0 or inStr(email,".") = 0 then
arrayErrors = arrayErrors & "|email"
end if
if invalidChar(Email,1,"@.-_") then
arrayErrors = arrayErrors & "|email"
end if
end if
'Password
if isEmpty(idCust) or not IsNumeric(idCust) Then
else
if len(password) = 0 then
arrayErrors = arrayErrors & "|password"
else
if invalidChar(Password,1,"") then
arrayErrors = arrayErrors & "|password"
end if
end if
end if
'PaymentType
if action = "checkout" then
if len(paymentType) = 0 then
arrayErrors = arrayErrors & "|paymenttype"
end if
end if
'Future Mail Indicator
if futureMail <> "Y" then
futureMail = "N"
end if
'Address
if len(address) = 0 then
arrayErrors = arrayErrors & "|address"
end if
'City
if len(city) = 0 then
arrayErrors = arrayErrors & "|city"
end if
'Zip
if len(zip) = 0 then
arrayErrors = arrayErrors & "|zip"
else
if invalidChar(zip,2,"") then
arrayErrors = arrayErrors & "|zip"
end if
end if
'State/Prov/Country
if len(locCountry) = 0 then
arrayErrors = arrayErrors & "|locState"
arrayErrors = arrayErrors & "|locCountry"
else
if not validLoc(locState,locCountry) then
arrayErrors = arrayErrors & "|locState"
arrayErrors = arrayErrors & "|locCountry"
end if
end if
'State/Province 2
if len(locState) > 0 and len(locState2) > 0 then
arrayErrors = arrayErrors & "|locState2"
end if
'Shipping
if len(shippingName & shippingLastName & shippingPhone & shippingAddress & shippingCity & shippingZip & shippingLocCountry) > 0 then
'Ship Name
if len(shippingName) = 0 then
arrayErrors = arrayErrors & "|shippingName"
end if
'Ship Last Name
if len(shippingLastName) = 0 then
arrayErrors = arrayErrors & "|shippingLastName"
else
if invalidChar(shippingLastName,2,"") then
arrayErrors = arrayErrors & "|shippingLastName"
end if
end if
'shippingPhone
if len(shippingPhone) = 0 then
arrayErrors = arrayErrors & "|shippingPhone"
else
if invalidChar(shippingPhone,2,"") then
arrayErrors = arrayErrors & "|shippingPhone"
end if
end if
'Ship Address
if len(shippingAddress) = 0 then
arrayErrors = arrayErrors & "|shippingAddress"
end if
'Ship City
if len(shippingCity) = 0 then
arrayErrors = arrayErrors & "|shippingCity"
end if
'Ship Zip
if len(shippingZip) = 0 then
arrayErrors = arrayErrors & "|shippingZip"
else
if invalidChar(shippingZip,2,"") then
arrayErrors = arrayErrors & "|shippingZip"
end if
end if
'Ship State/Prov/Country
if len(shippingLocCountry) = 0 then
arrayErrors = arrayErrors & "|shippingLocState"
arrayErrors = arrayErrors & "|shippingLocCountry"
else
if not validLoc(shippingLocState,shippingLocCountry) then
arrayErrors = arrayErrors & "|shippingLocState"
arrayErrors = arrayErrors & "|shippingLocCountry"
end if
end if
'Ship State/Province 2
if len(shippingLocState) > 0 and len(shippingLocState2) > 0 then
arrayErrors = arrayErrors & "|shippingLocState2"
end if
end if
'There were no errors
if len(trim(arrayErrors)) = 0 then
'Check for duplicate email address
mySQL = "SELECT idCust " _
& "FROM customer " _
& "WHERE email = '" & validSQL(email,"A") & "' "
if not isNull(idCust) then
mySQL = mySQL & "AND idCust <> " & validSQL(idCust,"I")
end if
set rsTemp = openRSexecute(mySQL)
if not rsTemp.EOF then
response.redirect "sysMsg.asp?errMsg=" & server.URLEncode(langErrEmailUsed)
end if
call closeRS(rsTemp)
'Create empty Customer Record
if isNull(idCust) then
set rsTemp = openRSopen("customer",adUseServer,adOpenKeySet,adLockOptimistic,adCmdTable,0)
rsTemp.AddNew
rsTemp("status") = "I" 'Default to Inactive para uso na HERBALIFE
rsTemp("dateCreated") = currDateTime("DT",timeOffSet)
rsTemp("dateCreatedInt")= dateInt(currDateTime("DT",timeOffSet))
rsTemp("taxExempt") = "N" 'Default to No
if action = "newaff" then
rsTemp("affiliate") = "A" 'Affiliate Application
else
rsTemp("affiliate") = "N" 'Default to No
end if
rsTemp.update
session(storeID & "idCust") = rsTemp("idCust")
idCust = rsTemp("idCust")
call closeRS(rsTemp)
end if
'Update the customer record
mySQL = "UPDATE customer SET " _
& "[name] = '" & validSQL(name,"A") & "', " _
& "LastName = '" & validSQL(LastName,"A") & "', " _
& "CustomerCompany = '" & validSQL(CustomerCompany,"A") & "', " _
& "Phone = '" & validSQL(Phone,"A") & "', " _
& "Email = '" & validSQL(Email,"A") & "', " _
& "[Password] = '" & validSQL(Ascii2Hex(EnDeCrypt(Password,rc4Key)),"A") & "', " _
& "Address = '" & validSQL(Address,"A") & "', " _
& "City = '" & validSQL(City,"A") & "', " _
& "Zip = '" & validSQL(Zip,"A") & "', " _
& "locState = '" & validSQL(locState,"A") & "', " _
& "locState2 = '" & validSQL(locState2,"A") & "', " _
& "locCountry = '" & validSQL(locCountry,"A") & "', " _
& "paymentType = '" & validSQL(paymentType,"A") & "', " _
& "shippingName = '" & validSQL(shippingName,"A") & "', " _
& "shippingLastName = '" & validSQL(shippingLastName,"A") & "', " _
& "shippingPhone = '" & validSQL(shippingPhone,"A") & "', " _
& "ShippingAddress = '" & validSQL(ShippingAddress,"A") & "', " _
& "ShippingCity = '" & validSQL(ShippingCity,"A") & "', " _
& "shippingZip = '" & validSQL(shippingZip,"A") & "', " _
& "shippingLocState = '" & validSQL(shippingLocState,"A") & "', " _
& "shippingLocState2 = '" & validSQL(shippingLocState2,"A") & "', " _
& "shippingLocCountry = '" & validSQL(shippingLocCountry,"A") & "', " _
& "futureMail = '" & validSQL(futureMail,"A") & "' " _
& "WHERE idCust = " & validSQL(idCust,"I")
set rsTemp = openRSexecute(mySQL)
call closeRS(rsTemp)
'Update cartHead with some info (if possible)
if not(isNull(idOrder)) then
mySQL = "UPDATE cartHead SET " _
& "idCust = " & validSQL(idCust,"I") & ", " _
& "[Name] = '" & validSQL(Name,"A") & "'," _
& "LastName = '" & validSQL(LastName,"A") & "'," _
& "Address = '" & validSQL(Address,"A") & "' " _
& "WHERE idOrder = " & validSQL(idOrder,"I") & " "
set rsTemp = openRSexecute(mySQL)
call closeRS(rsTemp)
end if
'Forward to next page
select case action
case "newacc", "newaff"
Response.Redirect "cadsucesso.asp"
case "modify"
Response.Redirect "custListOrders.asp"
case "save"
call saveCart(idOrder,idCust)
Response.Redirect "custListOrders.asp"
case "checkout"
Response.Redirect "30_Ship_CC.asp"
end select
end if
end if
'Determine default Payment Type
if len(paymentType) = 0 then
paymentType = payDefault
end if
%>
<%
'Close Database Connection
call closedb()
'**********************************************************************
'Main Shopping Cart Display Area
'**********************************************************************
sub cartMain()
'If there were errors, show message
if len(trim(arrayErrors)) > 0 then
arrayErrors = split(LCase(arrayErrors),"|")
Response.Write "" & langErrInvForm & "
"
else
arrayErrors = array("")
end if
%>
|
|