明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 4437|回复: 5

[Dvbbs] [改造DVBBS83]增加自上次登录以下新贴显示及直到功能

[复制链接]
发表于 2010-4-15 19:18 | 显示全部楼层 |阅读模式
本帖最后由 作者 于 2010-5-13 22:26:51 编辑

动网的论坛显示的新贴标识,都只是显示后台设置时间内的新贴标识,最长只能设置到2天。
对于用户来说,用户关心的是自己自从上次登录以来,有哪些贴子是最新的,但动网升级了这么多个版本,一直没有去解决这个问题。
我从2001年开始使用动网论坛,2004年就自己做了改造,不管用户是否已经登录是论坛,都可以显示自用户上次登录以来的新贴标识,如果有新贴,这些新贴将会显示一个标识,并通过点击新贴标识,可以直接到达该主题下的最新的贴子。
后台->版面管理->选每个版面->高级设置->贴子列表相关->显示最新贴图片标识时间设置,设置为0
一、 index.asp 文件:
1.改
  1. Select Case sToken
  2.   Case "width"
  3.    TPL_Echo BWidth
  4.   Case "today"
  5.    If Application(Dvbbs.CacheName &"_information_" & BoardData.selectSingleNode("@boardid").text).documentElement.selectSingleNode("information/@todaynum").text="0" Then
  6.     TPL_Echo "today"
  7.    Else
  8.     TPL_Echo "todaynew"
  9.    End If
复制代码
中的
  1.   If Application(Dvbbs.CacheName &"_information_" & BoardData.selectSingleNode("@boardid").text).documentElement.selectSingleNode("information/@todaynum").text="0" Then
复制代码
换为:
  1. 'mccad edit lastnew 4
  2. '   If Application(Dvbbs.CacheName &"_information_" & BoardData.selectSingleNode("@boardid").text).documentElement.selectSingleNode("information/@todaynum").text="0" Then
  3.    LastPost= Application(Dvbbs.CacheName &"_information_" & BoardData.selectSingleNode("@boardid").text).documentElement.selectSingleNode("information/@lastpost_2").text
  4.    If Not IsDate(LastPost) Then LastPost=Now()
  5.    If DateDiff("s",Dvbbs.Lastlogin,LastPost)< 0 Then
复制代码
2.改
  1. Case "titleimg"   
  2.    If Dvbbs.Board_Setting(60)<>"" And Dvbbs.Board_Setting(60)<>"0" Then
  3.     Dim PostTime
  4.     If Dvbbs.Board_Setting(38) = "0" Then
  5.       PostTime = lastpost(2)
  6.     Else
  7.       PostTime = Topic(5,i)
  8.     End If
  9.     If DateDiff("n",Posttime,Now)+Cint(Dvbbs.Forum_Setting(0)) < CLng(Dvbbs.Board_Setting(61)) Then
  10.      TPL_Echo "&nbsp;<img src="""&Dvbbs.Board_Setting(60)&""" border=""0"" alt="""&DateDiff("n",Posttime,Now)+Cint(Dvbbs.Forum_Setting(0))&"分钟前更新!""/>"
  11.     End If
  12.    End If
中的
  1.    If DateDiff("n",Posttime,Now)+Cint(Dvbbs.Forum_Setting(0)) < CLng(Dvbbs.Board_Setting(61)) Then
  2.      TPL_Echo "&nbsp;<img src="""&Dvbbs.Board_Setting(60)&""" border=""0"" alt="""&DateDiff("n",Posttime,Now)+Cint(Dvbbs.Forum_Setting(0))&"分钟前更新!""/>"
  3.     End If
