Using ASP to write a simple daily flow, maximum daily traffic statistics

Source: Internet
Author: User
Tags date ini readline
Traffic | Statistics using ASP to write a simple daily flow, maximum daily flow statistics
-----------------------------------------------------------------------------

<%
' #########-statistics today, maximum daily flow-##########

Sub My_today_counter ()

Day1 = CStr (date ()) ' ######-get current date
Day_counter_file = Server.MapPath ("Counter/day_counter.ini") ' ######-Specify counter file

Set fo = Server.CreateObject ("Scripting.FileSystemObject")
Set get_old = fo. OpenTextFile (day_counter_file,1,false,false) ' ######-read record file
Day2 = Get_old. ReadLine
Today_counter = Get_old. ReadLine
Get_old.close

Application ("todays") = Today_counter

Set out = fo. CreateTextFile (Day_counter_file,true,false)

If day1 = Day2 Then ' #######-write today Traffic
Out. WriteLine (Day2)
Today_counter = Today_counter + 1
Out.writeline (Today_counter)
Out. Close

Else ' ######-a new day, summarizing maximum daily traffic
Max_day_counter_file = Server.MapPath ("Counter/max_day_counter.ini")
Set Outmax = fo. OpenTextFile (Max_day_counter_file,1,false,false)
Day3 = Outmax.readline
Maxdaycounter = Outmax.readline ' ######-read maximum daily traffic record
Outmax.close

Application ("maxday") = Maxdaycounter ' ######-maximum daily flow

If Today_counter-maxdaycounter>0 then ' ######-yesterday traffic is greater than maximum daily traffic record
Application ("maxday") = Today_counter ' ######-maximum daily flow
Set Outmax = Fo.createtextfile (max_day_counter_file,true,false)
Outmax.writeline (day2) ' ######-if Day2 has maximum daily flow
Outmax.writeline (today_counter) ' ######-write maximum daily traffic record
Outmax.close
End If

Out.writeline (day1) ' ######-Create a new day traffic statistics file
Today_counter = 1
Out. WriteLine (Today_counter)
Out. Close
End If

End Sub
Application.Lock ' Lock
My_today_counter ' Call procedure
Application.UnLock ' unlock lock

%>


&LT;TD align=center class=big><a href= "Javascript:alert (' from May 1, 2001 to present, tomorrow net total traffic: <% =application (" counter ")% > Today: <%=application ("todays")%> busiest: <%=application ("Maxday")%> (passengers) ' onmouseover= ' window.status= ' Click to view traffic statistics information '; return true; "onmouseout=" window.status= "; return true; " > Flow Statistics </a>



===========================================================================
To ensure that the above program runs normally, you must first build two files under the directory/counter this file

(1) Day_counter.ine
File contents:

01-11-23
1


(2) Max_day_counter.ine
File contents:

01-11-22
1


<!--##########-01-11-23 is the server today's date-->



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.