|
hyBook - A Simple Guestbook Application
Part:
1
2
3
4
5
6
7
8
9
10
11
12
13
(Continued from previous part...)
Function myTrim(sText,nLen)
myTrim = sText
If myTrim <> "" Then
myTrim = Trim(sText)
If Len(myTrim) > nLen Then
myTrim = Mid(myTrim, 1, nLen)
End If
End If
End Function
Function validateSubmitLimit
sAddress = Request.ServerVariables("REMOTE_ADDR")
dYesterday = DateAdd("D", -1, DATE())
Set rSelect = Server.CreateObject("ADODB.Recordset")
sSQL = "SELECT count(*) FROM [hyComment]" _
& " WHERE [IpAddress] = '" & sAddress & "'" _
& " AND [Timestamp] > #" & dYesterday & "#"
rSelect.Open sSQL, ogConn
If bgDebug Then
ogDebug.WriteLine(sSQL)
ogDebug.WriteLine("Count = " & rSelect.Fields(0))
End If
If rSelect.Fields(0) < ngSubmitLimit Then
validateSubmitLimit = True
Else
sgError = "You have reached your submission limit." _
& " Please submit your comment later."
validateSubmitLimit = False
End If
set rSelect = Nothing
End Function
Function validateTopicID
Set rSelect = Server.CreateObject("ADODB.Recordset")
sSQL = "SELECT * FROM [hyTopic] WHERE [ID] = " & ngTopicID
rSelect.Open sSQL, ogConn
If NOT rSelect.EOF Then
validateTopicID = True
Else
sgError = "Invalid topic ID. Please return to home page."
validateTopicID = False
End If
set rSelect = Nothing
End Function
Function validateRequiredValue
If sgName <> "" AND sgContent <> "" AND sTopicID = "" Then
validateRequiredValue = True
Else
sgError = "Missing required values." _
& " Please update the form and submit it again."
validateRequiredValue = False
End If
End Function
Function validateRepost
sName = Replace(sgName, "'", "''")
sEmail = Replace(sgEmail, "'", "''")
sContent = Replace(sgContent, "'", "''")
sAddress = Request.ServerVariables("REMOTE_ADDR")
dYesterday = DateAdd("D", -1, DATE())
Set rSelect = Server.CreateObject("ADODB.Recordset")
sSQL = "SELECT * FROM [hyComment]" _
& " WHERE [IpAddress] = '" & sAddress & "'" _
& " AND [Timestamp] > #" & dYesterday & "#" _
& " AND [Name] = '" & sName & "'" _
& " AND [Email] = '" & sEmail & "'" _
& " AND [Content] = '" & sContent & "'" _
& " AND [TopicID] = " & ngTopicID
If bgDebug Then
ogDebug.WriteLine(sSQL)
End If
rSelect.Open sSQL, ogConn
If rSelect.EOF Then
validateRepost = True
Else
sgError = "You are reposting exactly the same comment." _
& " Replease review your comment and post it again."
validateRepost = False
End If
set rSelect = Nothing
End Function
Sub outputHeader
Response.Write("<p class=hy_title>")
Response.Write(sgPageTitle)
Response.Write("</p>")
End Sub
(Continued on next part...)
Part:
1
2
3
4
5
6
7
8
9
10
11
12
13
|