<% Dim nof_rootDir, nof_sitePath, nof_scriptDir, nof_debug, nof_componentName, _ nof_componentId, nof_scriptInterfaceFile, nof_langFile, nof_locale nof_rootDir = Request.Form("nof_rootDir") nof_sitePath = Request.Form("nof_sitePath") nof_scriptDir = Request.Form("nof_scriptDir") nof_debug = Request.Form("nof_debug") nof_componentName = Request.Form("nof_componentName") nof_componentId = Request.Form("nof_componentId") nof_scriptInterfaceFile = Request.Form("nof_scriptInterfaceFile") nof_langFile = Request.Form("nof_langFile") set nof_locale = ssLocaleToDictionary(nof_sitePath & nof_scriptDir, nof_langFile) Call ssSignupMain() Sub ssSignupMain() On Error Resume Next Application("LoginField") = "UserName" Application("PassField") = "Password" Application("MailField") = "Email" Application("AdminField") = "AdminStatus" Application("ValidField") = "ValidationFlag" Dim suiteTags set suiteTags = Server.CreateObject("scripting.dictionary") suiteTags.Add "dbpath", "dbPath" suiteTags.Add "uploaddir", "dbFileUploadDir" suiteTags.Add "sendemail", "sendEmail" suiteTags.Add "smtpip", "emailServer" suiteTags.Add "smtpport", "emailServerPort" suiteTags.Add "emailto", "emailToAddress" suiteTags.Add "emailfrom", "emailFromAddress" suiteTags.Add "debug", "publishInDebugMode" suiteTags.Add "dbcolumns", "dbColumns" suiteTags.Add "language", "language" Dim compGeneralTags set compGeneralTags = Server.CreateObject("scripting.dictionary") compGeneralTags.Add "currentpage", "currentPage" compGeneralTags.Add "nextpage", "nextPage" compGeneralTags.Add "errormark", "errorMark" compGeneralTags.Add "accessdeniedpage", "accessDeniedPage" Dim XMLDoc Set XMLDoc = ssOpenXMLFile(nof_sitePath & nof_scriptDir & "\" & nof_scriptInterfaceFile) If Err.number <> 0 Then ' The method above returns only documented exceptions, ' so we safely pass the error object further Call ssRaiseFatalError(Err, "div", nof_debug) Response.End() End If Dim ComponentNode set ComponentNode = ssGetNode(XMLDoc,,"Component", Array("name","id"), Array(nof_ComponentName, nof_componentId), -1) If ComponentNode Is Nothing Then Err.Raise 400, "ss_signup_post.main.20", ssGetLocaleString("Error.400", Null) Call ssRaiseFatalError(err, "div", nof_debug) Response.End() End If dbPath = ssGetProperty( ComponentNode, suiteTags.Item("dbpath") ) if dbPath = "" then Err.Raise 526, "ss_signuppost.main.40", ssGetLocaleString("Error.526", Null) Call ssRaiseFatalError(err, "div", nof_debug) Response.End end if if not inStr(1, dbPath, "\", 1) > 0 then Dim absPath, relPath set relPath = nothing set relPath = ssReFind(dbPath, "\.\./") absPath = Server.MapPath(".") if not relPath is nothing then if relPath.count > 0 then for i=1 to relPath.count absPath = Left(absPath, inStrRev(absPath,"\") - 1) dbPath = Replace(dbPath, "../", "", 1, 1) next else if inStr(1, dbPath, "./") > 0 then dbPath = Replace(dbPath, "./", "", 1, 1) end if end if set relPath = nothing end if dbPath = absPath & "\" & Replace(dbPath, "/", "\") end if dbFields = ssGetDBFields(ComponentNode, suiteTags.Item("dbcolumns")) if ssFileExists(dbPath) then 'check if the fields are the same tableHead = ssGetLine(dbPath) if LCase(dbFields) <> LCase(tableHead) Then 'create the database Call ssCreateDB(dbPath, dbFields) if (Err.Number <> 0) Then Call ssRaiseFatalError(err, null, nof_debug) Response.End() end if tableHead = ssGetLine(dbPath) end if else 'create the database Call ssCreateDB(dbPath, dbFields) if (Err.Number <> 0) Then Call ssRaiseFatalError(err, "div", nof_debug) Response.End() end if tableHead = ssGetLine(dbPath) end if allTHeads = split(tableHead,",") %>
" method="post" target='_self'> <% errLocal = "" for i=0 to UBound(allTHeads) fieldName = allTHeads(i) fieldValue = EncodeValue(request.form(fieldName)) Set regEx = New RegExp regEx.Pattern = "\r\n" regEx.IgnoreCase = True regEx.Global = True fieldValue = regEx.Replace(fieldValue, " ") call ssBuildHiddenField(fieldName, fieldValue) errFlag = CheckFields(ComponentNode, fieldName, fieldValue) if LCase(errFlag) <> "false" then errLocal = errLocal & "
  • " & errFlag & "
  • " call ssBuildHiddenField(nof_componentId & "_" & fieldName & "ErrImg", _ ssGetProperty( ComponentNode, compGeneralTags.Item("errormark") )) end if next ' check for retypePassword if it's there ' fieldName = "retype" & Application("PassField") fieldValue = EncodeValue(request.form(fieldName)) call ssBuildHiddenField(fieldName, fieldValue) errFlag = CheckFields(ComponentNode, fieldName, fieldValue) if LCase(errFlag) = "false" then if Request.Form(Application("PassField")) <> Request.Form(fieldName) then set errEvent = getErrorEvent(ComponentNode, fieldName, "passwordsnotmatch") propValue = "" if not errEvent is nothing then propValue = ssGetProperty( errEvent, "message" ) end if if Len(propValue) > 0 then errLocal = errLocal & "
  • " & propValue & "
  • " end if end if else errLocal = errLocal & "
  • " & errFlag & "
  • " end if if LCase(errFlag) <> "false" then call ssBuildHiddenField(nof_componentId & "_" & fieldName & "ErrImg", _ ssGetProperty( ComponentNode, compGeneralTags.Item("errormark") )) end if if not Len(errLocal) > 0 then dim userExistence userExistence = UserExist(XMLDoc, request.form(LCase(Application("LoginField"))).item, dbPath) if err.number <> 0 then exit sub end if if userExistence then set errEvent = getErrorEvent(ComponentNode, "username", "alreadyexists") propValue = "" if not errEvent is nothing then propValue = ssGetProperty( errEvent, "message" ) end if errLocal = "" call ssBuildHiddenField(nof_componentId & "_" & Application("LoginField") & "ErrImg", _ ssGetProperty(ComponentNode, compGeneralTags.Item("errormark")) ) else for i=0 to UBound(allTHeads) if inStr(LCase(request.form),LCase(allTHeads(i))) > 0 then if Len(rowRec) > 0 then rowRec = rowRec & "," rowRec = rowRec & """" & EncodeValue(request.form(LCase(allTHeads(i)))) & """" else if Len(rowRec) > 0 then rowRec = rowRec & "," if LCase(allTHeads(i)) = LCase(Application("AdminField")) then rowRec = rowRec & """false""" elseif LCase(allTHeads(i)) = LCase(Application("ValidField")) then set adminProp = ssGetByDBpath(XMLDoc, "admin", _ uiteTags.Item("dbpath"), ssGetProperty( ComponentNode, suiteTags.Item("dbpath") )) if adminProp is nothing then rowRec = rowRec & """true""" Err.Clear else if Len(ssGetProperty(adminProp, "automaticvalidation")) > 0 then rowRec = rowRec & """" & _ ssGetProperty(adminProp, "automaticvalidation") & """" else rowRec = rowRec & """true""" end if end if else rowRec = rowRec & """""" end if end if next if ssInsert(dbPath, CStr(rowRec)) then dim emailTemplate, sendEmail emailTemplate = nof_sitePath & nof_scriptDir & "\ss_SignupTemplate_" & _ ssGetProperty( ComponentNode, suiteTags.Item("language") ) & ".properties" if ssFileExists(emailTemplate) then sendEmail = ssGetTemplateValue(emailTemplate, "sendEmail") if err.number <> 0 then Call ssRaiseFatalError(err, null, nof_debug) exit sub end if if sendEmail = "true" then Dim emailFileContent, fromEmail, subject, body body = ssGetTemplateValue(emailTemplate, "Body") body = Replace(body, "{0}", request.form(LCase(Application("LoginField"))), 1, -1, 1) body = Replace(body, "{1}", request.form(LCase(Application("PassField"))), 1, -1, 1) body = Replace(body, "\n", "
    ", 1, -1, 1) Set objMail = new ss_CDOMail objMail.SmtpServer = ssGetProperty( ComponentNode, suiteTags.Item("smtpip") ) objMail.SmtpBackupServer = "localhost" objMail.EmailTo = request.form(LCase(Application("MailField"))) objMail.EmailFrom = ssGetProperty( ComponentNode, suiteTags.Item("emailfrom") ) objMail.EmailSubject = ssGetTemplateValue(emailTemplate, "Subject") objMail.AddHtmlBody = body if not objMail.SendMail then Call ssRaiseFatalError(err, null, nof_debug) response.end end if Set objMail = Nothing end if end if response.write "" & vbcrlf else Call ssRaiseFatalError(err, null, nof_debug) Response.End() end if end if else errLocal = "" end if call ssBuildHiddenField(nof_componentId & "_" & "Errors", errLocal) Response.Write "
    " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " end sub function checkFields(ByVal CompNode, ByVal fieldName, ByVal fieldValue) On Error Resume next checkFields = "false" set errEvent = getErrorEvent(CompNode, fieldName, "required") propValue = "" if not errEvent is nothing then propValue = ssGetProperty( errEvent, "message" ) end if if Len(propValue) > 0 then if not Len(fieldValue) > 0 then checkFields = propValue exit function end if end if set errEvent = getErrorEvent(CompNode, fieldName, "invalidemail") propValue = "" if not errEvent is nothing then propValue = ssGetProperty(errEvent, "message" ) end if if inStr(fieldName, "email") > 0 and Len(propValue) > 0 then if not checkEmail(fieldValue) then checkFields = propValue exit function end if end if set errEvent = getErrorEvent(CompNode, fieldName, "short") propValue = "0" if not errEvent is nothing then propValue = ssGetProperty(errEvent, "minimumlength") end if if CLng(propValue) > 0 then if Len(fieldValue) < CLng(propValue) then checkFields = ssGetProperty(errEvent, "message") exit function end if end if set errEvent = getErrorEvent(CompNode, fieldName, "long") propValue = "0" if not errEvent is nothing then propValue = ssGetProperty(errEvent, "maximumlength") end if if CLng(propValue) > 0 then if Len(fieldValue) > CLng(propValue) then checkFields = ssGetProperty(errEvent, "message") exit function end if end if end function %>