复制代码
换为:
  1. 'mccad edit lastnew
  2.      if CLng(Dvbbs.Board_Setting(61))>0 then
  3.       If DateDiff("n",Posttime,Now)+Cint(Dvbbs.Forum_Setting(0)) < CLng(Dvbbs.Board_Setting(61)) Then
  4.        TPL_Echo "&nbsp;<a href=""dispbbs.asp?boardID="&Topic(1,i)&"&ID="&Topic(0,i)&"&star="&Int(Topic(6,i)/Dvbbs.CheckNumeric(Dvbbs.Board_Setting(27)))+1&"&page="&page&"&lastid="&lastpost(1)&"#lastnewpost""><img src="""&Dvbbs.Board_Setting(60)&""" border=""0"" alt="""&DateDiff("n",Posttime,Now)+Cint(Dvbbs.Forum_Setting(0))&"分钟前更新!""/></a>"
  5.       End If
  6.      else
  7.        If DateDiff("s",Posttime,Dvbbs.Lastlogin) <0 Then
  8.        TPL_Echo "&nbsp;<a href=""dispbbs.asp?boardID="&Topic(1,i)&"&ID="&Topic(0,i)&"&star="&Int(Topic(6,i)/Dvbbs.CheckNumeric(Dvbbs.Board_Setting(27)))+1&"&page="&page&"&lastid="&lastpost(1)&"#lastnewpost""><img src="""&Dvbbs.Board_Setting(60)&""" border=""0"" alt="""&DateDiff("n",Posttime,Now)+Cint(Dvbbs.Forum_Setting(0))&"分钟前更新!""/></a>"
  9.        End If
  10.      end if
  11.    End If
复制代码
3.
  1.   Case "titleimg"   
  2.    If Dvbbs.Board_Setting(60)<>"" And Dvbbs.Board_Setting(60)<>"0" Then
  3.     Dim PostTime
  4.     If Dvbbs.Board_Setting(38) = "0" Then
  5.       PostTime = lastpost(2)
  6.     Else
  7.       PostTime = TopTopic(5,i)
  8.     End If
后的
  1.     If DateDiff("n",Posttime,Now)+Cint(Dvbbs.Forum_Setting(0)) < CLng(Dvbbs.Board_Setting(61)) Then
  2.      TPL_Echo "&nbsp;<img src="""&Dvbbs.Board_Setting(60)&""" border=""0"" alt="""&DateDiff("n",Posttime,Now)+Cint(Dvbbs.Forum_Setting(0))&"分钟前更新!""/>"
  3.     End If
复制代码
改为
  1.      'mccad edit lastnew
  2.      if CLng(Dvbbs.Board_Setting(61))>0 then
  3.       If DateDiff("n",Posttime,Now)+Cint(Dvbbs.Forum_Setting(0)) < CLng(Dvbbs.Board_Setting(61)) Then
  4.        TPL_Echo "&nbsp;<a href=""dispbbs.asp?boardID="&TopTopic(1,i)&"&ID="&TopTopic(0,i)&"&star="&Int(TopTopic(6,i)/Dvbbs.CheckNumeric(Dvbbs.Board_Setting(27)))+1&"&page="&page&"&lastid="&lastpost(1)&"#lastnewpost""><img src="""&Dvbbs.Board_Setting(60)&""" border=""0"" alt="""&DateDiff("n",Posttime,Now)+Cint(Dvbbs.Forum_Setting(0))&"分钟前更新!""/></a>"
  5.       End If
  6.      else
  7.        If DateDiff("s",Posttime,Dvbbs.Lastlogin) <0 Then
  8.        TPL_Echo "&nbsp;<a href=""dispbbs.asp?boardID="&TopTopic(1,i)&"&ID="&TopTopic(0,i)&"&star="&Int(TopTopic(6,i)/Dvbbs.CheckNumeric(Dvbbs.Board_Setting(27)))+1&"&page="&page&"&lastid="&lastpost(1)&"#lastnewpost""><img src="""&Dvbbs.Board_Setting(60)&""" border=""0"" alt="""&DateDiff("n",Posttime,Now)+Cint(Dvbbs.Forum_Setting(0))&"分钟前更新!""/></a>"
  9.        End If
  10.      end if
