Discuz! NT Forum integration ASP program Forum tutorial

Source: Internet
Author: User

Copy codeThe Code is as follows: the cookie Page code is recorded during login
<! -- # Include file = "md5.asp" --> // a 32-bit md5 encrypted file must be called. This file is everywhere and I will not provide it
<%
Dim Username, Password, Question, Answer, Expires, Verify
Username = replace (trim (Request. form ("Username"), "'", "'' ") // User Name
Password = replace (trim (Request. form ("Password"), "'", "'' ") // User Password
Question = replace (trim (Request. form ("Question"), "'", "'' ") // password Problem
Answer = replace (trim (Request. form ("Answer"), "'", "'' ") // password Answer
Expires = replace (trim (Request. form ("Expires"), "'", "'' ") // cookie record duration
Verify = replace (trim (Request. form ("Verify"), "'", "'' ") // Verification Code
// The submitted verification is added here, for example, xxx cannot be empty or the field length.
SQL = "select * from [dnt_users] where username = '" & Username "'" // For convenience, I will not add a filter function here. If you must add it when using it, otherwise injected
Set rsw.conn.exe cute (SQL)
If rs. eof then
Response. Write ("<script> alert ('prompt! \ N User Account Error! '); History. back (); </script> ")
Response. end
Else
If rs ("password") <> md5 (Password) then
Response. Write ("<script> alert ('prompt! \ N incorrect user password! '); History. back (); </script> ")
Response. end
Else
If rs ("secques") <> Answer then
Response. Write ("<script> alert ('prompt! \ N Security answer error! '); History. back (); </script> ")
Response. end
Else
Dim DES, DESCode
Set DES = Server. CreateObject ("DiscuzNT. DES ")
DESCode = DES. encode ("" & rs ("password") "", "Z143D2VBML") // Z143D2VBML encrypts your DES key. use NotePad to open general in the CONFIG directory. in the config file, find the <Passwordkey> Z846D4VVZL </Passwordkey> line. The English between <Passwordkey> and </Passwordkey> is your key. Change the key to your file
Set DES = Nothing
Response. Cookies ("dnt") ("userid") = rs ("uid ")
Response. Cookies ("dnt") ("password") = DESCode
Response. Cookies ("dnt") ("tpp") = rs ("tpp ")
Response. Cookies ("dnt") ("ppp") = rs ("ppp ")
Response. Cookies ("dnt") ("pmsound") = rs ("pmsound ")
Response. Cookies ("dnt") ("invisible") = rs ("invisible ")
Response. Cookies ("dnt") ("referer") = "index. aspx"
Response. Cookies ("dnt") ("sigstatus") = rs ("sigstatus ")
Response. Cookies ("dnt") ("expires") = Expires
If Expires <> 0 then
Response. Cookies ("dnt"). Expires = DateAdd ("N", Expires, Now ())
End if
Response. Cookies ("dnt"). Domain = ".xxx.com" // modify it to your Domain name. Note that the front section contains. (Click)
Response. Cookies ("dnt"). Secure = False
End if
End if
End if
Rs. close
Set rs = nothing
// After login is added here, you can turn to or perform other operations.
%>

========================================================== ========================================================== ==============
Registration Page code (LOGIN status after registration)

<! -- # Include file = "md5.asp" --> // 32: the md5 encrypted file must be called. This file is everywhere and I will not provide it
<%
Dim Username, Password, CheckPassword, Email, Question, Answer, Verify
Username = replace (trim (Request. form ("Username"), "'", "'' ") // User Name
Password = replace (trim (Request. form ("Password"), "'", "'' ") // User Password
CheckPassword = replace (trim (Request. form ("CheckPassword"), "'", "'' ") // password verification
Question = replace (trim (Request. form ("Question"), "'", "'' ") // password Problem
Answer = replace (trim (Request. form ("Answer"), "'", "'' ") // password Answer
Expires = replace (trim (Request. form ("Expires"), "'", "'' ") // cookie record duration
Verify = replace (trim (Request. form ("Verify"), "'", "'' ") // Verification Code
// The submitted verification is added here, for example, xxx cannot be empty or the field length.
SQL = "select * from [dnt_users] where username = '" & Username "'" // For convenience, I will not add a filter function here. If you must add it when using it, otherwise injected
Set rsw.conn.exe cute (SQL)
If not rs. eof then
Response. Write ("<script> alert ('prompt! \ N user account has been registered for use! '); History. back (); </script> ")
Response. end
End if
Rs. close
Set rs = nothing
SQL = "select * from [dnt_users] where Email = '" & Email "'" // For convenience, I will not add a filter function here. If you must add it when using it, otherwise injected
Set rsw.conn.exe cute (SQL)
If not rs. eof then
Response. Write ("<script> alert ('prompt! \ N email address has been registered and used! '); History. back (); </script> ")
Response. end
End if
Rs. close
Set rs = nothing
Ip = request. servervariables ("http_x_forwarded_for ")
If ip = "" then ip = request. servervariables ("remote_addr ")
SQL = "insert into [dnt_users] (username, nickname, password, secques, gender, adminid, groupid, groupexpiry, extgroupids, regip, joindate, lastip, lastvisit, lastactivity, lastpost, latency, lastposttitle, posts, latency, oltime, pageviews, credits, extcredits1, extcredits2, extcredits3, extcredits4, extcredits5, latency, latency, extcredits8, latency, email, bday, sigstatus, tpp, ppp, templateid, pmsound, showemail, newsletter, invisible, newpm, newpmcount, accessmasks, onlinestate) values ('"& Username"', '', '" & MD5 (Password) "','" & Answer "', 0, 0, 10, 0,', '" & ip "', '" & now () "', '" & ip "', '"& now ()"', 0, '0. 00', '0. 00', '0. 00', '0. 00', '0. 00', '0. 00', '0. 00', '0. 00', 0, '"& Email )"
Set rsw.conn.exe cute (SQL)
SQL = "select uid from [dnt_users] where username = '" & Username "'" // For convenience, I will not add a filter function here. If you must add it when using it, otherwise injected
Set rsw.conn.exe cute (SQL)
Uid = rs (0)
SQL = "insert into [dnt_userfields] (uid, avatar, avatarwidth, avatarheight, authtime, authflag) values ('" & Uid "', 'avatars \ common \ 0.gif ', 0, 0, '"& now ()"', 0 )"
Set rsw.conn.exe cute (SQL)
SQL = "update [dnt_statistics] set totalusers = totalusers + 1, lastusername = '" & Username "', lastuserid = '" & Uid "'"
Set rsw.conn.exe cute (SQL)
SQL = "select * from [dnt_users] where username = '" & Username "'" // For convenience, I will not add a filter function here. If you must add it when using it, otherwise injected
Set rsw.conn.exe cute (SQL)
If rs. eof then
Response. Write ("<script> alert ('prompt! \ N User Account Error! '); History. back (); </script> ")
Response. end
Else
If rs ("password") <> md5 (Password) then
Response. Write ("<script> alert ('prompt! \ N incorrect user password! '); History. back (); </script> ")
Response. end
Else
Dim DES, DESCode
Set DES = Server. CreateObject ("DiscuzNT. DES ")
DESCode = DES. encode ("" & rs ("password") "", "Z143D2VBML") // Z143D2VBML encrypts your DES key. use NotePad to open general in the CONFIG directory. in the config file, find the <Passwordkey> Z846D4VVZL </Passwordkey> line. The English between <Passwordkey> and </Passwordkey> is your key. Change the key to your file
Set DES = Nothing
Response. Cookies ("dnt") ("userid") = rs ("uid ")
Response. Cookies ("dnt") ("password") = DESCode
Response. Cookies ("dnt") ("tpp") = rs ("tpp ")
Response. Cookies ("dnt") ("ppp") = rs ("ppp ")
Response. Cookies ("dnt") ("pmsound") = rs ("pmsound ")
Response. Cookies ("dnt") ("invisible") = rs ("invisible ")
Response. Cookies ("dnt") ("referer") = "index. aspx"
Response. Cookies ("dnt") ("sigstatus") = rs ("sigstatus ")
Response. Cookies ("dnt") ("expires") = 0
Response. Cookies ("dnt"). Domain = ".xxx.com" // modify it to your Domain name. Note that the front section contains. (Click)
Response. Cookies ("dnt"). Secure = False
End if
End if
Rs. close
Set rs = nothing
// After registration is added here, you can turn to or add user data synchronization to another user table.
%>

========================================================== ========================================================== ==============
Edit the Page code (you do not need to log on again after editing the password)

<! -- # Include file = "md5.asp" --> // 32: the md5 encrypted file must be called. This file is everywhere and I will not provide it
<%
Dim Username, Password, CheckPassword, Email, Question, Answer, Verify
Username = replace (trim (Request. form ("Username"), "'", "'' ") // User Name
Password = replace (trim (Request. form ("Password"), "'", "'' ") // User Password
CheckPassword = replace (trim (Request. form ("CheckPassword"), "'", "'' ") // password verification
Question = replace (trim (Request. form ("Question"), "'", "'' ") // password Problem
Answer = replace (trim (Request. form ("Answer"), "'", "'' ") // password Answer
Expires = replace (trim (Request. form ("Expires"), "'", "'' ") // cookie record duration
Verify = replace (trim (Request. form ("Verify"), "'", "'' ") // Verification Code
// The submitted verification is added here, for example, xxx cannot be empty or the field length.
If Password <> "" then
If Password <> CheckPassword then
Response. Write ("<script> alert ('prompt! The \ n verification password is different from the user password! '); History. back (); </script> ")
Response. end
End if
Password = MD5 (Password)
Else
Password = U_Password // U_Password is your 32-bit MD5 encryption Password, which is read during verification and used for verification here
End if
If AnswerTrue = "true" then
If Question <> 0 then
Answer = mid (MD5 (Answer + MD5 (Question), 16, 8)
Else
Answer = ""
End if
Else
Answer = U_Secques // U_Secques indicates your password Answer. It is read during verification and used for verification here.
End if
Ip = request. servervariables ("http_x_forwarded_for ")
If ip = "" then ip = request. servervariables ("remote_addr ")
SQL = "select * from [dnt_users] where username = '" & Username "'" // For convenience, I will not add a filter function here. If you must add it when using it, otherwise injected
Set rsw.conn.exe cute (SQL)
If Rs. eof then
Response. Write ("<script> alert ('prompt! \ N User Account Error! '); History. back (); </script> ")
Response. end
Else
SQL = "select * from [dnt_users] where email = '" & Email "' and username <> '" & Username "'" // For convenience, I will not add a filter function here. If you use it, you must add it. Otherwise, it will be injected.
Set rsw.conn.exe cute (SQL)
If not rs. eof then
Response. write ("<script> alert ('friendly reminder! \ N email is in use! '); History. back (); </script> ")
Response. end
Else
SQL = "update [dnt_users] set password = '" & Password "', secques = '" & Answer "', email = '"& Email" 'where username =' "& Username" '"// For convenience, I will not add a filter function here. If you must add it when using it, otherwise injected
Set rsw.conn.exe cute (SQL)
Set DES = Server. CreateObject ("DiscuzNT. DES ")
DESCode = DES. encode ("" & Password "", "Z143D2VBML") // Z143D2VBML encrypts your DES key. use NotePad to open general in the CONFIG directory. in the config file, find the <Passwordkey> Z846D4VVZL </Passwordkey> line. The English between <Passwordkey> and </Passwordkey> is your key. Change the key to your file
Set DES = Nothing
Response. Cookies ("dnt") ("userid") = rs ("uid ")
Response. Cookies ("dnt") ("password") = DESCode
Response. Cookies ("dnt") ("tpp") = rs ("tpp ")
Response. Cookies ("dnt") ("ppp") = rs ("ppp ")
Response. Cookies ("dnt") ("pmsound") = rs ("pmsound ")
Response. Cookies ("dnt") ("invisible") = rs ("invisible ")
Response. Cookies ("dnt") ("referer") = "index. aspx"
Response. Cookies ("dnt") ("sigstatus") = rs ("sigstatus ")
Response. Cookies ("dnt") ("expires") = 0
Response. Cookies ("dnt"). Domain = ".xxxx.com" // modify it to your Domain name. Note that the front section contains. (Click)
Response. Cookies ("dnt"). Secure = False
End if
End if
Rs. close
Set rs = nothing
// After editing, you can add and synchronize user data to another user table.
%>

========================================================== ========================================================== ==================
Exit cookie verification page code

<%
Response. Cookies ("dnt") ("userid") = ""
Response. Cookies ("dnt") ("password") = ""
Response. Cookies ("dnt") ("tpp") = ""
Response. Cookies ("dnt") ("ppp") = ""
Response. Cookies ("dnt") ("pmsound") = ""
Response. Cookies ("dnt") ("invisible") = ""
Response. Cookies ("dnt") ("referer") = ""
Response. Cookies ("dnt") ("sigstatus") = ""
Response. Cookies ("dnt") ("expires") = ""
Response. Cookies ("dnt"). Expires = ""
Response. Cookies ("dnt"). Domain = ".xxx.com"
Response. Cookies ("dnt"). Secure = False
Response. Write ("<script> alert ('prompt! \ N User Login canceled! '); Self. opener. location. reload (); window. close (); </script> ")
Response. end
%>

========================================================== ========================================================== ====================
Verify the cookie Page code. This is an easy-to-use verification code, which is basically the same. You can modify it according to your asp program authentication file.
%>
Dim DES, DESCode
Set DES = Server. CreateObject ("DiscuzNT. DES ")
DESCode = DES. decode ("" & request. cookies ("dnt") ("password") "", "Z143D2VBML") // Z143D2VBML encrypts your DES key. use NotePad to open general in the CONFIG directory. in the config file, find the <Passwordkey> Z846D4VVZL </Passwordkey> line. The English between <Passwordkey> and </Passwordkey> is your key. Change the key to your file
Set DES = Nothing
// Read the database to verify that your cookies are correct.
Dim U_UId, U_UserName, U_Password, U_Secques, U_Email
SQL = "select uid, username, password, secques, email from [dnt_users] where uid = '" & request. cookies ("dnt") ("userid") "'and password ='" & DESCode "'" // For convenience, I will not add a filter function for cookies, if you must add it when using it, otherwise it will be injected, you can filter some single quotes and some sensitive ones.
Set rsw.conn.exe cute (SQL)
If not rs. eof then
Founduser = true
U_UId = Rs (0)
U_UserName = Rs (1)
U_Password = Rs (2)
U_Secques = Rs (3)
U_Email = Rs (4)
Else
Founduser = false
End if
Rs. close
Set rs = nothing
%>

Related Article

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.