Visit Counter II

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul W Smith

    Visit Counter II

    The code below works as a page counter for me, counting how many visits my
    web site has per week (Sunday - Saturday). This works fine - it write the
    date and the count to a text file e.g.

    15/8/2008
    1001

    When the new week arrives the old information is just overwritten, however
    what I would like to do is keep the old information but starting the new
    week with two new lines appended to the top of the existing information so
    maintaining the historical data.

    or

    I actually can write the code that appends the two new lines when the new
    week starts. However I do not have sufficient knowledge to be able to write
    the ASP required to either amend the top two lines of the textstream (for
    when the total should be added).

    Any help or references gratefully received.

    PWS

    ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~


    strCountFileNam e = Server.MapPath( Request.ServerV ariables("SCRIP T_NAME") &
    ".cnt")

    Set objFSO = Server.CreateOb ject("Scripting .FileSystemObje ct")

    Set objCountFile = objFSO.OpenText File(strCountFi leName, 1, True)

    If Not objCountFile.At EndOfStream Then
    dtDate = CDate(objCountF ile.ReadLine)
    iCount = CLng(objCountFi le.ReadLine)
    Else
    dtDate = Date
    iCount = 0
    End If

    objCountFile.Cl ose
    Set objCountFile = Nothing

    If IsEmpty(Session ("TotalCount ")) Then

    If Weekday(Date(), vbSunday) = 1 And dtDate <Date then
    iCount = 1
    Else
    iCount = iCount + 1
    End If
    dtDate = Date

    End If

    Session("TotalC ount")= iCount

    Set objCountFile = objFSO.CreateTe xtFile(strCount FileName, True)

    objCountFile.Wr iteLine dtDate

    objCountFile.Wr iteLine iCount

    objCountFile.Cl ose
    Set objCountFile = Nothing

    Set objFSO = Nothing

    Response.Write iCount


Working...