复制代码
二、dv_clsmain.asp文件修改:
1.改
  1. Const guestxml="<?xml version=""1.0"" encoding=""gb2312""?><xml><userinfo statuserid=""0"" userid=""0"" username=""客人"" userclass=""客人"" usergroupid=""7"" cometime="""" boardid=""0"" activetime="""" statusstr=""""/></xml>"
复制代码
  1. 'mccad edit lastnew 1
  2. Const guestxml="<?xml version=""1.0"" encoding=""gb2312""?><xml><userinfo statuserid=""0"" userid=""0"" username=""客人"" userclass=""客人"" usergroupid=""7"" cometime="""" boardid=""0"" activetime="""" statusstr="""" lastlogin=""""/></xml>"
复制代码
2.在
  1.   Dim BS
  2.   Set Bs=GetBrowser()
  3.   UserSession.documentElement.appendChild(Bs.documentElement)
  4.   If EnabledSession Then
  5.    Session(CacheName & "UserID")=UserSession.xml
  6.   End If
  7. End Sub
的Dim BS 前加入:
  1.   'mccad edit lastnew 5
  2.   LastLogin=Request.Cookies(Forum_sn&"-LastLogin")
  3.   if Not isDate(LastLogin) then LastLogin=Now()
  4.   UserSession.documentElement.selectSingleNode("userinfo/@lastlogin").text=LastLogin
  5.   Response.Cookies(Forum_sn&"-LastLogin")=Now()
  6.   Response.Cookies(Forum_sn&"-LastLogin").Expires=Date+3650
  7.   'end mccad
复制代码
3.在
  1.   If UserID > 0 Then
  2.    GetCacheUserInfo
  3.   Else
  4.    UserGroupID = 7
  5.    Lastlogin = Now()
  6.   End If
复制代码
中的
   Lastlogin = Now()
改为
  1.    'mccad edit lastnew 2
  2.    'Lastlogin = Now()
  3.    Lastlogin = UserSession.documentElement.selectSingleNode("userinfo/@lastlogin").text
复制代码
4.在
  1.   Dim BS
  2.   Set Bs=GetBrowser()
  3.   UserSession.documentElement.appendChild(Bs.documentElement)
  4.   If EnabledSession Then
  5.    Session(CacheName & "UserID")= UserSession.xml
  6.   End If
  7.   Rs.close()
  8.   Set Rs=Nothing
  9.   GetCacheUserInfo()
  10. End Sub
的Dim BS 前加入:
  1.   'mccad edit lastnew 8
  2.   Dim tmpSession
  3.   Set tmpSession =Server.CreateObject("msxml2.FreeThreadedDOMDocument"& MsxmlVersion)
  4.   If tmpSession.loadxml(Session(CacheName & "UserID")&"")  Then
  5.    if Not tmpSession.documentElement.selectSingleNode("userinfo/@lastlogin") Is Nothing then
  6.     UserSession.documentElement.selectSingleNode("userinfo/@lastlogin").text=tmpSession.documentElement.selectSingleNode("userinfo/@lastlogin").text
  7.    end if
  8.   end if
  9.   Set tmpSession=Nothing
  10.   'end mccad
5.
  1.   '检查是否有新短信
  2.    Call TyUserMsg(Dvbbs.MemberName,0)
  3.    Execute("Update [Dv_User] Set UserToday='0|0|0|0|0',LastLogin = " & SqlNowString & " Where UserID = " & UserID)
  4.    UserSession.documentElement.selectSingleNode("userinfo/@usertoday").text = "0|0|0|0|0"
  5.    LastLogin = Now()
  6.   End If
  7.   If Userhidden = 2 and DateDiff("s",Lastlogin,Now())>Clng(Forum_Setting(8))*60 Then
  8.    '检查是否有新短信
  9.    Call TyUserMsg(Dvbbs.MemberName,0)
  10.    Execute("Update [Dv_User] Set UserLastIP = '" & UserTrueIP & "',LastLogin = " & SqlNowString & " Where UserID = " & UserID)
  11.    Lastlogin = Now()
复制代码
中两个 Lastlogin = Now() 都注释掉,如下:
  1.    '检查是否有新短信
  2.    Call TyUserMsg(Dvbbs.MemberName,0)
  3.    Execute("Update [Dv_User] Set UserToday='0|0|0|0|0',LastLogin = " & SqlNowString & " Where UserID = " & UserID)
  4.    UserSession.documentElement.selectSingleNode("userinfo/@usertoday").text = "0|0|0|0|0"
  5.    'LastLogin = Now() 'mccad edit lastnew 1
  6.   End If
  7.   If Userhidden = 2 and DateDiff("s",Lastlogin,Now())>Clng(Forum_Setting(8))*60 Then
  8.    '检查是否有新短信
  9.    Call TyUserMsg(Dvbbs.MemberName,0)
  10.    Execute("Update [Dv_User] Set UserLastIP = '" & UserTrueIP & "',LastLogin = " & SqlNowString & " Where UserID = " & UserID)
  11.    'Lastlogin = Now() 'mccad edit lastnew 1
  12.   End If
复制代码
三、dispbbs.asp
1.在
Dim CanRead,TrueMaster,Skin
下加入:
  1. 'mccad add lastnew 2
  2. Dim LastID
  3. LastID=Dvbbs.CheckNumeric(Request("LastID"))
2.在
  1. Select Case iTopicMode
  2.   Case 2 G_TopicTitle = "<font color=""red"">"&G_TopicTitle&"</font>"
  3.   Case 3 G_TopicTitle = "<font color=""blue"">"&G_TopicTitle&"</font>"
  4.   Case 4 G_TopicTitle = "<font color=""green"">"&G_TopicTitle&"</font>"
  5.   Case Else
  6. End Select
复制代码
下面加入:
  1. 'mccad add lastnew 1
  2. if 0<LastID then G_CurrentPage = GetCurrentPage(G_CurrentPage)
复制代码
3.在
  1. Function Topic_Ads(n)
  2.   Randomize
  3.   Topic_Ads=Dvbbs.Forum_ads(n)(CInt(UBound(Dvbbs.Forum_ads(n))*Rnd))
  4. End Function
下加入:
  1. 'mccad add lastnew
  2. Function GetCurrentPage(Star)
  3. Dim Rs,TopicID,SQL,Pcount,TopicCount
  4. Set Rs=Dvbbs.Execute("Select top 1  AnnounceID,BoardID,dateandtime,RootID from "&TotalUseTable&"  where  rootID="&AnnounceID&" and locktopic<2 and datediff(""s"",'"& dvbbs.lastlogin &"',dateandtime)>0   order by Announceid")
  5. if rs.eof and rs.bof then
  6.   GetCurrentPage=Star
  7.   exit Function
  8. else
  9.   TopicID=rs(0)
  10. end if
  11. Set Rs=Dvbbs.Execute("Select AnnounceID,BoardID,dateandtime,RootID from "&TotalUseTable&" where rootID="&AnnounceID&" and locktopic<2 and announceid<= "&TopicID&" order by Announceid")
  12.   if rs.eof and rs.bof then
  13.    rs.close:set rs=nothing
  14.   GetCurrentPage=Star
  15.    exit Function
  16.   else
  17.    SQL=rs.GetRows(-1)
  18.    rs.close:set rs=nothing
  19.    TopicCount=Ubound(SQL,2)+1
  20.    if TopicCount mod Cint(dvbbs.Board_Setting(27))=0 then
  21.      Pcount= TopicCount \ Cint(dvbbs.Board_Setting(27))
  22.    else
  23.       Pcount= TopicCount \ Cint(dvbbs.Board_Setting(27))+1
  24.    end if
  25.   GetCurrentPage=Pcount
  26.   end if
  27. end Function
4.在TPL_ParseArea过程的
  1. Case "bbslist"
  2.    iUbd = UBound(G_ItemList, 2)
  3.    If "1"=Dvbbs.Forum_ads(7) Then Dvbbs.Forum_ads(14)=Split(Dvbbs.Forum_ads(14),"#####")
  4.    For G_Floor=0 To iUbd
  5.     '下面几个赋值用在dv_ubbcode.asp
  6.     RootID_a = G_ItemList(7, G_Floor)
  7.     AnnounceID_a= RootID_a
  8.     ReplyID_a = G_ItemList(0, G_Floor)
  9.     UserName = G_ItemList(1, G_Floor)
  10.     PostBuyUser = G_ItemList(19, G_Floor)
  11.     TPL_Scan sTemplate
  12.    Next
复制代码
段的
    TPL_Scan sTemplate
上面加入:
  1.     'mccad add lastnew
  2.     if  0<LastID and datediff("s", dvbbs.lastlogin ,G_ItemList(3, G_Floor))>0 then TPL_Echo "<a name=""lastnewpost""></a>"
复制代码
发表于 2010-4-15 22:07 | 显示全部楼层
谢谢、、、、我是专门过来感谢的
发表于 2010-5-4 11:46 | 显示全部楼层

明经大哥,为什么我找不到这句了:

  1. Const guestxml="<?xml version=""1.0"" encoding=""gb2312""?><xml><userinfo statuserid=""0"" userid=""0"" username=""客人"" userclass=""客人"" usergroupid=""7"" cometime="""" boardid=""0"" activetime="""" statusstr=""""/></xml>"

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
 楼主| 发表于 2010-5-4 12:24 | 显示全部楼层

