If a personal website has a member registration module + Dongwang Forum, it will not be easy to integrate the website with the Dongwang Forum system to achieve synchronized update of user information, login and other operations between different Web systems. Although Dongwang has provided There is a detailed guide for developers of the API interface of the Dongwang Forum system, but a novice like me can’t understand it for a while, sorry. Not willing to give in, after some research and testing on its login, verification and other functions, I finally achieved some success. Rookies also have rookie methods:
The forum version for this test is Version 7.1.0 Sp1, and other versions have not been tested.
1. Website file structure
wwwroot
┝index.asp
┝ CheckUserLogin.asp
┕bbs/
2. Integration Principle
It is not difficult to implement synchronous updates. The main problem with integration is synchronous login, so our focus will be on discussing how to achieve synchronous login. My method is to integrate the main site user table into the Dongwang user table Dv_User (to avoid the trouble of updating two libraries in the future). You can add fields to Dv_User as needed, and modify bbs/login.asp and bbs/inc Make appropriate modifications to /Dv_ClsMain.asp; when logging in, send the form to bbs/login.asp for verification; the main site determines whether the login is successful based on the information recorded in the Session after successful login to Dongwang, and obtains user information.
3. Add new modified files
1.index.asp code:
<html>
<head>
<meta http-equiv=Content-Type content=text/html; charset=gb2312 />
<title>Integration of personal website and dynamic network (www.mzwu.com)</title>
</head>
<body>
<!--#include file=CheckUserLogin.asp -->
<%
If CheckUserLogin Then
Response.write(<a href=bbs/logout.asp?back=1>Logout</a><p></p>)
Response.write(username: & Request.Cookies(username) & <br>)
Response.write(Gender: & Request.Cookies(sex) & <br>)
Response.write(Registration time: & Request.Cookies(joindate) & <br>)
Response.write(last login: & Request.Cookies(lastlogin) & <br>)
Response.write(number of logins: & Request.Cookies(userlogins) & <br>)
Response.write(browser type: & Request.Cookies(browser) & <br>)
Response.write(browser version: & Request.Cookies(version) & <br>)
Response.write(operating system: & Request.Cookies(platform) & <br>)
Else
%>
<form id=form1 name=form1 method=post action=bbs/login.asp?action=chk&back=1>
username:
<input name=username type=text id=username size=10 />
<br />
password:
<input name=password type=password id=password size=10 />
<input type=submit name=Submit value=Login/>
</form>
<%
End if
%>
<p></p><a href=bbs/>Enter the forum</a>
</body>
</html>
2.CheckUserLogin.asp code:
<!--#Include File=bbs/inc/Dv_ClsMain.asp-->
<%
Function CheckUserLogin()
Dim Dvbbs,UserSession
Const MsxmlVersion=.3.0
Set Dvbbs = New Cls_Forum
Set UserSession=Server.CreateObject(msxml2.FreeThreadedDOMDocument& MsxmlVersion)
If UserSession.loadxml(Session(Dvbbs.CacheName & UserID)&) Then
If UserSession.documentElement.selectSingleNode(userinfo/@userid).text<>0 Then
'Successfully logged in to the forum
CheckUserLogin = True
'The following is how to obtain some user information. You can save it in Cookies or Session for easy use:
'User ID: UserSession.documentElement.selectSingleNode(userinfo/@userid).text
'Username: UserSession.documentElement.selectSingleNode(userinfo/@username).text
'Birthday: UserSession.documentElement.selectSingleNode(userinfo/@userbirthday).text
'Email: UserSession.documentElement.selectSingleNode(userinfo/@useremail).text
'Gender: UserSession.documentElement.selectSingleNode(userinfo/@usersex).text '0 is female, 1 is male
'Registration time: UserSession.documentElement.selectSingleNode(userinfo/@joindate).text
'Last login: UserSession.documentElement.selectSingleNode(userinfo/@lastlogin).text
'Number of logins: UserSession.documentElement.selectSingleNode(userinfo/@userlogins).text
'Money: UserSession.documentElement.selectSingleNode(userinfo/@userwealth).text
'Points: UserSession.documentElement.selectSingleNode(userinfo/@userep).text
'Charm: UserSession.documentElement.selectSingleNode(userinfo/@usercp).text
'Last login IP: UserSession.documentElement.selectSingleNode(userinfo/@userlastip).text
'Browser type: UserSession.documentElement.selectSingleNode(agent/@browser).text
'Browser version: UserSession.documentElement.selectSingleNode(agent/@version).text
'Operating system: UserSession.documentElement.selectSingleNode(agent/@platform).text
'Visiting IP: UserSession.documentElement.selectSingleNode(agent/@ip).text
'Example application:
Response.Cookies(username) = UserSession.documentElement.selectSingleNode(userinfo/@username).text
Response.Cookies(joindate) = UserSession.documentElement.selectSingleNode(userinfo/@joindate).text
If UserSession.documentElement.selectSingleNode(userinfo/@usersex).text=0 Then
Response.Cookies(sex) = pretty girl
Else
Response.Cookies(sex) = cool brother
End if
Response.Cookies(lastlogin) = UserSession.documentElement.selectSingleNode(userinfo/@lastlogin).text
Response.Cookies(userlogins) = UserSession.documentElement.selectSingleNode(userinfo/@userlogins).text
Response.Cookies(browser) = UserSession.documentElement.selectSingleNode(agent/@browser).text
Response.Cookies(version) = UserSession.documentElement.selectSingleNode(agent/@version).text
Response.Cookies(platform) = UserSession.documentElement.selectSingleNode(agent/@platform).text
Else
'Have visited the forum but not logged in yet, guest status
CheckUserLogin = False
End if
Else
'Have not visited the forum
CheckUserLogin = False
End if
Set UserSession = nothing
Set Dvbbs = nothing
End Function
%>
3. A new red part is added to bbs/login.asp so that you can still return to the homepage after successfully logging in to the homepage of the site:
Dim comeurlname
If instr(lcase(request(comeurl)),reg.asp)>0 or instr(lcase(request(comeurl)),login.asp)>0 or trim(request(comeurl))= Then
comeurlname=
comeurl=index.asp
Else
comeurl=request(comeurl)
comeurlname=<li><a href=&request(comeurl)&>&request(comeurl)&</a></li>
End If
If request(back)=1 Then
Response.Redirect(../index.asp)
End If
Dim TempStr
TempStr = template.html(2)
'If Dvbbs.Forum_ChanSetting(0)=1 And Dvbbs.Forum_ChanSetting(10)=1 And Dvbbs.Forum_ChanSetting(12)=1 Then
' TempStr = Replace(TempStr,{$ray_logininfo},template.html(3))
'Else
' TempStr = Replace(TempStr,{$ray_logininfo},)
'End If
'------------------------------------------------ ----------------
'System integration
'------------------------------------------------ ----------------
If DvApi_Enable Then
Response.Write DvApi_SaveCookie
Response.Flush
End If
'------------------------------------------------ ----------------
TempStr = Replace(TempStr,{$ray_logininfo},)
TempStr = Replace(TempStr,{$comeurl},comeurl)
TempStr = Replace(TempStr,{$comeurlinfo},comeurlname)
TempStr = Replace(TempStr,{$forumname},Dvbbs.Forum_Info(0))
Response.Write TempStr
TempStr=
End Function
4. A new red part has been added to bbs/logout.asp so that you can still return to the home page after clicking logout on the home page of the site:
'------------------------------------------------ ----------------
'System integration
'------------------------------------------------ ----------------
Dim DvApi_Obj,DvApi_SaveCookie,SysKey
If DvApi_Enable Then
Md5OLD = 1
SysKey = Md5(Dvbbs.MemberName&DvApi_SysKey,16)
Md5OLD = 0
Set DvApi_Obj = New DvApi
DvApi_SaveCookie = DvApi_Obj.SetCookie(SysKey,Dvbbs.MemberName,,)
Set DvApi_Obj = Nothing
Response.Write DvApi_SaveCookie
Response.Flush
End If
If request(back)=1 Then
Response.Redirect(../index.asp)
End If
'------------------------------------------------ ----------------
'Response.Redirect Dvbbs.Forum_Info(11)
response.write<script language=JavaScript>
response.writesetTimeout(window.location='&Dvbbs.Forum_Info(11)&',1000);
response.write</script>
4. Dongwang settings: Remove the login verification code, OK, the integration is completed.
5. Extension:
The fields in the default Dv_User table sometimes cannot meet our actual needs. We need to add new fields to expand them. Let's do it:
1. Open the Dv_User table and add a text type field info_1
2. In the ChkUserLogin function of bbs/login.asp
Sql=Select UserID,UserName,UserPassword,UserEmail,UserPost,UserTopic,UserSex,UserFace,UserWidth,UserHeight,JoinDate,LastLogin,lastlogin as cometime, LastLogin as activetime,UserLogins,Lockuser,Userclass,UserGroupID,UserGroup,userWealth,userEP,userCP,UserPower,UserBirthday,UserLastIP,UserDel,UserIsBest,Use rHidden,UserMsg,IsChallenge,UserMobile,TitlePic,UserTitle,TruePassWord,UserToday,UserMoney,UserTicket,FollowMsgID,Vip_StarTime,Vip_EndTime,userid as boardid
Modify to:
Sql=Select UserID,UserName,UserPassword,UserEmail,UserPost,UserTopic,UserSex,UserFace,UserWidth,UserHeight,JoinDate,LastLogin,lastlogin as cometime, LastLogin as activetime,UserLogins,Lockuser,Userclass,UserGroupID,UserGroup,userWealth,userEP,userCP,UserPower,UserBirthday,UserLastIP,UserDel,UserIsBest,Use rHidden,UserMsg,IsChallenge,UserMobile,TitlePic,UserTitle,TruePassWord,UserToday,UserMoney,UserTicket,FollowMsgID,Vip_StarTime,Vip_EndTime,userid as boardid,info_1
3. In the TrueCheckUserLogin function of bbs/inc/Dv_ClsMain.asp
Sql=Select UserID,UserName,UserPassword,UserEmail,UserPost,UserTopic,UserSex,UserFace,UserWidth,UserHeight,JoinDate,LastLogin as cometime ,LastLogin,LastLogin as activetime,UserLogins,Lockuser,Userclass,UserGroupID,UserGroup,userWealth,userEP,userCP,UserPower,UserBirthday,UserLastIP,UserDel,UserIsBest,Use rHidden,UserMsg,IsChallenge,UserMobile,TitlePic,UserTitle,TruePassWord,UserToday,UserMoney,UserTicket,FollowMsgID,Vip_StarTime,Vip_EndTime,userid as boardid
Modify to:
Sql=Select UserID,UserName,UserPassword,UserEmail,UserPost,UserTopic,UserSex,UserFace,UserWidth,UserHeight,JoinDate,LastLogin as cometime ,LastLogin,LastLogin as activetime,UserLogins,Lockuser,Userclass,UserGroupID,UserGroup,userWealth,userEP,userCP,UserPower,UserBirthday,UserLastIP,UserDel,UserIsBest,Use rHidden,UserMsg,IsChallenge,UserMobile,TitlePic,UserTitle,TruePassWord,UserToday,UserMoney,UserTicket,FollowMsgID,Vip_StarTime,Vip_EndTime,userid as boardid,info_1
4.CheckUserLogin.asp
Response.Cookies(platform) = UserSession.documentElement.selectSingleNode(agent/@platform).text
added after
Response.Cookies(info_1) = UserSession.documentElement.selectSingleNode(userinfo/@info_1).text
5.index.asp
Response.write(operating system: & Request.Cookies(platform) & <br>)
added after
Response.write(new: & Request.Cookies(info_1) & <br>)
6.OK, successfully completed