<% ' Logfile IO Routines used by this script... ' Copyright (c) Eugene Semerenko, 2001. http://jetstat.com/asp ' Const ForReading = 1, ForWriting = 2, ForAppending = 8 function LogRead(sLF) ' Read Log File and Return As String on error resume next dim fso, myFile if sLF<>"" then Set fso = Server.CreateObject("Scripting.FileSystemObject") Set myFile = fso.OpenTextFile(Server.MapPath(sLF), ForReading, False) ' Open File for Reading, Not Create New. if err then 'Some error Response.Write("

Error in LogRead: " & err.description & "

") Response.End end if LogRead = "" & myFile.ReadAll myFile.Close Set myFile = Nothing Set fso = Nothing end if ' sLF<>"" end function 'ReadTextFile sub LogWrite(sLF, sLine) ' Write Line to Log File on error resume next dim fso, f if sLF<>"" then Set fso = Server.CreateObject("Scripting.FileSystemObject") if Not fso.FileExists(Server.MapPath(sLF)) then Set f = fso.OpenTextFile(Server.MapPath(sLF), ForAppending, True) ' Open File for Appending, Create New. f.WriteLine "# JS ASP Login Script, (c) Eugene Semerenko, 2002. http://jetstat.com/asp" f.WriteLine "# JS ASP Login Access Log file. Created: " & Now f.WriteLine "# Format: Date & Time, User IP, Username & Event, Referer, User Agent" f.WriteBlankLines 2 else Set f = fso.OpenTextFile(Server.MapPath(sLF), ForAppending, True) ' Open File for Appending, Create New. end if if err then 'Some error Response.Write("

Error in LogWrite: " & err.description & "

Please check that folder and file: '" & cdLogFilePath & "' has correct permissions to Write for Internet Guest Account -
- IUSR_MachineName, where MachineName is your box network name.
Also be sure that your file attributes don't set to READONLY.
") Response.End end if f.WriteLine Now & ", " & Request.ServerVariables("REMOTE_ADDR") & ", " & sLine & ", " & Request.ServerVariables("HTTP_REFERER") & ", " & Request.ServerVariables("HTTP_USER_AGENT") f.Close Set f = Nothing Set fso = Nothing end if ' sLF<>"" end sub function ReadTextFile(sFn, iHtt, iRepl) on error resume next ' Read Text Template (Htt) from templates catalog and make replacements 'sFn is file name, if iHtt than read template, if iRepl then make basic replacement dim fso, myFile, data data="" if sFn<>"" then Set fso = Server.CreateObject("Scripting.FileSystemObject") if iHtt then Set myFile = fso.OpenTextFile(Server.MapPath(cdTemplatePath) & sFn, 1, False) ' Open Template for Reading, Not Create New. else Set myFile = fso.OpenTextFile(Server.MapPath(sFn), 1, False) ' Open File for Reading, Not Create New. end if data = "" & myFile.ReadAll myFile.Close if data<>"" then if iRepl then 'Make Replacements data = Replace(data,"%HOSTURL%", "" & cdHostUrl) data = Replace(data,"%ADMINEMAIL%", "" & cdAdminEMail) data = Replace(data,"%DATENOW%", FormatDateTime(Date,1)) 'Long Date Format data = Replace(data,"%TIMENOW%", FormatDateTime(Time,3)) 'Long Time Format end if else Response.Write("

Error in reading message template file: " & sFn & ".
Please check your config options or template file name.

") end if Set myFile = Nothing Set fso = Nothing end if 'sFn<>"" ReadTextFile=data end function 'ReadTextFile %>