你是7.1版本的文件,肯定是不一样的。

如果是7.1版本,有一个独立的文件inc/guest.xml

 楼主| 发表于 2010-5-13 22:28 | 显示全部楼层
有点错误,已经修复!
发表于 2011-7-8 13:10 | 显示全部楼层
本帖最后由 vbangle 于 2011-7-9 14:44 编辑

我的是SQL版本,改造后在index.asp大致下面提示出错是,可能是数组Topic不对,需要怎样排查?谢谢

                Case "titleimg"                        
                        If Dvbbs.Board_Setting(60)<>"" And Dvbbs.Board_Setting(60)<>"0" Then
                                Dim PostTime
                                If Dvbbs.Board_Setting(38) = "0" Then
                                                PostTime = lastpost(2)
                                Else
                                                PostTime = TopTopic(5,i)
                                End If
                                'If DateDiff("n",Posttime,Now)+Cint(Dvbbs.Forum_Setting(0)) < CLng(Dvbbs.Board_Setting(61)) Then
                                        'TPL_Echo " <img src="""&Dvbbs.Board_Setting(60)&""" border=""0"" alt="""&DateDiff("n",Posttime,Now)+Cint(Dvbbs.Forum_Setting(0))&"分钟前更新!""/>"
                                'End If        
                                        'mccad edit lastnew
        if CLng(Dvbbs.Board_Setting(61))>0 then
            If DateDiff("n",Posttime,Now)+Cint(Dvbbs.Forum_Setting(0)) < CLng(Dvbbs.Board_Setting(61)) Then
                TPL_Echo " <a href=""dispbbs.asp?boardID="&Topic(1,i)&"&ID="&Topic(0,i)&"&star="&Int(Topic(6,i)/Dvbbs.CheckNumeric(Dvbbs.Board_Setting(27)))+1&"&page="&page&"&lastid="&lastpost(1)&"#lastnewpost""><img src="""&Dvbbs.Board_Setting(60)&""" border=""0"" alt="""&DateDiff("n",Posttime,Now)+Cint(Dvbbs.Forum_Setting(0))&"分钟前更新!""/></a>"
            End If
        else
            If DateDiff("s",Posttime,Dvbbs.Lastlogin) <0 Then
                TPL_Echo " <a href=""dispbbs.asp?boardID="&Topic(1,i)&"&ID="&Topic(0,i)&"&star="&Int(Topic(6,i)/Dvbbs.CheckNumeric(Dvbbs.Board_Setting(27)))+1&"&page="&page&"&lastid="&lastpost(1)&"#lastnewpost""><img src="""&Dvbbs.Board_Setting(60)&""" border=""0"" alt="""&DateDiff("n",Posttime,Now)+Cint(Dvbbs.Forum_Setting(0))&"分钟前更新!""/></a>"
            End If
                                End If
                        End If
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-27 12:16 , Processed in 1.099653 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表