<% Option Explicit %> <% Dim databaseType Dim databaseName Dim databaseUser Dim databasePassword Dim sortOrder Dim sendMail Dim mailFrom Dim mailTo Dim mailSubject '********************************************* 'Database information and other options databaseType = "Microsoft Access Driver (*.mdb)" databaseName = "comments.mdb" databaseUser = "Admin" databasePassword = "" ' select the sort order in which to display comments sortOrder = "descending" ' or "ascending" ' set to true if you want to receive an email for each new comment sendMail = true ' or false ' enter the subject for the email here mailSubject = "[aspcomments]: New comment from " '********************************************* '********************************************* '* NOTE: CHANGE THE EMAIL ADDRESSES WITHIN * '* THIS BLOCK BEFORE USE! * '********************************************* ' enter your email address here mailFrom = "aspcomments@sneaker.org" ' enter your email adddress here mailTo = "aspcomments@sneaker.org" '********************************************* 'Get the full path to the db Dim databasePath databasePath = server.mappath(databaseName) 'Connect to DB Server Dim dbConnectString dbConnectString = "DRIVER={" & databaseType &_ "};DBQ=" & databasePath 'Set up the database connection Dim dbConnection Set dbConnection = Server.CreateObject("ADODB.Connection") dbConnection.ConnectionTimeout = 60 dbConnection.CommandTimeout = 15 dbConnection.Open dbConnectString Dim blogid ' Get the blogid blogid = Request("blogid") 'If there is no blog id print missing message If blogid = "" Then %> Missing blogid. <% Else 'Check if the blogid is numbers only Dim digitsOnly Set digitsOnly = New RegExp digitsOnly.pattern = "^\d+$" 'If it is not only digits then print invalid message If NOT digitsOnly.Test(blogid) Then %> Invalid blogid. <% Else Dim rsComments, sqlComments Set rsComments = Server.CreateObject("ADODB.RecordSet") Dim name, email, url, comment, entered 'Check if this is a form submission If Request("add") <> "" And Request("name") <> "" And Request("comment") <> "" Then 'Get a timestamp Dim timestamp timestamp = Now 'Get the request parameters name = Request("name") email = Request("email") url = Request("url") comment = Request("comment") 'Check if there is a "://" in the url Dim isURL Set isURL = New RegExp isURL.pattern = "://+" If NOT isURL.Test(url) Then url = "http://" & url End If 'Check if the user wants to set a cookie If Request("remember") <> "" Then Response.Cookies("aspcomments")("name") = name Response.Cookies("aspcomments")("email") = email Response.Cookies("aspcomments")("url") = url Response.Cookies("aspcomments").Expires = DateAdd("m", 6, timestamp) Else Response.Cookies("aspcomments") = "" End If sqlComments = "INSERT INTO comments (blogid, name, email, url, comment, entered) VALUES (" & blogid & ",'" & escape(name) & "','" & escape(email) & "','" & escape(url) & "','" & escape(comment) & "',#" & timestamp & "#)" dbConnection.Execute sqlComments 'Check if the the setting is to send email 'and if so then use CDONTS to send the mail ' If sendMail Then ' Dim mail, mailBody ' Set mail = Server.CreateObject("CDONTS.NewMail") ' mailSubject = mailSubject & Request("name") & " (" &_ ' Request("email") & ")" ' mailBody = Request("name") & "(" & Request("email") & ")" &_ ' CHR(13) & Request("url") & CHR(13) &_ ' Request("comment") & CHR(13) &_ ' timestamp & CHR(13) ' ' mail.From = mailFrom ' mail.To = mailTo ' mail.Subject = mailSubject ' mail.Body = mailBody ' mail.Importance = 1 ' mail.Send ' ' Set mail = Nothing ' End If End If If sortOrder = "descending" Then sqlComments = "SELECT * FROM comments WHERE blogid=" & blogid & " ORDER BY entered DESC" Else sqlComments = "SELECT * FROM comments WHERE blogid=" & blogid End If rsComments.Open sqlComments, dbConnection, 3 If Request("count") = "1" Then Dim count count = rsComments.RecordCount if count <= 0 Then Response.write("document.write('');") 'Response.write("document.write('0');") Else Response.write("document.write('" & count & "');") End If Else %> Há Controvérsias [Comentários] <% do until rsComments.EOF name = unescape(rsComments("name"), "plain") email = unescape(rsComments("email"), "plain") url = unescape(rsComments("url"), "plain") comment = unescape(rsComments("comment"), "plain") entered = rsComments("entered") %>
<%=name%> (<%=email%>)
<%=url%>

<%=comment%>
<%=entered%>
<% rsComments.moveNext loop %>
">
nome: " SIZE="38">
email: " SIZE="38">
site: " SIZE="38">
comentário:
  
<% End If End If End If %>