<% 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 ssChangePasswordMain() Sub ssChangePasswordMain() On Error Resume Next Application("LoginField") = "UserName" Application("PassField") = "Password" Application("MailField") = "Email" 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" Err.Clear() 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("changepassword", nof_componentId), -1) If componentNode Is Nothing Then Err.Raise 400, "ss_changePassword_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_changePassword_post.main.40", ssGetLocaleString("Error.526", Null) Call ssRaiseFatalError(err, "div", nof_debug) Response.End end if Dim absPath, relPath if not inStr(1, dbPath, "\", 1) > 0 then 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 allFields = split(request.form,"&") Response.Write "" & vbCrLf & _ " " & vbCrLf & _ "
" & vbCrLf Dim errLocal : errLocal = "" for i=0 to UBound(allFields) errFlag = false fieldName = split(allFields(i),"=")(0) fieldValue = request.form(fieldName) call ssBuildHiddenField(fieldName, fieldValue) propValue = "" set errEvent = getErrorEvent(ComponentNode, fieldName, "required") if not errEvent is nothing then propValue = ssGetProperty(errEvent, "message") end if if not errFlag AND Len(propValue) > 0 then if not Len(fieldValue) > 0 then errFlag = true errLocal = errLocal & "
  • " & propValue & "
  • " end if end if if not errFlag AND inStr(fieldName, "retypeNew" & Application("PassField")) > 0 then if fieldValue <> request.form("new" & Application("PassField")) then errFlag = true propValue = "" set errEvent = getErrorEvent(ComponentNode, fieldName, "notmatch") if not errEvent is nothing then propValue = ssGetProperty(errEvent, "message") end if errLocal = errLocal & "
  • " & propValue & "
  • " end if end if set errEvent = nothing if errFlag then call ssBuildHiddenField(request.form("nof_componentId").Item & "_" & fieldName & "ErrImg", ssGetProperty(ComponentNode, compGeneralTags.Item("errormark"))) end if next if not Len(errLocal) > 0 then dim result, objMail result = ChangePassword(dbPath, request.form("old" & Application("PassField")), request.form("new" & Application("PassField"))) if result = "changed" then Dim emailTemplate emailTemplate = nof_SitePath & nof_ScriptDir & "\ss_ChangePasswordTemplate_" & _ ssGetProperty(ComponentNode, suiteTags.Item("language")) & ".properties" if ssFileExists(emailTemplate) then sendEmail = ssGetTemplateValue(emailTemplate, "sendEmail") if err.number <> 0 then Call ssRaiseFatalError(err, "div", nof_debug) Exit Sub end if if sendEmail = "true" then Dim emailFileContent, fromEmail, subject, body, rec, recItems, userMail, userUN, userPass, mailPos, usPos, passPos userMail = "" userUN = "" userPass = "" rec = GetUser(dbPath, Session("ssMemberID")) if (Err.Number <> 0) Then Call ssRaiseFatalError(err, null, nof_Debug) exit sub end if recItems = split(Mid(rec,2,Len(rec)-2),""",""") if isArray(recItems) then mailPos = GetRecPos(dbPath, (Application("MailField"))) usPos = GetRecPos(dbPath, (Application("LoginField"))) passPos = GetRecPos(dbPath, (Application("PassField"))) if UBound(recItems) > mailPos then userMail = recItems(mailPos) if UBound(recItems) > usPos then userUN = recItems(usPos) if UBound(recItems) > passPos then userPass = recItems(passPos) end if body = ssGetTemplateValue(emailTemplate, "Body") body = Replace(body, "{0}", userUN, 1, -1, 1) body = Replace(body, "{1}", userPass, 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 = userMail 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 elseif result = "notexist" then propValue = "" set errEvent = getErrorEvent(ComponentNode, "old" & Application("PassField"), "invalidpassword") if not errEvent is nothing then propValue = ssGetProperty(errEvent, "message") end if set errEvent = nothing errLocal = "
  • " & propValue & "
  • " call ssBuildHiddenField(request.form("nof_componentId").Item & "_" & Application("PassField") & "ErrImg", ssGetProperty(ComponentNode, compGeneralTags.Item("errormark"))) elseif result = "errorupdate" then errLocal = "
  • An Error Occured while updating.
  • " end if end if if Len(errLocal) > 0 then errLocal = "" call ssBuildHiddenField(nof_componentId & "_" & "Errors", errLocal) set ComponentNode = nothing set XMLDoc = nothing Response.Write "
    " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ "" end sub %>