Free ASP Code / Script:
Zero Administration Guestbook (Ver 1.17)

How I Configured ZAG?

Well, everybody makes mistakes. Once you make 1 little mistake, everything goes wrong. And so is this guestbook. So I decided to show you how I configured the test guestbook.

The red text below is the only essential change you need to make. Others are optional. You just need to edit only 3 lines correctly. This code below is running at
http://www7.eWebCity.com/myanmarsnet/zagtest.asp

 

<%
'------------------------------
' Zero Administration Guestbook - Ver 1.17
' Copyright 2000 Steven HTUT. All rights reserved.
' http://winmyanmar.bizhosting.com/zag.htm
'
' This asp code can be used free of charge, as long as this copyright notice stays intact.

'------------------------------

' CONFIGURE YOUR GUESTBOOK'S LOOK
Dim strFile, bDay, strBakFile, strDump, SiteTitle, WelcomeMessage, TextAttribute, LineAttribute
SiteTitle     = "ZAG "
WelcomeMessage    = "Welcome to our Zero Administration Guestbook Testing Place! Please tell us what kind of thoughts, comments, or suggestions you have about our site..."
strFile     = Server.MapPath("
/myanmarsnet/db/zagtest.htm")
strLog         = Server.MapPath("
/myanmarsnet/db/guestbook.log")
LineAttribute     = "<hr size='1' color='red'>"              'note the use of single quotes
TextAttribute     = "<font face='Comic Sans MS' size='3' color='navy'>"    'note the use of single quotes






' DON'T EDIT BELOW THIS LINE
'------------------------------

If Request.Form.Count = 0 Then
%>
    <html><head>
    <title>
    <%
    response.write (SiteTitle)
    %>
    Guestbook: thoughts, comments, suggestions...</title>
    <style><!--
    body { font-family: sans-serif; font-size: 10pt }
    A:hover { color: white; background-color: red; }
    A:link { color: red; }
    -->
    </style></head>
    <body bgcolor="#FFFFFF" link="#FF0000">

    <H1>
    <% response.write (SiteTitle) %>
    Guestbook</H1>
    <% response.write (WelcomeMessage) %>
    <FORM ACTION="zagtest.asp" METHOD="post">
    <TABLE>
        <TR>
        <TD ALIGN="right" VALIGN="top"><B>Comment:</B></TD>
        <TD><textarea rows="9" name="comment" cols="90"></textarea>
        <TR>
        <TD ALIGN="right"><B>Name:</B></TD>
        <TD><INPUT TYPE="text" NAME="name" SIZE="30"></TD>
        </TR>
        <TR>
        <TD ALIGN="right" valign="top"><B>Email:</B></TD>
        <TD><INPUT TYPE="text" NAME="email" SIZE="30"><p>
    <INPUT TYPE="submit" VALUE="Sign the Guestbook!"></INPUT></TD></TR>
    </TABLE>
    </FORM>&nbsp;<p>

    <blockquote>
    <H3>Thoughts, Comments, and Suggestions on
    <%
    response.write (SiteTitle) & "<br>"
    response.write (MonthName(month(date)) & " " & year(date))
    %>
    </H3>
    <!--#include virtual="
/myanmarsnet/db/zagtest.htm"-->
    </blockquote>
<%
    response.Write (LineAttribute)
Else
    '### CHECK DATE -- IF ANOTHER MONTH, BACKUP FILE
    Dim objFSO, objFSOlog
    Dim objFile, objFileLog

    '### READ DATE LOG
    Set objFSOlog = Server.CreateObject("Scripting.FileSystemObject")
    Set objFileLog = objFSOlog.OpenTextFile(strLog, 1)         '### OPEN GUESTBOOK.LOG
    bDay = objFileLog.ReadAll
    bDay = Trim(bDay)
    objFileLog.Close

    '### IF A MONTH ENDED
    If Day(Date) < cByte(bDay) then
        If Month(Date) = 1 then
         strBakFile = Server.MapPath("" + Trim(CStr(year(date)-1)) +"-"+ "12.htm")
        else
         strBakFile = Server.MapPath("" + Trim(CStr(year(date))) +"-"+ Trim(CStr(month(date)-1)) + ".htm")
        End if
        response.write (strBakFile & "<br>")
        '### DO BACK UP
        '### READ OLD GUESTBOOK
        Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
        Set objFile = objFSO.OpenTextFile(strFile, 1)         '### OPEN zagtest.htm
        strDump = objFile.ReadAll
        objFile.Close
        Set objFile = Nothing
        Set objFSO = Nothing
        '### WRITE TO BAK FILE
        Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
        Set objFile = objFSO.CreateTextFile(strBakFile, true)
        objFile.write ("<html><body bgcolor='#FFFFFF' link='#FF0000'>")
        objFile.write ("<h3>Guestbook of Year "+ Trim(CStr(year(date))) +", Month "+ Trim(CStr(month(date)-1))+"</h3>")
        objFile.write (strDump)
        objFile.write ("</body></html>")
        objFile.Close
        Set objFile = Nothing
        Set objFSO = Nothing
        '### INITIALIZE CURRENT GUESTBOOK
        Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
        Set objFile = objFSO.CreateTextFile(strFile, true)
        objFile.write ("<hr size='1' color='red'>")
        objFile.Close
        Set objFile = Nothing
        Set objFSO = Nothing
        response.write ("Guestbook for the new month initiated...")
    End If


    '### Write the results to file
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile(strFile, 8, True)
    objFile.Write (LineAttribute)
    objFile.Write (TextAttribute)
    objFile.Write Server.HTMLEncode(Request.Form("comment"))
    objFile.Write "</p><p align='right'>"
    objFile.Write Server.HTMLEncode(Request.Form("name"))
    objFile.Write ", <a href='mailto:" & Server.HTMLEncode(Request.Form("email")) & "'>"
    objFile.Write Server.HTMLEncode(Request.Form("email")) & "</a></font><br><font size='1'>"
    objFile.Write now & " - ip address:"
    objFile.Write (request.servervariables("remote_Addr")) & "</font></p>"
    objFile.Close

    '### WRITE DATE LOG
    Set objFileLog = objFSOlog.OpenTextFile(strLog, 2, True)
    objFileLog.Write Day(Date)
    objFileLog.Close
    Set objFile = Nothing
    Set objFSO = Nothing
    Set objFileLog = Nothing
    Set objFSOlog = Nothing
%>

    <H3>Your comments have been written to the file!</H3>
    <A HREF="./zagtest.asp">Back to the guestbook</A><p>
<%
End If
%>

<A HREF="http://winmyanmar.bizhosting.com/zag.htm">Zero Administration Guestbook</a>. ASP code programmed by <A HREF="http://myanmars.net">Steven HTUT</a>.
</body></html>

http://www.myanmars.net, a partner of WinMyanmar Systems

Copyright 1992-2000 by Win Myanmar Systems Inc.
http://winmyanmar.bizhosting.com   All rights reserved.

--

Click Here!