%
' *******************************************************************
' * This is the ASP guestbook. *
' * You can modify this file as you like and you *
' * can also rename it. It will still work. *
' * *
' * You can edit all colors with the following script: *
' * *
' * Variable Explanation *
' * --------------------------------------------------------------- *
' ************************ *
BodyBgcolor = "#11560C" '* Body background color *
LinkColor = "#000099" '* Link color *
ALinkColor = "#99ccff" '* Active link color *
VLinkColor = "#000099" '* Visited link color *
TextColor = "#000000" '* Default text color *
HoverColor = "#99ccff" '* Default hover color (Mouse over link) *
TopcellBg = "#F5F5F5" '* Heading row background color in tables *
TopcellText = "#11560C" '* Heading row text color in tables *
CellBg = "#ffffff" '* Table background color *
CellText = "#000000" '* Table Text color *
' ************************ *
' * Other things to edit *
' * *
' * Variable Explanation *
' * --------------------------------------------------------------- *
' **************************************** *
Font = "Arial" '* The default font *
DataBaseName = "gb.mdb" '* Database + virtual path *
' **************************************** *
' *******************************************************************
session("fn") = "f17.shtml"
' -----------------------------------------
' Begin Inputting external data
' -----------------------------------------
' <<<< Querystring >>>>
Mode = Request.QueryString("Mode") 'Sign (or View)
Page = Request.QueryString("Page") 'In View mode
ShowTheCode = "yes"
If IsEmpty(Request.QueryString("Page")) then Page = 1
' <<<< Form >>>>
Flag = Request.Form("Flag")
If mode = "Sign" then
Name = Request.Form("Name")
Email = Request.Form("Email")
Place = Request.Form("Place")
Url = Request.Form("Url")
Comment = Request.Form("Comment")
End If
' <<<< Server >>>>
NameOfFile = Request.ServerVariables("Script_Name")
' -----------------------------------------
' End Inputting external data
' -----------------------------------------
' *********************************************************************
' * Sub list: *
' *********************************************************************
' * Header * The
etc. tags *
' * Footer * The etc. tags *
' * Signpage * The tags for the sign/Addentry page *
' * Validate * Validate the signpage *
' * InsertInfo * Insert info to database *
' * Viewpage * View entries *
' *********************************************************************
' * Database: gb.mdb Table: gb Primary key: Id *
' *********************************************************************
' |Id |Date |Name |Email |Place |Url |Comment
' |Autonum |Date/Time |Text-30 |Text-30 |Text-50 |Text-50 |Memo
' *********************************************************************
' -------------------------------------------
' Begin Subs and functions
' -------------------------------------------
'<<<<<<<<<<<<>>>>>>>>>>>>
Sub Header 'Header Sub
%>
':. Baldisserotto .:'
<%
Response.End
End Sub
'<<<<<<<<<<<<>>>>>>>>>>>>
Sub SignPage 'The page where Guests can input their Information
%>
<%
End Sub
'<<<<<<<<<<<<>>>>>>>>>>>>
Function Validate
Dim ErrorMsg
ErrorMsg = "
"
If Name = "" Then
ErrorMsg = ErrorMsg & "
Missing name
"
End if
If Email = "" Then
ErrorMsg = ErrorMsg & "
"
End if
If Comment = "" Then
ErrorMsg = ErrorMsg & "
Missing comment
"
ElseIf InStr(Comment, ">") <> 0 or InStr(Comment, "<") <> 0 Then
ErrorMsg = ErrorMsg & "
Do not use < or >
"
End if
ErrorMsg = ErrorMsg & "
"
If Not ErrorMsg = "
" then
Response.write ""
Response.write "Following errrors were detected "
Response.write ""
Response.write ErrorMsg
Response.write "
"
Validate = False
Else
Validate = True
End if
End Function
'<<<<<<<<<<<<>>>>>>>>>>>>
Sub InsertInfo
Comment = Replace(Comment,VbCrlf," ")
Comment = Replace(Comment,Chr(34),""")
set conn = server.createobject("adodb.connection")
'DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; "
'DSNtemp=dsntemp & "DBQ=" & server.mappath(DataBaseName)
conn.Open "dsn=GB"
sqlstmt = "Insert into gb (Name,Email,Place,Url,Comment)"
sqlstmt = sqlstmt & " Values("
sqlstmt = sqlstmt & "'" & Name & "',"
sqlstmt = sqlstmt & "'" & Email & "',"
sqlstmt = sqlstmt & "'" & Place & "',"
sqlstmt = sqlstmt & "'" & Url & "',"
sqlstmt = sqlstmt & "'" & Comment & "'"
sqlstmt = sqlstmt & ")"
conn.execute(sqlstmt)
conn.close
set conn = nothing
End Sub
'<<<<<<<<<<<<>>>>>>>>>>>>
Sub ViewPage
set conn = server.createobject("adodb.connection")
'DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; "
'DSNtemp=dsntemp & "DBQ=" & server.mappath(DataBaseName)
conn.Open "DSN=gb"
sqlstmt = "SELECT * from Gb ORDER BY date DESC"
'set rs = conn.execute(sqlstmt)
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sqlstmt, conn, 3, 3
If rs.EOF then
Response.write "No records in guestbook"
Else
TotalRecords = rs.recordcount
rs.Pagesize=10
TotalPages = cInt(rs.pagecount)
rs.absolutepage=Page
%>
There are <%= TotalRecords %> entries in <%= TotalPages %> pages.
<%
For CountRecords = 1 to 10
If rs.EOF then Exit for
Daten = rs("Date")
Name = rs("Name")
Email = rs("Email")
Place = rs("Place")
Url = rs("Url")
If Url<>"" and InStr(Url,"http://")=0 then Url="http://"&Url
Comment = rs("Comment")
%>
<%
rs.movenext
Next 'CountRecords
If Page > 1 Then
%>
<<<
<%
End If
If NOT rs.EOF then
%>
>>>
<%
End If
End If
conn.close
set conn = nothing
End Sub
' -----------------------------------------
' End Subs and Functions
' -----------------------------------------
' Begin Main
' -----------------------------------------
If Mode = "Sign" then
'Sign mode
If Flag = "" then
'If form has not been submitted, no flag is regongnised
WhatToDo = "Sign Guestbook"
Header
SignPage
Footer
End If
If Flag = 1 then
'If form has been submitted, flag will be set to 1
WhatToDo = "Sign Guestbook"
Header
If Not Validate then
'The "Validate" function writes Error message
Signpage
Else
InsertInfo
Response.write ""
Response.write "Your entry has successfully been added.
"
Response.write "View guestbook "
Response.write ""
Footer
End If
Footer
End If
Else
'View mode
WhatToDo = "View Guestbook"
Header
Viewpage
Footer
End If
' -----------------------------------------
' End Main
' -----------------------------------------
%>