- 积分
- 73438
- 明经币
- 个
- 注册时间
- 2001-6-7
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 作者 于 2010-5-13 22:26:51 编辑
动网的论坛显示的新贴标识,都只是显示后台设置时间内的新贴标识,最长只能设置到2天。
对于用户来说,用户关心的是自己自从上次登录以来,有哪些贴子是最新的,但动网升级了这么多个版本,一直没有去解决这个问题。
我从2001年开始使用动网论坛,2004年就自己做了改造,不管用户是否已经登录是论坛,都可以显示自用户上次登录以来的新贴标识,如果有新贴,这些新贴将会显示一个标识,并通过点击新贴标识,可以直接到达该主题下的最新的贴子。
后台->版面管理->选每个版面->高级设置->贴子列表相关->显示最新贴图片标识时间设置,设置为0
一、 index.asp 文件:
1.改- Select Case sToken
- Case "width"
- TPL_Echo BWidth
- Case "today"
- If Application(Dvbbs.CacheName &"_information_" & BoardData.selectSingleNode("@boardid").text).documentElement.selectSingleNode("information/@todaynum").text="0" Then
- TPL_Echo "today"
- Else
- TPL_Echo "todaynew"
- End If
复制代码 中的
- If Application(Dvbbs.CacheName &"_information_" & BoardData.selectSingleNode("@boardid").text).documentElement.selectSingleNode("information/@todaynum").text="0" Then
复制代码 换为:- 'mccad edit lastnew 4
- ' If Application(Dvbbs.CacheName &"_information_" & BoardData.selectSingleNode("@boardid").text).documentElement.selectSingleNode("information/@todaynum").text="0" Then
- LastPost= Application(Dvbbs.CacheName &"_information_" & BoardData.selectSingleNode("@boardid").text).documentElement.selectSingleNode("information/@lastpost_2").text
- If Not IsDate(LastPost) Then LastPost=Now()
- If DateDiff("s",Dvbbs.Lastlogin,LastPost)< 0 Then
复制代码 2.改
- 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 = Topic(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
- 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
复制代码 3.- 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="&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>"
- End If
- else
- If DateDiff("s",Posttime,Dvbbs.Lastlogin) <0 Then
- TPL_Echo " <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>"
- End If
- end if
复制代码 二、dv_clsmain.asp文件修改:
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>"
复制代码 为- 'mccad edit lastnew 1
- 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.在- Dim BS
- Set Bs=GetBrowser()
- UserSession.documentElement.appendChild(Bs.documentElement)
- If EnabledSession Then
- Session(CacheName & "UserID")=UserSession.xml
- End If
- End Sub
的Dim BS 前加入:- 'mccad edit lastnew 5
- LastLogin=Request.Cookies(Forum_sn&"-LastLogin")
- if Not isDate(LastLogin) then LastLogin=Now()
- UserSession.documentElement.selectSingleNode("userinfo/@lastlogin").text=LastLogin
- Response.Cookies(Forum_sn&"-LastLogin")=Now()
- Response.Cookies(Forum_sn&"-LastLogin").Expires=Date+3650
- 'end mccad
复制代码 3.在- If UserID > 0 Then
- GetCacheUserInfo
- Else
- UserGroupID = 7
- Lastlogin = Now()
- End If
复制代码 中的
Lastlogin = Now()
改为- 'mccad edit lastnew 2
- 'Lastlogin = Now()
- Lastlogin = UserSession.documentElement.selectSingleNode("userinfo/@lastlogin").text
复制代码 4.在- Dim BS
- Set Bs=GetBrowser()
- UserSession.documentElement.appendChild(Bs.documentElement)
- If EnabledSession Then
- Session(CacheName & "UserID")= UserSession.xml
- End If
- Rs.close()
- Set Rs=Nothing
- GetCacheUserInfo()
- End Sub
的Dim BS 前加入:- 'mccad edit lastnew 8
- Dim tmpSession
- Set tmpSession =Server.CreateObject("msxml2.FreeThreadedDOMDocument"& MsxmlVersion)
- If tmpSession.loadxml(Session(CacheName & "UserID")&"") Then
- if Not tmpSession.documentElement.selectSingleNode("userinfo/@lastlogin") Is Nothing then
- UserSession.documentElement.selectSingleNode("userinfo/@lastlogin").text=tmpSession.documentElement.selectSingleNode("userinfo/@lastlogin").text
- end if
- end if
- Set tmpSession=Nothing
- 'end mccad
5.
- '检查是否有新短信
- Call TyUserMsg(Dvbbs.MemberName,0)
- Execute("Update [Dv_User] Set UserToday='0|0|0|0|0',LastLogin = " & SqlNowString & " Where UserID = " & UserID)
- UserSession.documentElement.selectSingleNode("userinfo/@usertoday").text = "0|0|0|0|0"
- LastLogin = Now()
- End If
- If Userhidden = 2 and DateDiff("s",Lastlogin,Now())>Clng(Forum_Setting(8))*60 Then
- '检查是否有新短信
- Call TyUserMsg(Dvbbs.MemberName,0)
- Execute("Update [Dv_User] Set UserLastIP = '" & UserTrueIP & "',LastLogin = " & SqlNowString & " Where UserID = " & UserID)
- Lastlogin = Now()
复制代码 中两个 Lastlogin = Now() 都注释掉,如下:- '检查是否有新短信
- Call TyUserMsg(Dvbbs.MemberName,0)
- Execute("Update [Dv_User] Set UserToday='0|0|0|0|0',LastLogin = " & SqlNowString & " Where UserID = " & UserID)
- UserSession.documentElement.selectSingleNode("userinfo/@usertoday").text = "0|0|0|0|0"
- 'LastLogin = Now() 'mccad edit lastnew 1
- End If
- If Userhidden = 2 and DateDiff("s",Lastlogin,Now())>Clng(Forum_Setting(8))*60 Then
- '检查是否有新短信
- Call TyUserMsg(Dvbbs.MemberName,0)
- Execute("Update [Dv_User] Set UserLastIP = '" & UserTrueIP & "',LastLogin = " & SqlNowString & " Where UserID = " & UserID)
- 'Lastlogin = Now() 'mccad edit lastnew 1
- End If
复制代码 三、dispbbs.asp
1.在
Dim CanRead,TrueMaster,Skin
下加入:- 'mccad add lastnew 2
- Dim LastID
- LastID=Dvbbs.CheckNumeric(Request("LastID"))
2.在
- Select Case iTopicMode
- Case 2 G_TopicTitle = "<font color=""red"">"&G_TopicTitle&"</font>"
- Case 3 G_TopicTitle = "<font color=""blue"">"&G_TopicTitle&"</font>"
- Case 4 G_TopicTitle = "<font color=""green"">"&G_TopicTitle&"</font>"
- Case Else
- End Select
复制代码 下面加入:
- 'mccad add lastnew 1
- if 0<LastID then G_CurrentPage = GetCurrentPage(G_CurrentPage)
复制代码 3.在- Function Topic_Ads(n)
- Randomize
- Topic_Ads=Dvbbs.Forum_ads(n)(CInt(UBound(Dvbbs.Forum_ads(n))*Rnd))
- End Function
下加入:- 'mccad add lastnew
- Function GetCurrentPage(Star)
- Dim Rs,TopicID,SQL,Pcount,TopicCount
- 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")
- if rs.eof and rs.bof then
- GetCurrentPage=Star
- exit Function
- else
- TopicID=rs(0)
- end if
- Set Rs=Dvbbs.Execute("Select AnnounceID,BoardID,dateandtime,RootID from "&TotalUseTable&" where rootID="&AnnounceID&" and locktopic<2 and announceid<= "&TopicID&" order by Announceid")
- if rs.eof and rs.bof then
- rs.close:set rs=nothing
- GetCurrentPage=Star
- exit Function
- else
- SQL=rs.GetRows(-1)
- rs.close:set rs=nothing
- TopicCount=Ubound(SQL,2)+1
- if TopicCount mod Cint(dvbbs.Board_Setting(27))=0 then
- Pcount= TopicCount \ Cint(dvbbs.Board_Setting(27))
- else
- Pcount= TopicCount \ Cint(dvbbs.Board_Setting(27))+1
- end if
- GetCurrentPage=Pcount
- end if
- end Function
4.在TPL_ParseArea过程的
- Case "bbslist"
- iUbd = UBound(G_ItemList, 2)
- If "1"=Dvbbs.Forum_ads(7) Then Dvbbs.Forum_ads(14)=Split(Dvbbs.Forum_ads(14),"#####")
- For G_Floor=0 To iUbd
- '下面几个赋值用在dv_ubbcode.asp
- RootID_a = G_ItemList(7, G_Floor)
- AnnounceID_a= RootID_a
- ReplyID_a = G_ItemList(0, G_Floor)
- UserName = G_ItemList(1, G_Floor)
- PostBuyUser = G_ItemList(19, G_Floor)
- TPL_Scan sTemplate
- Next
复制代码 段的
TPL_Scan sTemplate
上面加入:- 'mccad add lastnew
- if 0<LastID and datediff("s", dvbbs.lastlogin ,G_ItemList(3, G_Floor))>0 then TPL_Echo "<a name=""lastnewpost""></a>"
复制代码 |
|