4.1 网站首页 4.1.1 用户注册 重名检验:采用AJAX技术检查欲注册用户名是否存在,当用户名输入框失去焦点时触发重名检验代码,若已经存在则弹出警告框提示用户,如下图所示: 内容来自论文无忧网 www.paper51.com
http://www.paper51.com 图4-1 检查用户重名 http://www.paper51.com 重名验证JS代码: 内容来自www.paper51.com var request; copyright paper51.com functioncheckLoginName() 内容来自www.paper51.com { 内容来自www.paper51.com request=newActiveXObject("Msxml2.XMLHTTP"); 内容来自论文无忧网 www.paper51.com if(!request) paper51.com
{ paper51.com request=new ActiveXObject("Microsoft.XMLHTTP"); 内容来自www.paper51.com } 内容来自论文无忧网 www.paper51.com request.onreadystatechange=afterCheckLoginName; copyright paper51.com url="/oa/userregister.nsf/checkname?openagent&loginName="+document.all.loginName.value; 内容来自www.paper51.com request.open("POST",url,true); 内容来自论文无忧网 www.paper51.com
request.send(null); 内容来自www.paper51.com } 内容来自www.paper51.com functionafterCheckLoginName() 内容来自www.paper51.com
{ paper51.com if(request.readyState==4) copyright paper51.com
{ copyright paper51.com if(request.status==200) paper51.com { 内容来自www.paper51.com if(request.responseText.indexOf("1")>-1) copyright paper51.com { 内容来自论文无忧网 www.paper51.com
alert("已有相同用户名存在!") copyright paper51.com document.all.loginName.value=""; 内容来自论文无忧网 www.paper51.com document.all.loginName.focus(); paper51.com } copyright paper51.com } paper51.com } 内容来自论文无忧网 www.paper51.com } 内容来自www.paper51.com [url="/oa/userregister.nsf/checkname?openagent&loginName="+document.all.loginName.value;]所触发的后台代理(checkname) 内容来自www.paper51.com SubInitialize 内容来自www.paper51.com Dim sessionAs New NotesSession copyright paper51.com
Dim doc As NotesDocument paper51.com Dim userdoc As NotesDocument 内容来自www.paper51.com Dim view AsNotesView 内容来自论文无忧网 www.paper51.com Dim db As NotesDatabase copyright paper51.com Set doc=session.DocumentContext paper51.com Set db=session.CurrentDatabase http://www.paper51.com Set view=db.GetView("usercheck") 内容来自www.paper51.com macro=|@rightback(Query_String_Decoded;"=")| copyright paper51.com loginname=Evaluate(macro,doc) 内容来自论文无忧网 www.paper51.com
Set userdoc=view.GetDocumentByKey(loginname(0),True) 内容来自www.paper51.com Print"Content-type: text/xml" 内容来自www.paper51.com If Not userdoc Is Nothing Then http://www.paper51.com Print"1" http://www.paper51.com Else copyright paper51.com Print"0" copyright paper51.com End If http://www.paper51.com End Sub 内容来自www.paper51.com 用户填写完注册信息,通过注册按钮触发公式:@Command([ToolsRunMacro]; "register"); 进而调用代理(register)完成注册。 copyright paper51.com 下为用户注册到服务器代理(register)中代码: paper51.com Sub Initialize paper51.com Dimsession As New NotesSession 内容来自www.paper51.com Dimreg As New NotesRegistration 内容来自论文无忧网 www.paper51.com Dimdb As NotesDatabase 内容来自www.paper51.com Dimdoc As NotesDocument http://www.paper51.com Dimln,n,pw As String copyright paper51.com Setdoc =session.DocumentContext http://www.paper51.com
Setdb = session.CurrentDatabase copyright paper51.com un = doc.Username(0) http://www.paper51.com pw = doc.Password(0) copyright paper51.com
doc.state = "1" 内容来自论文无忧网 www.paper51.com Calldoc.Save(True,True) 内容来自www.paper51.com dt = Datenumber(Year(Today)+20,Month(Today), Day(Today)) copyright paper51.com reg.CertifierIDFile ="E:\\Lotus\\Domino\\data\\cert.id" paper51.com reg.Expiration = dt paper51.com reg.IDType = ID_HIERARCHICAL copyright paper51.com reg.MinPasswordLength = 5 ' password strength 内容来自www.paper51.com
reg.CreateMailDb = True copyright paper51.com reg.UpdateAddressBook = True 内容来自www.paper51.com reg.StoreIDInAddressBook = True paper51.com 内容来自www.paper51.com Callreg.RegisterNewUser(un, _ ' last name copyright paper51.com "E:\\Lotus\\Domino\\data\\"+un+".id",_ ' file to be created http://www.paper51.com "",_ ' mail serwer 内容来自www.paper51.com "",_ ' first namel 内容来自论文无忧网 www.paper51.com "",_ ' middle initial 内容来自www.paper51.com
"123456",_ ' certifier password paper51.com
"",_ ' location field 内容来自论文无忧网 www.paper51.com "",_ ' comment field http://www.paper51.com
"mail\"+un+".nsf", _ 'mail file copyright paper51.com "",_ 'forwarding domain 内容来自www.paper51.com pw,NOTES_FULL_CLIENT) 'password usertype 内容来自www.paper51.com
copyright paper51.com Print"<script language='javascript'>" paper51.com Print"location='/register.nsf/success'" copyright paper51.com Print"</script>" copyright paper51.com End Sub paper51.com 修改某用户的Internet的口令后,需要等待一定时间(服务器数据更新后)再以新口令登录就可以了。 username为@Name([Abbreviate];@UserName)name为@NameLookup([NoUpdate];@UserName;"shortname") Sub Initialize Dim session As NewNotesSession Dim view,userview Asnotesview Dimusername,name,oldpassword As String Dim doc,sessiondoc,userdocAs NotesDocument Dim db As New NotesDatabase("", "" ) Dim dbhome As notesdatabase Dim databasename As String Setdbhome=session.currentdatabase databasename=dbhome.filepath '数据库全路径 If (Not (db.Open("", "names.nsf" ))) Then Print"[/"+databasename+"/changepasswordmessageboxForm?openform&message=公用通迅录失效,请重启服务器!]" Exit Sub End If Set db=NewNotesDatabase("","names.nsf") Set userview =db.getview("($VIMPeople)") paper51.com
Setdoc =session.DocumentContext username = doc.username(0) oldpassword =doc.oldpassword(0) Set userdoc =userview.GetDocumentByKey( username ,True) If ( userdoc Is Nothing )Then Print"[/"+databasename+"/changepasswordmessageboxForm?openform&message=无此用户!]" Exit Sub End If Set view=dbhome.GetView("usercheck") key=doc.name(0) Set sessiondoc =view.getdocumentbykey(key) 内容来自论文无忧网 www.paper51.com
If(sessiondoc.password(0)<>doc.oldpassword(0)) Then Print"[/"+databasename+"/changepasswordmessageboxForm?openform&message=旧口令输入错误!]" Exit Sub End If tmp1 = Evaluate(|@Password(tmppassword)|,doc) userdoc.HTTPPassword =Trim(tmp1(0)) Calluserdoc.save(True,False) Call userview.Refresh Print"[/"+databasename+"/changepasswordmessageboxForm?openform&message=您已成功的修改了密码,密码更新可能需要几分钟!]" sessiondoc.password=doc.tmppassword(0) http://www.paper51.com
Callsessiondoc.save(True,True) 内容来自www.paper51.com
Exit Sub http://www.paper51.com |