discuz 2.0整合asp系统,用户添加函数
编程学习 2021-07-05 10:58www.dzhlxh.cn编程入门
我的做法是,用户在原来的登录系统登录一次,记录用户名和密码明码,然后往数据库里面添加一个论坛用户(注意密码用32位的MD5),然后再用雪人的方法整合同步登录就可以了
函数可以参考:
<%
'注册论坛用户,参数说明
'username 用户登录名称
'password 用户有登录密码
'groupid 用户组id,高级会员,用户组id为17;正式会员,用户组id为18;普通会员,则用户组id为10
'email,realname,mobile,phone 电子邮件,真实姓名,手机,电话
sub regbbsuser(username,password,groupid,email,realname,mobile,phone)
'数据库连接
MM_conn_bbs_STRING="Driver={SQL Server};server=SURUI;uid=sa;pwd=sa;database=ntylswbbs;"
Set connbbs=Server.Createobject("ADODB.Connection")
connbbs.open MM_conn_bbs_STRING
'检查用户名是否存在
checkuser="select * from dnt_users where username='"&username"'"
set checkuserrs=connbbs.execute(checkuser)
if not checkuserrs.eof then
haveuser="true"
else
haveuser="false"
end if
'如果用户不存在,则增加论坛用户
if haveuser="false" then
'更新dnt_users(用户信息)表
sql1="select * from dnt_users"
set rs1=server.createobject("ADODB.Recordset")
rs1.open sql1,connbbs,1,3
rs1.addnew
rs1("username")=username
rs1("password")=md532(password)
rs1("groupid")=groupid
rs1("email")=email
rs1.update
rs1.close
'读取刚建立用户的id
sql2="select * from dnt_users where username='"&username"'"
set rs2=server.createobject("ADODB.Recordset")
rs2.open sql2,connbbs,1,1
useruid=rs2("uid")
rs2.close
'更新dnt_userfields(用户相关信息)表
sql3="select * from dnt_userfields"
set rs3=server.createobject("ADODB.Recordset")
rs3.open sql3,connbbs,1,3
rs3.addnew
rs3("uid")=useruid
if realname<>"" then
rs3("realname")=realname
end if
if mobile<>"" then
rs3("mobile")=mobile
end if
if phone<>"" then
rs3("phone")=phone
end if
rs3.update
rs3.close
'更新dnt_statistics(论坛状态信息)表
sql4="select * from dnt_statistics"
set rs4=server.createobject("ADODB.Recordset")
rs4.open sql4,connbbs,1,3
rs4("totalusers")=rs4("totalusers")+1
rs4("lastusername")=username
rs4("lastuserid")=useruid
rs4.update
rs4.close
end if
connbbs.close
end sub
'调用函数
call regbbsuser("asp","123456789",18,"123@163.com","啦啦啦","13580351626","0207235803")
%>
代码如下:
<%
'注册论坛用户,参数说明
'username 用户登录名称
'password 用户有登录密码
'groupid 用户组id,高级会员,用户组id为17;正式会员,用户组id为18;普通会员,则用户组id为10
'email,realname,mobile,phone 电子邮件,真实姓名,手机,电话
sub regbbsuser(username,password,groupid,email,realname,mobile,phone)
'数据库连接
MM_conn_bbs_STRING="Driver={SQL Server};server=SURUI;uid=sa;pwd=sa;database=ntylswbbs;"
Set connbbs=Server.Createobject("ADODB.Connection")
connbbs.open MM_conn_bbs_STRING
'检查用户名是否存在
checkuser="select * from dnt_users where username='"&username"'"
set checkuserrs=connbbs.execute(checkuser)
if not checkuserrs.eof then
haveuser="true"
else
haveuser="false"
end if
'如果用户不存在,则增加论坛用户
if haveuser="false" then
'更新dnt_users(用户信息)表
sql1="select * from dnt_users"
set rs1=server.createobject("ADODB.Recordset")
rs1.open sql1,connbbs,1,3
rs1.addnew
rs1("username")=username
rs1("password")=md532(password)
rs1("groupid")=groupid
rs1("email")=email
rs1.update
rs1.close
'读取刚建立用户的id
sql2="select * from dnt_users where username='"&username"'"
set rs2=server.createobject("ADODB.Recordset")
rs2.open sql2,connbbs,1,1
useruid=rs2("uid")
rs2.close
'更新dnt_userfields(用户相关信息)表
sql3="select * from dnt_userfields"
set rs3=server.createobject("ADODB.Recordset")
rs3.open sql3,connbbs,1,3
rs3.addnew
rs3("uid")=useruid
if realname<>"" then
rs3("realname")=realname
end if
if mobile<>"" then
rs3("mobile")=mobile
end if
if phone<>"" then
rs3("phone")=phone
end if
rs3.update
rs3.close
'更新dnt_statistics(论坛状态信息)表
sql4="select * from dnt_statistics"
set rs4=server.createobject("ADODB.Recordset")
rs4.open sql4,connbbs,1,3
rs4("totalusers")=rs4("totalusers")+1
rs4("lastusername")=username
rs4("lastuserid")=useruid
rs4.update
rs4.close
end if
connbbs.close
end sub
'调用函数
call regbbsuser("asp","123456789",18,"123@163.com","啦啦啦","13580351626","0207235803")
%>