%
%>
<%
asp_include "include/siteusers_variables.asp",false
asp_include "classes/runnerpage.asp",false
registered = false
strMessage = ""
allow_registration = true
strUsername = ""
strPassword = ""
strEmail = ""
Set values = (CreateDictionary())
Set keys = (CreateDictionary())
id = 1
asp_include "include/xtempl.asp",false
isNeedSettings = true
Set xt = (CreateClass("Xtempl",0,Empty,Empty,Empty,Empty,Empty,Empty,Empty))
Set params = (CreateDictionary2("pageType",PAGE_REGISTER,"id",id))
setArrElementByRef params,"xt",xt
setArrElement params,"tName",strTableName
setArrElement params,"needSearchClauseObj",false
setArrElement params,"calendar",false
Set pageObject = (CreateClass("RunnerPage",1,params,Empty,Empty,Empty,Empty,Empty,Empty))
doAssignmentByRef isUseCaptcha,globalEvents.existsCAPTCHA_p1(PAGE_REGISTER)
if not bValue(pageObject.isCaptchaOk) then
allow_registration = false
end if
if bValue(globalEvents.exists_p1("BeforeProcessRegister")) then
globalEvents.BeforeProcessRegister_p1 conn
end if
includes = ""
includes = CSmartStr(includes) & "" & vbcrlf
includes = CSmartStr(includes) & "" & vbcrlf
if IsIdentical(pageObject.debugJSMode,true) then
includes = CSmartStr(includes) & "" & vbcrlf
else
includes = CSmartStr(includes) & "" & vbcrlf
end if
if bValue(isUseCaptcha) then
pageObject.doCaptchaCode
end if
if IsEqual(GetRequestValue(RequestForm(),"btnSubmit"),"Register") then
Set filename_values = (CreateDictionary())
Set blobfields = (CreateDictionary())
inlineedit = ADD_SIMPLE
doAssignmentByRef value,postvalue("value_UserName_" & CSmartStr(id))
doAssignmentByRef var_type,postvalue("type_UserName_" & CSmartStr(id))
if bValue(FieldSubmitted("UserName_" & CSmartStr(id))) then
doAssignmentByRef value,prepare_for_db("UserName",value,var_type,"","")
else
value = false
end if
if not (IsFalse(value)) then
setArrElement values,"UserName",value
end if
doAssignmentByRef value,postvalue("value_Password_" & CSmartStr(id))
doAssignmentByRef var_type,postvalue("type_Password_" & CSmartStr(id))
if bValue(FieldSubmitted("Password_" & CSmartStr(id))) then
doAssignmentByRef value,prepare_for_db("Password",value,var_type,"","")
else
value = false
end if
if not (IsFalse(value)) then
setArrElement values,"Password",value
end if
doAssignmentByRef value,postvalue("value_UserEmailAddress_" & CSmartStr(id))
doAssignmentByRef var_type,postvalue("type_UserEmailAddress_" & CSmartStr(id))
if bValue(FieldSubmitted("UserEmailAddress_" & CSmartStr(id))) then
doAssignmentByRef value,prepare_for_db("UserEmailAddress",value,var_type,"","")
else
value = false
end if
if not (IsFalse(value)) then
setArrElement values,"UserEmailAddress",value
end if
doAssignment strUsername,ArrayElement(values,"UserName")
doAssignment strPassword,ArrayElement(values,"Password")
doAssignment strEmail,ArrayElement(values,"UserEmailAddress")
GetCollectionBounds filename_values,register_loopIdx2,register_loopMax2
do while register_loopIdx2<=register_loopMax2
key = GetCollectionKey(filename_values,register_loopIdx2)
doAssignment value,ArrayElement(filename_values,key)
setArrElement values,key,value
register_loopIdx2=register_loopIdx2+1
loop
if not bValue(asp_strlen(strUsername)) then
xt.assign_p2 "user_msg","Username can not be empty."
allow_registration = false
else
strSQL = "select count(*) from `siteusers` where `UserName`=" & CSmartStr(add_db_quotes("UserName",strUsername,""))
doAssignmentByRef rs,db_query(strSQL,conn)
doAssignmentByRef data,db_fetch_numarray(rs)
if IsLess(0,ArrayElement(data,0)) then
xt.assign_p2 "user_msg",(((CSmartStr("Username") & " ") & CSmartStr(strUsername)) & " ") & CSmartStr("already exists. Choose another username.")
allow_registration = false
end if
end if
if not bValue(asp_strlen(strEmail)) then
xt.assign_p2 "email_msg","Please enter a valid email address."
allow_registration = false
else
strSQL = "select count(*) from `siteusers` where `UserEmailAddress`=" & CSmartStr(add_db_quotes("UserEmailAddress",strEmail,""))
doAssignmentByRef rs,db_query(strSQL,conn)
doAssignmentByRef data,db_fetch_numarray(rs)
if IsLess(0,ArrayElement(data,0)) then
xt.assign_p2 "email_msg",(((CSmartStr("Email") & " ") & CSmartStr(strEmail)) & " ") & CSmartStr("already registered. If you forgot your username or password use the password reminder form.")
allow_registration = false
end if
end if
if not bValue(checkpassword(ArrayElement(values,"Password"))) then
msg = ""
fmt = "Password must be at least %% characters length."
doAssignmentByRef fmt,asp_str_replace("%%","8",fmt)
msg = CSmartStr(msg) & ("
" & CSmartStr(fmt))
fmt = "Password must contain %% unique characters."
doAssignmentByRef fmt,asp_str_replace("%%","4",fmt)
msg = CSmartStr(msg) & ("
" & CSmartStr(fmt))
fmt = "Password must contain %% digits or symbols."
doAssignmentByRef fmt,asp_str_replace("%%","2",fmt)
msg = CSmartStr(msg) & ("
" & CSmartStr(fmt))
if bValue(msg) then
doAssignmentByRef msg,asp_substr(msg,4,empty)
end if
xt.assign_p2 "password_msg",msg
allow_registration = false
end if
retval = true
if bValue(allow_registration) then
if bValue(globalEvents.exists_p1("BeforeRegister")) then
doAssignmentByRef retval,globalEvents.BeforeRegister_p2(values,strMessage)
end if
else
retval = false
end if
if bValue(retval) then
message = ""
doAssignmentByRef retval,DoInsertRecord("siteusers",values,blobfields,id,pageObject)
doAssignment strMessage,message
end if
if bValue(isUseCaptcha) and bValue(pageObject.isCaptchaOk) then
setArrElement Session,CSmartStr(strTableName) & "_count_captcha",CSmartDbl(Session(CSmartStr(strTableName) & "_count_captcha"))+1
end if
if bValue(retval) then
if bValue(globalEvents.exists_p1("AfterSuccessfulRegistration")) then
globalEvents.AfterSuccessfulRegistration_p1 values
end if
doAssignmentByRef url,GetSiteUrl()
url = CSmartStr(url) & CSmartStr(GetRequestValue(Request.ServerVariables,"SCRIPT_NAME"))
message = ((CSmartStr("You have registered as a user at") & " ") & CSmartStr(url)) & vbcrlf & vbcrlf
strLabel = "User Name"
message = CSmartStr(message) & (((CSmartStr(strLabel) & ": ") & CSmartStr(ArrayElement(values,"UserName"))) & vbcrlf)
strLabel = "User Email Address"
message = CSmartStr(message) & (((CSmartStr(strLabel) & ": ") & CSmartStr(ArrayElement(values,"UserEmailAddress"))) & vbcrlf)
if not IsFalse(doAssignmentByRef(pos,asp_strpos(strEmail,vbcr,empty))) or not IsFalse(doAssignmentByRef(pos,asp_strpos(strEmail,vblf,empty))) then
doAssignmentByRef strEmail,asp_substr(strEmail,0,pos)
end if
runner_mail CreateDictionary3("to",strEmail,"subject","Notification on registering","body",message)
message = ((CSmartStr("User registered at") & " ") & CSmartStr(url)) & vbcrlf
strLabel = "User Name"
message = CSmartStr(message) & (((CSmartStr(strLabel) & ": ") & CSmartStr(ArrayElement(values,"UserName"))) & vbcrlf)
strLabel = "User Email Address"
message = CSmartStr(message) & (((CSmartStr(strLabel) & ": ") & CSmartStr(ArrayElement(values,"UserEmailAddress"))) & vbcrlf)
runner_mail CreateDictionary3("to","info@empin.org","subject","Notification on registering","body",message)
pageObject.addCommonJs
pageObject.fillSetCntrlMaps
pageObject.addButtonHandlers
setArrElement pageObject.body,"begin",CSmartStr(ArrayElement(pageObject.body,"begin")) & ((((((CSmartStr(includes) & "