oblog完全整合动网论坛

转一篇文章以便参考。不过是2005年的,不一定完全适合现在的版本。

-------------------------

 

经过N个小时研究,总算完全整合动网论坛!

 


刚写完,还没有及时整理,请海涵(假设BBS和BLOG分别放在根目录下,如果不是请自行修改)

 

实现功能:论坛登陆自动登陆博客,博客退出论坛也自动退出。实现论坛与博客同步登陆!

 

注意刚出的新版有个别细微差别,没有本质的影响和差异,可放心修改!

 

修改 Cookies
改BBS COOKIES 安全路径:BBS/INC/DV_ClsMain.asp

 


'Cookiepath = CacheData(26,0)
改成:

 

Cookiepath = "/"
改 登陆校验,外部登陆交外部系统处理
BLOG/Login.asp 将以下代码:

 

BLOG/Login.asp 将以下代码:
sub sub_chklogin()
if oblog.chkiplock() then
  oblog.adderrstr("对不起!你的IP已被锁定,不允许登陆,!")
  oblog.showerr
  exit sub
end if
if oblog.setup(58,0)=1 then
  if not oblog.codepass then oblog.adderrstr("验证码错误,请刷新后重新输入!"):oblog.showerr
end if
if UserName="" then oblog.adderrstr("登陆用户名不能为空!")
if Password="" then oblog.adderrstr("登陆密码不能为空!")
if oblog.errstr<>"" then oblog.showerr:exit sub
if CookieDate="" then CookieDate=0 else CookieDate=Clng(CookieDate)
password=md5(password)
if is_ot_user=1 then
  call ot_chklogin()
else
  oblog.ob_chklogin UserName,password,CookieDate
end if
if fromurl<>"" then
  response.Redirect(replace(fromurl,"$","&"))
else
  if action="showindexlogin" then
   if instr(oblog.comeurl,"/err.asp")>0 then
    response.Redirect("index.asp")
   else
    response.Redirect(oblog.comeurl)
   end if
  else
   response.Redirect("user_index.asp")
  end if
end if
end sub

 


改成:

 


sub sub_chklogin()
if oblog.chkiplock() then
  oblog.adderrstr("对不起!你的IP已被锁定,不允许登陆,!")
  oblog.showerr
  exit sub
end if
if UserName="" then oblog.adderrstr("登陆用户名不能为空!")
if Password="" then oblog.adderrstr("登陆密码不能为空!")
if oblog.errstr<>"" then oblog.showerr:exit sub
if CookieDate="" then CookieDate=0 else CookieDate=Clng(CookieDate)

 

if fromurl<>"" then fromurl=replace(fromurl,"$","&")

 

if is_ot_user=1 then
  if fromurl="" then fromurl=blogdir & "user_index.asp"
  response.redirect "../bbs/login.asp?action=chk&username=" & UserName & "&password=" & Password & "&codestr=" & trim(request("codestr")) & "&CookieDate=" & CookieDate & "&comeurl="& Server.URLEncode(fromurl)
else
  if oblog.setup(58,0)=1 then
   if not oblog.codepass then oblog.adderrstr("验证码错误,请刷新后重新输入!"):oblog.showerr
  end if
  password=md5(password)
  oblog.ob_chklogin UserName,password,CookieDate
end if
if fromurl<>"" then
  response.Redirect(fromurl)
else
  if action="showindexlogin" then
   if instr(oblog.comeurl,"/err.asp")>0 then
    response.Redirect("index.asp")
   else
    response.Redirect(oblog.comeurl)
   end if
  else
   response.Redirect("user_index.asp")
  end if
end if
end sub

 


并删除 ot_chklogin() 过程

 

获取 BBS Cookies 参数,使BLOG的Cookies与BBS一致 (注:DVBBS在登陆时系统将随机自动产生密码,所以我们必须校验的密码字段为:TruePassword)
ot_password="TruePassword" '密码字段
BLOG/Conn.asp 添加以下内容:

 


dim ot_connstr,ot_conn,ot_usertable,ot_username,ot_password,ot_regurl,ot_lostpasswordurl,ot_modifypass1,ot_modifypass2
改成

 


dim ot_connstr,ot_conn,ot_usertable,ot_username,ot_password,ot_regurl,ot_lostpasswordurl,ot_modifypass1,ot_modifypass2,ot_cookies_name

 

ot_cookies_name = Replace(Lcase(Replace(Replace(Replace(Server.MapPath("/bbs/index.asp"),"index.asp",""),":",""),"\","")),"_","")  'DVBBS 论坛所用的 Cookies Name

 

const ot_logouturl="../bbs/logout.asp" '退出登陆的地址

 

BLOG/INC/Class_Sys.asp 中 CheckUserLogined 函数内

 

logined_uname=filt_badstr(DecodeCookie(Request.Cookies(cookies_name)("UserName")))
logined_upass=filt_badstr(DecodeCookie(Request.Cookies(cookies_name)("Password")))

 

改成

 

if is_ot_user=1 then
logined_uname=filt_badstr(Request.Cookies(ot_cookies_name)("UserName"))
logined_upass=filt_badstr(Request.Cookies(ot_cookies_name)("Password"))
else
logined_uname=filt_badstr(DecodeCookie(Request.Cookies(cookies_name)("UserName")))
logined_upass=filt_badstr(DecodeCookie(Request.Cookies(cookies_name)("Password")))
end if

 

系统退出是自动退出论坛
BLOG/Logout.asp (新补丁的文件为:user_logout.asp)将
if request("re")="1" then
  response.Redirect(oblog.comeurl)
else
  Response.Redirect "index.asp"
end if
改成

 

if is_ot_user=1 then
response.Redirect ot_logouturl
else
if request("re")="1" then
  response.Redirect(oblog.comeurl)
else
  Response.Redirect "index.asp"
end if
end if

 

OK 搞定!

你可能感兴趣的:(Blog)