The Forum has been Updated
The code has been upgraded to the latest .NET core version. Please check instructions in the Community Announcements about migrating your account.
This is my first post, so be gentle!!
A little background first:
On one of the forums that I help administrate it appears that topics are being deleted for no particular reason. Users began to complain (and I don't blame them) that they would post a thread and it would be gone the next day. One of the administrators of the forum has a personal agenda with some of the users, so I wanted to find a way to send an email to myself every time a topic was deleted that contains some basic information about who was doing the deleting. I looked all over the support forums here and wasn't able to find anything that could really help me out, so I decided to write the code myself. This code could easily be re-used in other areas of the forum for different purposes. I've pasted the code below.
There are a couple of things I took into consideration when I wrote this. First off, this is just "quick and dirty" code. It does the job, it's not pretty and it's not meant to stay in there forever, I just needed something to work for a short time. Secondly, you'll want to consider how many topics are being deleted on your forums as you could easily get a ton of emails in a short time. We don't have that many deleted topics, so it's not a problem for me.
Now for the code:
The code should be pasted into the pop_delete.asp file. As always, make sure you make a backup of the original file before pasting this code in. On our setup, this code starts out on line 267 of the pop_delete.asp file, right after the line "set rs = nothing". Our forum is setup with an Access database and we're running Snitz version 3.4.03.
'#####Test code to send name of member who deleted topic to administrator#####
'#####Get user and topic information, then compose email and send it#####
set rs = Server.CreateObject("ADODB.Recordset")
strSql = "SELECT T.TOPIC_ID, T.T_SUBJECT, T.T_AUTHOR, M.M_NAME "
strSql = strSql & "FROM " & strActivePrefix & "TOPICS T, " & strMemberTablePrefix & "MEMBERS M "
strSql = strSql & "WHERE T.TOPIC_ID = " & cLng(delAr(i)) & " AND M.MEMBER_ID = T.T_AUTHOR"
rs.Open strSql, my_Conn
'##Get the subject and author of the topic being deleted
T_Subject = rs("T_SUBJECT")
T_Author = rs("M_NAME")
rs.close
set rs = nothing
'##Get member information for the member trying to delete the post##
set rs = Server.CreateObject("ADODB.Recordset")
strSql = "SELECT MEMBER_ID, M_LAST_IP "
strSql = strSql & "FROM " & strMemberTablePrefix & "MEMBERS "
strSql = strSql & "WHERE M_NAME = '" & strDBNTFUserName & "'"
rs.Open strSql, my_Conn
Memb_IP = rs("M_LAST_IP")
rs.close
set rs = nothing
strBody = "The topic '" & T_Subject & "' created by " & T_Author & " has been deleted from the forums. "
strBody = strBody & "The member who deleted the topic is " & strDBNTFUserName & " with an IP address of "
strBody = strBody & Memb_IP & "."
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Topic Deleted"
myMail.From="admin@yourdomain.com" 'change this
myMail.To="someone@somewhere.com" 'your email address
myMail.TextBody=strBody
myMail.Send
set myMail=nothing<
A little background first:
On one of the forums that I help administrate it appears that topics are being deleted for no particular reason. Users began to complain (and I don't blame them) that they would post a thread and it would be gone the next day. One of the administrators of the forum has a personal agenda with some of the users, so I wanted to find a way to send an email to myself every time a topic was deleted that contains some basic information about who was doing the deleting. I looked all over the support forums here and wasn't able to find anything that could really help me out, so I decided to write the code myself. This code could easily be re-used in other areas of the forum for different purposes. I've pasted the code below.
There are a couple of things I took into consideration when I wrote this. First off, this is just "quick and dirty" code. It does the job, it's not pretty and it's not meant to stay in there forever, I just needed something to work for a short time. Secondly, you'll want to consider how many topics are being deleted on your forums as you could easily get a ton of emails in a short time. We don't have that many deleted topics, so it's not a problem for me.
Now for the code:
The code should be pasted into the pop_delete.asp file. As always, make sure you make a backup of the original file before pasting this code in. On our setup, this code starts out on line 267 of the pop_delete.asp file, right after the line "set rs = nothing". Our forum is setup with an Access database and we're running Snitz version 3.4.03.
'#####Test code to send name of member who deleted topic to administrator#####
'#####Get user and topic information, then compose email and send it#####
set rs = Server.CreateObject("ADODB.Recordset")
strSql = "SELECT T.TOPIC_ID, T.T_SUBJECT, T.T_AUTHOR, M.M_NAME "
strSql = strSql & "FROM " & strActivePrefix & "TOPICS T, " & strMemberTablePrefix & "MEMBERS M "
strSql = strSql & "WHERE T.TOPIC_ID = " & cLng(delAr(i)) & " AND M.MEMBER_ID = T.T_AUTHOR"
rs.Open strSql, my_Conn
'##Get the subject and author of the topic being deleted
T_Subject = rs("T_SUBJECT")
T_Author = rs("M_NAME")
rs.close
set rs = nothing
'##Get member information for the member trying to delete the post##
set rs = Server.CreateObject("ADODB.Recordset")
strSql = "SELECT MEMBER_ID, M_LAST_IP "
strSql = strSql & "FROM " & strMemberTablePrefix & "MEMBERS "
strSql = strSql & "WHERE M_NAME = '" & strDBNTFUserName & "'"
rs.Open strSql, my_Conn
Memb_IP = rs("M_LAST_IP")
rs.close
set rs = nothing
strBody = "The topic '" & T_Subject & "' created by " & T_Author & " has been deleted from the forums. "
strBody = strBody & "The member who deleted the topic is " & strDBNTFUserName & " with an IP address of "
strBody = strBody & Memb_IP & "."
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Topic Deleted"
myMail.From="admin@yourdomain.com" 'change this
myMail.To="someone@somewhere.com" 'your email address
myMail.TextBody=strBody
myMail.Send
set myMail=nothing<