<SCRIPT language="VBScript" RUNAT="Server">
sub Application_Onstart()
Dim ifn,jfn,tmpval,founUser,notsfile
Dim fsonlum,SourceFile,TargetFile,ObjCoutpath,CounterObj
Dim Applonlinum(5)
notsfile = False
For ifn=0 to 4
Applonlinum(ifn) = 0
Next
Set fsonlum = Server.CreateObject("Scripting.FileSystemObject")
SourceFile = Server.MapPath("Database/counter.pn")
TargetFile = Server.MapPath("Database/counter.ini")
ObjCoutpath = TargetFile
if Not fsonlum.FileExists (TargetFile) Then
if Not fsonlum.FileExists (SourceFile) Then
notsfile = True
Set CounterObj = fsonlum.CreateTextFile(SourceFile,True)
CounterObj.Close
end if
fsonlum.CopyFile SourceFile,TargetFile
end if
Set CounterObj = fsonlum.OpenTextFile(ObjCoutpath)
ifn = 0
Do While Not CounterObj.atEndOfStream
Applonlinum(ifn) = CounterObj.ReadLine
Applonlinum(ifn) = Replace(Applonlinum(ifn),vbCrLf,"")
Applonlinum(ifn) = trim(Applonlinum(ifn))
ifn = ifn + 1
Loop
if IsArray(Applonlinum) then
if ifn <= 1 Then
Applonlinum(0) = 64
Applonlinum(1) = int(Rnd()/8*30)
Applonlinum(2) = Applonlinum(1) + 3
Applonlinum(3) = cStr(Now())
Applonlinum(4) = cStr(Date())
else
Applonlinum(1) = int(Rnd()/6*50)
end if
end if
if Applonlinum(2) >= Applonlinum(0)/2 Then
Applonlinum(2) = Int(Applonlinum(0)/2)
end if
Application.lock
Application("onlieum") = Applonlinum
Application.Unlock
CounterObj.Close
if Day(Date()) - Day(Application("onlieum")(4)) >=1 then
Applonlinum(2) = Applonlinum(1) + 3
Applonlinum(4) = cStr(Date())
end if
if notsfile = True Then
Set CounterObj = fsonlum.OpenTextFile(ObjCoutpath,2,True)
For jfn=0 to 4
CounterObj.WriteLine Applonlinum(jfn)
Next
fsonlum.CopyFile TargetFile,SourceFile,True
CounterObj.Close
end if