UBB Style Forum Since you last came to have a new post function of ASP implementation

Source: Internet
Author: User
Ubb This is the recent use of ASP rewrite UBB forum experience, improper place please correct me
Reference to Chinaasp's Web club (a UBB-style forum)
UBB Forum has a very good feature, that will be marked since your last visit since the new posts, mainly in two places
: The discussion area list and a list of posts in a discussion area.
Usually the graphics used are on.gif,off.gif (the discussion area list), Closed.gif,closedb.gif (a discussion area
List of posts, where on.gif,closedb.gif represents the new or modified post since the last visit.
implementation:
By using a combination of session and cookie variables to implement
1. Session variable
Firstin, identifies whether to enter the page for the first time, or to enter the page by refreshing
2. Cookie variable
Simplified here, the cancellation of the original official version of the UBB Sessionlogin/lastlogin two cookies
Use only Sessionlogindt/lastlogindt two cookies
sessionlogindt-Save the last logon time
lastlogindt-save time for this login
principle:
Takes the last logon time for this session time, and the time of the last post in the discussion area or a discussion area
Compare the last time of the topic, choose the appropriate graphic according to the actual situation, such as:

If Rslist.fields ("status") = "Close" Then
' Topic closed
Response.Write "<tr><td bgcolor= #f7f7f7 >Src=http://www.163design.net/a/q/images/lock.gif > <a href=newsdetail.asp?id= "& RsList.Fields
("PostID") & ">" & Rslist.fields ("Subject") & "</a> </td>"
Else
' Lastly post time for the theme
If Rslist.fields ("lastly") >sessionlogindt then


Response.Write "<tr><td bgcolor= #f7f7f7 >Src=http://www.163design.net/a/q/images/closedb.gif> <a href=newsdetail.asp?id= "& RsList.Fields
("PostID") & ">" & Rslist.fields ("Subject") & "</a> </td>"
Else
Response.Write "<tr><td bgcolor= #f7f7f7 >Src=http://www.163design.net/a/q/images/closed.gif > <a href=newsdetail.asp?id= "& RsList.Fields
("PostID") & ">" & Rslist.fields ("Subject") & "</a> </td>"
End If
End If

Pages: Discussion area list (default.asp)
Code fragment:
If IsEmpty (Session ("Firstin")) Then
' first entry or use of cookies is not allowed

' Take the last access time and assign it to Sessionlogindt
If Not IsEmpty (Request.Cookies ("Lastlogindt")) Then
Sessionlogindt=request.cookies ("Lastlogindt")
If not IsDate (Sessionlogindt) Then
Sessionlogindt=formatdatetime (now)
Else
Sessionlogindt=cdate (Sessionlogindt)
End If
Else
Sessionlogindt=formatdatetime (now)
End If
' Write cookies
' Write Sessionlogindt
Response.Cookies ("Sessionlogindt") =sessionlogindt
Response.Cookies ("Sessionlogindt"). expires=date+365
Response.Cookies ("Lastlogindt") =lastlogindt
Response.Cookies ("Lastlogindt"). expires=date+365
Session ("Firstin") = "yes"
Else
' Refresh, while indicating that cookies are allowed
Session ("Firstin") = "No"
' Read time
If Not IsEmpty (Request.Cookies ("Sessionlogindt")) Then
Sessionlogindt=request.cookies ("Sessionlogindt")
' Sessionlogindt is not legal, this problem generally does not exist
If not IsDate (Sessionlogindt) Then
Sessionlogindt=formatdatetime (now)
Else
Sessionlogindt=cdate (Sessionlogindt)

End If
Else
' No Sessionlogindt cookies, this problem does not generally exist
Sessionlogindt=formatdatetime (now)
' Write Sessionlogindt
Response.Cookies ("Sessionlogindt") =sessionlogindt
&nbs



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.