The website and Forum are registered with members, logged in, exited, and synchronized with member information modification.

Source: Internet
Author: User

From: http://nt.discuz.net/showtopic.aspx? Topicid = 53983

The company wants to develop a network House website (http://www.dujia168.com), has designed the website database at the early stage of development, including some member information table .. Later I joined the Community power forum, and used an independent domain name (http://bbs.dujia168.com), so the two integration faces a lot of problems: 1: the site and the Forum database is not the same (the site is dujia database, the Forum is a BBS database), and the fields in the member information table are also different. Therefore, you must ensure that members log on, exit, and register on the website and forum, also, data modification must be synchronized. 2: considering that the company will not use this forum in the future, it is easy to separate websites and forums. You cannot make great changes. By learning the relevant information about community motivation, determine the following solutions, and test success (test address: http://www.dujia168.com), ^ _ ^, excited, also written to share with everyone.I. Database integration,Trigger technology is used to synchronize the modification, addition, and deletion of member table information between two databases. The member table of the website is "invalid user". The member data tables related to the Forum include "dnt_users", "dnt_userfields", and "dnt_statistics. For the role of data tables related to the Forum, refer to the instructions on the official website of the Forum. The main steps are as follows: 1. Modify the data design of dnt_users and change the UID specification to "no. For example

01. gif(28.12 K) 13:39:23

2: Modify the Stored Procedure dnt_createuser. Set ansi_nulls on set quoted_identifier on go .... The center remains unchanged, saving space... As declare @ uid int select @ uid = max (userid) + 1 from dujia. [DBO]. [Login User] insert into [dnt_users] ([uid], [username], [nickname], [Password], [secques], [gender], [adminid], [groupid], [groupexpiry], [extgroupids], [regip], [joindate], [lastip], [lastvisit], [lastactivity], [lastpost], [lastpostid], [lastposttitle], [posts], [digestposts], [oltime], [pageviews], [credits], [extcredits1], [extcredits2], [extcredits3], [extcredits4], [extcredits5], [extcredits6], [extcredits7], [extcredits8], [avatarshowid], [email], [bday], [sigstatus], [TPP], [PPP], [templateid], [pmsound], [showemail], [Newsletter], [invisible], [newpm], [accessmasks]) values (@ uid, @ username, @ nickname, @ password, @ secques, @ gender, @ adminid, @ groupid, @ groupexpiry, @ extgroupids, @ regip, @ joindate, @ lastip, @ lastvisit, @ lastactivity, @ lastpost, @ lastpostid, @ lastposttitle, @ posts, @ response, @ oltime, @ pageviews, @ credits, @ extcredits1, @ extcredits2, @ extcredits3, @ extcredits4, @ extcredits5, @ extcredits6, @ extcredits7, @ extcredits8, @ avatarshowid, @ email, @ bday, @ sigstatus, @ TPP, @ PPP, @ templateid, @ pmsound, @ showemail, @ newsletter, @ invisible, @ newpm, @ accessmasks) If @ error = 0 begin update [dnt_statistics] Set [totalusers] = [totalusers] + 1, [lastusername] = @ username, [lastuserid] = @ uid end insert into dnt_userfields ([uid], [website], [ICQ], [QQ], [Yahoo], [MSN], [Skype], [location], [customstatus], [Avatar], [avatarwidth], [avatarheight], [medals], [bio], [Signature], [sightml], [authstr], [realname], [idcard], [mobile], [PHONE]) values (@ uid, @ website, @ ICQ, @ qq, @ yahoo, @ MSN, @ Skype, @ location, @ customstatus, @ avatar, @ avatarwidth, @ avatarheight, @ medals, @ bio, @ signature, @ sightml, @ authstr, @ realname, @ idcard, @ mobile, @ phone) 3: Add a trigger to keep member information synchronized. First, add a trigger to the member table information,

02. gif(11.21 K) 13:39:23

Then, add the triggers in the Forum dnt_users and dnt_userfields respectively,

03. gif(11.60 K) 13:39:23

04. gif(10.11 K) 13:39:23

Because different user tables are designed differently, I only send triggers for adding members to the website for reference: Set ansi_nulls on set quoted_identifier on go alter trigger [DBO]. [user_insert] on [DBO]. [invalid user] For insert as --- temporarily invalidates the trigger in the Forum alter table bbs. [DBO]. [dnt_users] disable trigger dnt_users_insert --- obtain the ID and user name declare @ uid int select @ uid = max (userid) from your user declare @ username nchar (20) select @ username = username from your user --- insert basic forum user data insert in To BBS. [DBO]. [dnt_users] ([uid], [username], [Password], [gender], [email]) select your user. userid, I. username, I. userpassword, case I. usersex when 'F' then 2 when 'M' then 1 When's 'then 0 end, I. useremail from inserted as I inner join login user on login user. username = I. username -- change the user identity to a registered member update BBS. [DBO]. [dnt_users] Set [groupid] = 10 where uid = @ uid --- Insert detailed data of Forum users into BBs. [DBO]. dnt_userfields ([Uid], [QQ], [MSN], [location], [realname], [idcard], [mobile], [PHONE]) select your user. userid, I. userqq, I. usermsn, I. useraddress, I. userrealname, I. useridcard, I. usermobile, I. usertel from inserted as I inner join foreign user on foreign user. username = I. username --- modify Forum Status update BBS. [DBO]. [dnt_statistics] Set [totalusers] = [totalusers] + 1, [lastusername] = @ username, [lastuserid] = @ uid --- make the trigger in the Forum effective alter table bbs. [DBO]. [dnt_users] Enable trigger dnt_users_insert --- issue points insert into dujia. [DBO]. [Login userpoint] (pointaction, pointchange, pointuser) values ('registered member ', 500, @ UID) after the above three steps, data integration has been completed, member information can be modified, deleted, and added synchronously. Let's take a big credit. The following describes program integration.2. Program integration:Program Integration mainly relies on the login of the forum to determine whether to log on and exit. The Forum login uses its own cookies for verification. Encrypt the password with MD5 encryption first. then, DES encryption is used. the encryption key is randomly generated to each user during Forum installation. The encryption key is in the file General. config. <passwordkey> aaaaaaaaaa </passwordkey>. this ensures the security of the user password. Now, we can start program integration. 1: For cross-origin authentication, first set the following in the background of the Forum:

05. gif(3.52 K) 13:39:23

2: extract the required DES encryption function namespace dujia from the Forum's Des encryption file. dbutility {// public class dntdes encryption algorithm of the Forum {// default key vector Private Static byte [] keys = {0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef }; /// <summary> // DES encrypted string /// </Summary> /// <Param name = "encryptstring"> string to be encrypted </param> // /<Param name = "encryptkey"> encryption key, required 8-bit </param> /// <returns> the encrypted string is returned successfully. If the encrypted string fails to be returned, the source string is returned. </returns> Public static string encode (string ENC Ryptstring, string encryptkey) {encryptkey = "your forum encryption key"; encryptkey = getsubstring (encryptkey, 8, ""); encryptkey = encryptkey. padright (8, ''); byte [] rgbkey = encoding. utf8.getbytes (encryptkey. substring (0, 8); byte [] rgbiv = keys; byte [] inputbytearray = encoding. utf8.getbytes (encryptstring); descryptoserviceprovider dcsp = new descryptoserviceprovider (); memorystream mstream = new memorystream (); Cryptostream cstream = new cryptostream (mstream, dcsp. createencryptor (rgbkey, rgbiv), cryptostreammode. write); cstream. write (inputbytearray, 0, inputbytearray. length); cstream. flushfinalblock (); Return convert. tobase64string (mstream. toarray () ;}} 3: log on to a Member. First, verify the validity of the user in the database of the website, and then write cookies if (bll1_user. checkuserlogin (userlogin, md5password, out userid) // Website user verification {string dntpassword = httputil Ity. urlencode (dujia. dbutility. dntdes. encode (md5password, ""); httpcookie cookie = new httpcookie ("DNT"); cookie. values ["userid"] = userid. tostring (); cookie. values ["password"] = dntpassword; cookie. values ["TPP"] = "0"; cookie. values ["PPP"] = "0"; cookie. values ["pmsound"] = "0"; cookie. values ["invisible"] = "0"; cookie. values ["Referer"] = "index. aspx "; cookie. values ["sigstatus"] = "0"; cookie. valu Es ["expires"] = "100"; cookie. expires = datetime. now. addminutes (10); cookie. domain = ".dujia168.com"; response. appendcookie (cookie); response. redirect ("/account/index. aspx ");} else {LTP. common. messageBox. show (this, "the user name or password is incorrect. Please check and log on again !!. The Forum is also logged on. 4: website login verification. This process mainly reads the user ID and password information stored in cookies. Then compare the data extracted from the website database. Consistent, the user is logged on. This step ensures that the user's login status can be determined when logging on to the forum or website. 5: The Website user exits. This mainly aims to clear the cookies and reset the Forum status. Haha, after the above process, I believe that you will integrate the smart ones. There are many omissions in Writing technical articles for the first time. If you have any questions, contact me ,. QQ: 312718144

 

 

========================================================== ==========

Others:

1. Analyze the structure of the BBS User table, and insert the corresponding data into the BBS User table when the Website user is registered.

2. At the same time, after a user logs on, he must also assign values to the BBS session to achieve a local login and full-site browsing.

3. After a user logs on to the BBS, he must also assign values to the website session to enable a local logon and full-site browsing.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.