Discuz!NT 论坛整合ASP程序论坛教程
程序员文章站
2022-05-08 13:10:23
复制代码 代码如下:登陆时记录cookies页面代码 //32位md5加密文件,一定得调用,该文件...
复制代码 代码如下:
登陆时记录cookies页面代码
<!--#include file="md5.asp"--> //32位md5加密文件,一定得调用,该文件到处有,我就不提供了
<%
dim username,password,question,answer,expires,verify
username=replace(trim(request.form("username")),"'","''") //用户名
password=replace(trim(request.form("password")),"'","''") //用户密码
question=replace(trim(request.form("question")),"'","''") //密码问题
answer=replace(trim(request.form("answer")),"'","''") //密码答案
expires=replace(trim(request.form("expires")),"'","''") //cookies记录时长
verify=replace(trim(request.form("verify")),"'","''") //验证码
//此处加上提交的验证,如xxx不能为空等或字段长度等
sql="select * from [dnt_users] where username='"&username"'" //为了方便,此处我就不加过滤函数了,如你使用时一定加上,否则被注入
set rs=conn.execute(sql)
if rs.eof then
response.write ("<script>alert('提示!\n\n用户帐号错误!');history.back();</script>")
response.end
else
if rs("password")<>md5(password) then
response.write ("<script>alert('提示!\n\n用户密码错误!');history.back();</script>")
response.end
else
if rs("secques")<>answer then
response.write ("<script>alert('提示!\n\n安全答案错误!');history.back();</script>")
response.end
else
dim des,descode
set des=server.createobject("discuznt.des")
descode=des.encode(""&rs("password")"","z143d2vbml") //z143d2vbml为你的des加密密钥,请用记事本打开config目录里的general.config文件,找到<passwordkey>z846d4vvzl</passwordkey>这行,<passwordkey>与</passwordkey>中间的英文就是你的密钥,把密钥修改成你的文件的
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" //修改为你的域名,注意前面带.(点)
response.cookies("dnt").secure = false
end if
end if
end if
rs.close
set rs=nothing
//此处加登陆后转向或向其他操作,具体你自己看着办
%>
===========================================================================================
注册页面代码(注册完后同时登陆状态)
<!--#include file="md5.asp"--> //32为md5加密文件,一定得调用,该文件到处有,我就不提供了
<%
dim username,password,checkpassword,email,question,answer,verify
username=replace(trim(request.form("username")),"'","''") //用户名
password=replace(trim(request.form("password")),"'","''") //用户密码
checkpassword=replace(trim(request.form("checkpassword")),"'","''") //密码验证
question=replace(trim(request.form("question")),"'","''") //密码问题
answer=replace(trim(request.form("answer")),"'","''") //密码答案
expires=replace(trim(request.form("expires")),"'","''") //cookies记录时长
verify=replace(trim(request.form("verify")),"'","''") //验证码
//此处加上提交的验证,如xxx不能为空等或字段长度等
sql="select * from [dnt_users] where username='"&username"'" //为了方便,此处我就不加过滤函数了,如你使用时一定加上,否则被注入
set rs=conn.execute(sql)
if not rs.eof then
response.write ("<script>alert('提示!\n\n用户帐号已被注册使用!');history.back();</script>")
response.end
end if
rs.close
set rs=nothing
sql="select * from [dnt_users] where email='"&email"'" //为了方便,此处我就不加过滤函数了,如你使用时一定加上,否则被注入
set rs=conn.execute(sql)
if not rs.eof then
response.write ("<script>alert('提示!\n\n电子邮箱已被注册使用!');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,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,newpmcount,accessmasks,onlinestate) values ('"&username"',' ','"&md5(password)"','"&answer"',0,0,10,0,' ','"&ip"','"&now()"','"&ip"','"&now()"','"&now()"','"&now()"',0,' ',0,0,0,0,0,'0.00','0.00','0.00','0.00','0.00','0.00','0.00','0.00',0,'"&email"',' ',1,0,0,0,1,1,1,0,1,1,0,1)"
set rs=conn.execute(sql)
sql="select uid from [dnt_users] where username='"&username"'" //为了方便,此处我就不加过滤函数了,如你使用时一定加上,否则被注入
set rs=conn.execute(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 rs=conn.execute(sql)
sql="update [dnt_statistics] set totalusers=totalusers+1,lastusername='"&username"',lastuserid='"&uid"'"
set rs=conn.execute(sql)
sql="select * from [dnt_users] where username='"&username"'" //为了方便,此处我就不加过滤函数了,如你使用时一定加上,否则被注入
set rs=conn.execute(sql)
if rs.eof then
response.write ("<script>alert('提示!\n\n用户帐号错误!');history.back();</script>")
response.end
else
if rs("password")<>md5(password) then
response.write ("<script>alert('提示!\n\n用户密码错误!');history.back();</script>")
response.end
else
dim des,descode
set des=server.createobject("discuznt.des")
descode=des.encode(""&rs("password")"","z143d2vbml") //z143d2vbml为你的des加密密钥,请用记事本打开config目录里的general.config文件,找到<passwordkey>z846d4vvzl</passwordkey>这行,<passwordkey>与</passwordkey>中间的英文就是你的密钥,把密钥修改成你的文件的
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" //修改为你的域名,注意前面带.(点)
response.cookies("dnt").secure = false
end if
end if
rs.close
set rs=nothing
//此处加注册后转向或向另外一个用户表添加同步用户数据,具体你自己看着办
%>
===========================================================================================
编辑页面代码(编辑密码后无需重新登陆)
<!--#include file="md5.asp"--> //32为md5加密文件,一定得调用,该文件到处有,我就不提供了
<%
dim username,password,checkpassword,email,question,answer,verify
username=replace(trim(request.form("username")),"'","''") //用户名
password=replace(trim(request.form("password")),"'","''") //用户密码
checkpassword=replace(trim(request.form("checkpassword")),"'","''") //密码验证
question=replace(trim(request.form("question")),"'","''") //密码问题
answer=replace(trim(request.form("answer")),"'","''") //密码答案
expires=replace(trim(request.form("expires")),"'","''") //cookies记录时长
verify=replace(trim(request.form("verify")),"'","''") //验证码
//此处加上提交的验证,如xxx不能为空等或字段长度等
if password<>"" then
if password<>checkpassword then
response.write ("<script>alert('提示!\n\n验证密码与用户密码不相同!');history.back();</script>")
response.end
end if
password=md5(password)
else
password=u_password //u_password为你的32位md5加密密码,在验证时读取出来用来这里验证
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为你的密码答案,在验证时读取出来用来这里验证
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"'" //为了方便,此处我就不加过滤函数了,如你使用时一定加上,否则被注入
set rs=conn.execute(sql)
if rs.eof then
response.write ("<script>alert('提示!\n\n用户帐号错误!');history.back();</script>")
response.end
else
sql="select * from [dnt_users] where email='"&email"' and username<>'"&username"'" //为了方便,此处我就不加过滤函数了,如你使用时一定加上,否则被注入
set rs=conn.execute(sql)
if not rs.eof then
response.write ("<script>alert('友情提示!\n\n邮箱已被使用!');history.back();</script>")
response.end
else
sql="update [dnt_users] set password='"&password"',secques='"&answer"',email='"&email"' where username='"&username"'" //为了方便,此处我就不加过滤函数了,如你使用时一定加上,否则被注入
set rs=conn.execute(sql)
set des=server.createobject("discuznt.des")
descode=des.encode(""&password"","z143d2vbml") //z143d2vbml为你的des加密密钥,请用记事本打开config目录里的general.config文件,找到<passwordkey>z846d4vvzl</passwordkey>这行,<passwordkey>与</passwordkey>中间的英文就是你的密钥,把密钥修改成你的文件的
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" //修改为你的域名,注意前面带.(点)
response.cookies("dnt").secure = false
end if
end if
rs.close
set rs=nothing
//此处加编辑后转向或向另外一个用户表添加同步用户数据,具体你自己看着办
%>
=============================================================================================
退出验证cookies页面代码
<%
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('提示!\n\n用户注销登陆完毕!');self.opener.location.reload();window.close();</script>")
response.end
%>
==============================================================================================
验证cookies页面代码,这是我为了简单随手写的一段验证代码,基本都是大同小异,具体你根据你的asp程序验证文件来修改
%>
dim des,descode
set des=server.createobject("discuznt.des")
descode=des.decode(""&request.cookies("dnt")("password")"","z143d2vbml") //z143d2vbml为你的des加密密钥,请用记事本打开config目录里的general.config文件,找到<passwordkey>z846d4vvzl</passwordkey>这行,<passwordkey>与</passwordkey>中间的英文就是你的密钥,把密钥修改成你的文件的
set des=nothing
//下面是读取数据库来验证你的cookies是否正确
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"'" //为了方便,cookies用户和密码我就不加过滤函数了,如你使用时一定加上,否则被注入,就过滤些单引号及一些比较敏感的就可以了
set rs=conn.execute(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
%>
推荐阅读
-
Discuz!NT 论坛整合ASP程序论坛教程
-
Discuz!NT 论坛整合ASP程序论坛
-
Linux+Nginx+MySQL下配置论坛程序Discuz的基本教程
-
Linux+Nginx+MySQL下配置论坛程序Discuz的基本教程_PHP
-
Linux+Nginx+MySQL下配置论坛程序Discuz的基本教程,_PHP教程
-
Linux+Nginx+MySQL下配置论坛程序Discuz的基本教程,
-
Linux+Nginx+MySQL下配置论坛程序Discuz的基本教程,
-
Linux+Nginx+MySQL下配置论坛程序Discuz的基本教程
-
Discuz!NT 论坛整合ASP程序论坛教程
-
Discuz!NT 论坛整合ASP程序论坛