%
'/----------------------------------------------\
'>********** Please choose you colors:**********<
'\----------------------------------------------/
HeadingCellBgColor="#000099"
HeadingCellTextColor="#ffffff"
CellBgColor="#f0f0f0"
CellTextColor="#000000"
%>
My guestbook
<%
'/----------------------------------------------\
'>********* Data selected or requested *********<
'\----------------------------------------------/
Flag = Request.form("Flag")
If Flag = 1 then
Name = Request.form("Name")
Unit = Request.form("Unit")
Email = Request.form("Email")
Url = Request.form("Url")
Comment = Request.form("Comment")
Comment = server.HTMLencode(Comment) 'Do not allow HTML
Comment = Left(Comment, 1000) 'truncate the really long ones
Comment = Replace(Comment,VbCrlf,"
")
'************************************************
'/----------------------------------------------\
'>*************** Validation *******************<
'\----------------------------------------------/
errmsg=""
errComment=""
If Replace(Name," ","") = "" then errmsg = errmsg & "- Name is missing
"
If Replace(Email," ","") = "" then
errmsg = errmsg & "- Email is missing
"
ElseIf InStr(Email,"@")=0 then
errmsg = errmsg & "- Email is invalid
" 'all emails contain an at sign eg. you@you.com
ElseIf InStr(Email,".")=0 then
errmsg = errmsg & "- Email is invalid
" ' all emails contain a dot eg. you@you.com
End If
If (InStr(Name," ")=0) then errmsg = errmsg & "- Name is invalid
"
'Url is not required
If Replace(Comment," ","") = "" then errmsg = errmsg & "- Comment is missing
"
errmsg = errmsg & "
"
If NOT errmsg = "" then
%>
Following errors were detected:
<%= errmsg %>
Please click the back button on your browser, or click here and fix these errors.
<%
Response.end
End If
'************************************************
'/----------------------------------------------\
'>********** The new record is created *********<
'\----------------------------------------------/
'Comment next line out if you want the new record to appear as the last record in the guestbook
Newrecord = ""
Newrecord = Newrecord & "" & VbCrlf
Newrecord = Newrecord & "" & VbCrlf
Newrecord = Newrecord & "" & VbCrlf
Newrecord = Newrecord & "| Date: | " & now & " |
" & VbCrlf
Newrecord = Newrecord & "| Name: | " & Name & " |
" & VbCrlf
Newrecord = Newrecord & "| Unit: | " & Unit & " |
" & VbCrlf
Newrecord = Newrecord & "| Email: | " & Email & " |
" & VbCrlf
If NOT Url = "" then
Newrecord = Newrecord & "| Own Url: | " & Url & " |
" & VbCrlf
End If
Newrecord = Newrecord & "| Comments: |
" & VbCrlf
Newrecord = Newrecord & "| " & Comment & " |
" & VbCrlf
Newrecord = Newrecord & "
" & VbCrlf & VbCrlf
If Instr(Newrecord,"") = 0 then
Newrecord = Newrecord & ""
End If
'Do not save record if comment contains href, http
'Do not save record if name does not contain a blank (we want two names)
If ((InStr(Comment,"href")=0) AND (InStr(Comment,"=")=0) AND (InStr(Comment,"http")=0) AND (InStr(Name," ")>0)) then
errComment="false"
Else errComment="true"
End If
If ((Request.ServerVariables("Remote_Addr")="121.140.62.153") OR (Request.ServerVariables("Remote_Addr")="188.72.225.49") OR (Request.ServerVariables("Remote_Addr")="218.6.2.230")) then
errComment="true"
End If
'************************************************
'/----------------------------------------------\
'>********** Edit data.txt *********************<
'\----------------------------------------------/
fn = server.mappath("data.txt") 'Find data.txt on server
fn2 = server.mappath("data2.txt") 'Backup data file
Set fs = CreateObject("Scripting.FileSystemObject") 'Create the FileSystem object
Set htmlfile = fs.OpenTextFile(fn, 1, 0, 0) 'Open data.txt
code = htmlfile.ReadAll 'Read contents of file
htmlfile.close 'Close data.txt
set htmlfile = nothing
If NOT (errComment="true") then
code = Replace(Code,"",Newrecord) 'Add the new record
End If
Set htmlfile = fs.CreateTextFile(fn) 'ReCreate data.txt
htmlfile.write code 'Write contents
htmlfile.close 'Close data.txt
set htmlfile = nothing
Set htmlfile = fs.CreateTextFile(fn2) 'ReCreate data.txt
htmlfile.write code 'Write contents
htmlfile.close 'Close data.txt
set htmlfile = nothing
set fs = nothing 'Close FileSystem object
' *****************************************
%>
Thank you for signing the PML Voice Guestbook
PML Voice Home
<%
Else
%>
Sign the PML Voice Guestbook
<%
End If
%>