Using ToLogFile()

Contents of this folder :

Here are the contents of "logs/mylog.txt" file: (deleted when filesize > 20000 bytes)
<%response.write("Ahem ... you have nothing to do here!!")
response.end%>
[ 22-11-2024 07:41:27 ]     A visitor from 54.36.148.163
[ 22-11-2024 10:51:12 ]     A visitor from 135.181.138.3
[ 22-11-2024 10:53:04 ]     A visitor from 54.36.149.58
[ 22-11-2024 17:28:13 ]     A visitor from 57.141.0.25
[ 23-11-2024 17:59:39 ]     A visitor from 54.36.149.80
[ 23-11-2024 18:12:41 ]     A visitor from 54.36.149.106
[ 24-11-2024 13:42:25 ]     A visitor from 216.244.66.230
[ 24-11-2024 15:15:06 ]     A visitor from 3.17.155.142

Here are the contents of 'default.asp':
<!-- The includefile is one level back from the "default.asp" file: -->
<!--#include file ="../../jakes_IO.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="da">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Example use of the ToLogFile function</title>
    <link rel="stylesheet" type="text/css" href="/jake.css">
</head>
<body>
    <div align="center"><h1>Using ToLogFile()</h1></div>
    <b>Contents of this folder :</b><br>
    <% dim logstring
    
    logstring = "A visitor from " & request.servervariables("REMOTE_ADDR") & " "
    select case request.querystring("action")
        case "Button 1"
            logstring = logstring & "pressed button1"
        case "Button 2"
            logstring = logstring & "pressed button2"
        case "Button 3"
            logstring = logstring & "pressed button3"
        case "Say hello"
            logstring = logstring & "said 'Hello': )"
        case "Say bye"
            logstring = logstring & "said 'Bye': )"
        end select
        
        tologfile "logs/mylog.txt", logstring
        %>
    <form method="get" action="default.asp?action=button1"><input type="submit" name="action" value="Button 1">
    <input type="submit" name="action" value="Button 2">
    <input type="submit" name="action" value="Button 3">
    <input type="submit" name="action" value="Say hello">
    <input type="submit" name="action" value="Say bye">
    </form>
    
    <p><b>Here are the contents of "logs/mylog.txt" file:</b> (deleted when filesize > 20000 bytes)
    <br><span style="display:block;border:1px solid black;background:#DEF;padding:10px;font-size:11px;">
    <%
        response.write(stringToHTML(getFileContents("logs/mylog.txt")))
        if getsize("logs/mylog.txt") > 20000 then delete("logs/mylog.txt")
    %>
    </span>

    <p><b>Here are the contents of 'default.asp':</b>
    <br><span style="display:block;border:1px solid black;background:#FDE;padding:10px;font-size:11px;">
    <%
        response.write(stringToHTML(getFileContents("default.asp")))
    %>
    </span>


</body>
</html>