Citron Bleu - Gastenboek
<%
LoggedIn = Session("loginID")
ID = Trim(Request.queryString("ID"))
'============Empty Deleted Items from the database============
If LoggedIn <> "" Then
if request.querystring("del") = 1 then
Set dConn = Server.CreateObject("ADODB.Connection")
dConn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & database_path
mySQL = "DELETE FROM tblpost where active = 2;"
dConn.execute(mySQL)
dconn.close
set dconn = nothing
response.redirect("gastenboek.asp")
end if
end if
'============set based on delete or undelete============
If LoggedIn <> "" Then
showdeleted = request.querystring("showdeleted")
if showdeleted = 1 then
active = 2
removetype = 1
delete_text = undelete_text
delimage = "undelete.gif"
else
active = 1
removetype = 2
delete_text = delete_text
delimage = "delete.gif"
end if
else
active = 1
end if
'============Delete/Undelete Items from the guestbook display============
remove = request.querystring("remove")
if remove = 1 then
Set dConn = Server.CreateObject("ADODB.Connection")
dConn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & database_path
removetype = request.querystring("removetype")
mySQL = "UPDATE tblPost SET Active = " & removetype & " WHERE ID = " & ID & ";"
response.write "updating"
dConn.execute(mySQL)
dConn.Close
set dConn = Nothing
response.redirect("gastenboek.asp")
end if
'============End Delete Section============
Set dataRS = Server.CreateObject("ADODB.RecordSet")
dataSQL = "Select TOP " & show_posts & " message, remote_addr, sysdate, systime, id, email FROM tblPost WHERE active = " & active & " order by sysdate DESC, systime DESC;"
'Response.Write dataSQL
'response.end
Set dConn = Server.CreateObject("ADODB.Connection")
dConn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & database_path
dataRS.Open dataSQL, dConn, 1, 3
recordcount = dataRS.recordcount
if recordcount > 0 then
data = dataRS.GetRows()
'Data is retrieved so close all connections
dataRS.Close
Set dataRS = Nothing
dconn.close
set dconn = nothing
'Setup for array usage
iRecFirst = LBound(data, 2)
iRecLast = UBound(data, 2)
end if
'============IF IS A POST BACK============
vnumber = request.form("vnumber")
message = trim(request.form("message"))
email = trim(request.form("email"))
if request.form("ispostback") = 1 AND (len(message) > minimum_length) then
if allow_html = "no" then
message = RemoveHTMLtags(message)
else
message = PreSubmit2(message)
end if
strSQL = "tblPost"
'Open a recordset
Set cRS2 = Server.CreateObject("ADODB.recordset")
Set dConn = Server.CreateObject("ADODB.Connection")
dConn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & database_path
cRS2.Open strSQL, dConn, 1,3
cRS2.AddNew
cRS2("message") = message
cRS2("sysdate") = date()
cRS2("systime") = time()
cRS2("remote_addr") = request.ServerVariables("remote_addr")
cRS2("Active") = 1
cRS2("email") = email
cRS2.Update
cRS2.Close
Set cRS2 = Nothing
dConn.Close
Set dConn = Nothing
response.redirect("gastenboek.asp")
end if
'============End POSTBACK Section============
RandomNumber1 = Day(date())
RandomNumber2 = Month(date())
%>
<%
if recordcount > 0 then
%>
<%= message_text %>
<%
If LoggedIn <> "" then
%>
<%= delete_text %>
<% end if %>
<%
' Loop through the records (second dimension of the array)
For I = iRecFirst To iRecLast
Response.Write "
<%
end if
If LoggedIn <> "" Then
response.write logoutlink
else
response.write loginlink
end if
'close db just in case
on error resume next
dConn.Close
Set dConn = Nothing
on error goto 0
%>