Blocking members from sending e-mail

Snitz™ Forums 2000
https://forum.snitz.com/forumTopic/Posts/64879?pagenum=1
05 November 2025, 07:04

Topic


matko
Blocking members from sending e-mail
31 May 2007, 06:38


<font size="1"><b>Credits:</b>This MOD is based on idea of ruirib in Small mod: Blocking forum email spam</font id="size1">

<b>Version 1.0
Snitz forum version 3.4.06</b>

This mod will prevent members to send an e-mail to other members until they reach certain number of posts or until admin allows them to do so. Usefull to block e-mail spammers while allowing admin to overide this for users he knows or recommended users. Override can be set in User profile. It will also send a message to the forum admin, notifying him of the spam attempt, so that the member can be blocked.
<b>Difficulty:</b> easy to implement

<font color="blue">1. In admin section go to Alternative mod setup and run this code:</font id="blue">
Code:

[ALTER]
MEMBERS
ADD#M_ALLOWEMAIL#SMALLINT##0
[END]
[UPDATE] MEMBERS
M_ALLOWEMAIL#1#
[END]
[ALTER] MEMBERS_PENDING
ADD#M_ALLOWEMAIL#SMALLINT##0
[END]
[UPDATE] MEMBERS_PENDING
M_ALLOWEMAIL#1#
[END]

<font color="blue">2. in unmodified <b>pop_mail.asp</b> find this code (at around line 45):</font id="blue">
Code:

if Request.QueryString("ID") <> "" and IsNumeric(Request.QueryString("ID")) = True then
intMemberID = cLng(Request.QueryString("ID"))
else
intMemberID = 0
end if[/code]
<font color="blue">and right <b>BELOW</b> it add this:</font id="blue">

Code:

'##################### e-mail anti-spam MOD #######################
strSql = "SELECT M_NAME, M_POSTS, M_ALLOWEMAIL FROM " & strMemberTablePrefix & "MEMBERS M"
strSql = strSql & " WHERE M.MEMBER_ID = " & MemberID

set rs = my_Conn.Execute (strSql)

If Not rs.EOF then
intMPosts = rs("M_POSTS")
intAllowEmail = rs("M_ALLOWEMAIL")

if intMPosts < <font color="red">10</font id="red"> and intAllowEmail="0" then
Err_Msg = "<li>You can't send e-mail yet.</li>"
strSpammerName = RS("M_NAME")

'Send email to forum admin
strRecipients = strSender
strFrom = strSender
strFromName = "Automatic Server Email"
strSubject = "Possible Spam Poster"
strMessage = "There is a possible spam poster at " & strForumTitle & vbNewLine & vbNewLine
strMessage = strMessage & "Member " & strSpammerName & ", with MemberID " & MemberID & ", has been trying to send emails to " & Request.Form("Name") & ", without having enough posts to be allowed to do it." & vbNewLine & vbNewLine
strMessage = strMessage & "Here are the message contents: " & VbNewLine & Request.Form("Msg") & vbNewLine & vbNewLine & vbNewLine & vbNewLine
strMessage = strMessage & "This is a message sent automatically by the Spam Control Mod ;)."

%>
<!--#INCLUDE FILE="inc_mail.asp" -->
<%


end If

End if

rs.Close
end if
'############# End of email anti-spam mod #############

<font size="1">In red is number of posts member has to reach before allowed to send e-mail. Next version of this mod (if there is interest from people) can allow to set this value via admin menu, currently it has to be set in the code.</font id="size1">

<font color="blue">3. in <b>pop_mail.asp </b> look for this code (around line 102)</font id="blue">
[code] if Request.QueryString("mode") = "DoIt" then
Err_Msg = ""

<font color="blue">and comment Err_Msg= "" so it looks like this:</font id="blue">
Code:
if Request.QueryString("mode") = "DoIt" then
<font color="green">'</font id="green">Err_Msg = ""

<font color="blue">4. In unmodified <b>pop_profile.asp</b> look for this code (around 969)</font id="blue">
Code:

strsql = strsql & ", " & strMemberTablePrefix & "MEMBERS.M_QUOTE"
strsql = strsql & ", " & strMemberTablePrefix & "MEMBERS.M_BIO"
strSql = strSql & ", " & strMemberTablePrefix & "MEMBERS.M_SIG"

<font color="blue">and right <b>BELOW</b> these lines add this code</font id="blue">

Code:
strSql = strSql & ", " & strMemberTablePrefix & "MEMBERS.M_ALLOWEMAIL"

<font color="blue">So it looks like this</font id="blue">
Code:

strsql = strsql & ", " & strMemberTablePrefix & "MEMBERS.M_BIO"
strSql = strSql & ", " & strMemberTablePrefix & "MEMBERS.M_SIG"
<font color="green">strSql = strSql & ", " & strMemberTablePrefix & "MEMBERS.M_ALLOWEMAIL"</font id="green">
strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS"

<font color="blue">5. In the same <b>pop_profile.asp</b> look for this (around 1586):</font id="blue">
Code:
if strBio = "1" then
strSql = strSql & ", M_BIO = '" & chkString(Request.Form("Bio"),"message") & "'"
end if

<font color="blue">and right BELOW these lines add this:</font id="blue">

Code:
strSQL = strSql & ", M_ALLOWEMAIL = " & cLng(Request.Form("allowemail"))

<font color="blue">so it looks like this</font id="blue">

Code:
if strBio = "1" then
strSql = strSql & ", M_BIO = '" & chkString(Request.Form("Bio"),"message") & "'"
end if
<font color="green">strSQL = strSql & ", M_ALLOWEMAIL = " & cLng(Request.Form("allowemail"))</font id="green">
strSql = strSql & " WHERE MEMBER_ID = " & cLng(Request.Form("MEMBER_ID"))

my_Conn.Execute(strSql),,adCmdText + adExecuteNoRecords

<font color="blue">6. in <b>inc_profile.asp</b> look for this code (around 532)</font id="blue">

Code:

     if rs("M_LEVEL") = 3 then Response.Write(" selected")
Response.Write ">Administrator</option>" & vbNewLine & _
" </select>" & vbNewLine
end if
Response.Write " </td>" & vbNewLine & _
" </tr>" & vbNewLine

<font color="blue">and right BELOW this add this code</font id="blue">

Code:

response.write "                    <tr>" & vbNewLine & _
" <td bgColor=""" & strPopUpTableColor & """ align=""right"" valign=""middle"" nowrap><b><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """>User allowed to send<br />e-mail before limit of <br />posts is reached? </font></b></td>" & vbNewLine & _
" <td bgColor=""" & strPopUpTableColor & """ valign=""bottom"">" & vbNewLine
response.write " <select name=""allowemail"">" & vbNewLine & _
" <option value=""1"""
if rs("M_ALLOWEMAIL")="1" then Response.Write(" selected")
Response.Write ">Yes</option>" & vbNewLine & _
" <option value=""0"""
if rs("M_ALLOWEMAIL")="0" then Response.Write(" selected")
Response.Write ">No</option>" & vbNewLine & _
" </select>" & vbNewLine
Response.Write " </td>" & vbNewLine & _
" </tr>" & vbNewLine

<font color="blue">so it looks like this</font id="blue">

Code:

        if rs("M_LEVEL") = 3 then Response.Write(" selected")
Response.Write ">Administrator</option>" & vbNewLine & _
" </select>" & vbNewLine
end if
Response.Write " </td>" & vbNewLine & _
" </tr>" & vbNewLine
<font color="green"> response.write " <tr>" & vbNewLine & _
" <td bgColor=""" & strPopUpTableColor & """ align=""right"" valign=""middle"" nowrap><b><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """>User allowed to send<br />e-mail before limit of <br />posts is reached? </font></b></td>" & vbNewLine & _
" <td bgColor=""" & strPopUpTableColor & """ valign=""bottom"">" & vbNewLine
response.write " <select name=""allowemail"">" & vbNewLine & _
" <option value=""1"""
if rs("M_ALLOWEMAIL")="1" then Response.Write(" selected")
Response.Write ">Yes</option>" & vbNewLine & _
" <option value=""0"""
if rs("M_ALLOWEMAIL")="0" then Response.Write(" selected")
Response.Write ">No</option>" & vbNewLine & _
" </select>" & vbNewLine
Response.Write " </td>" & vbNewLine & _
" </tr>" & vbNewLine</font id="green">

end if
if not(strUseExtendedProfile) then


And that's it. I hope you'll find it usefull, if you have any suggestions how to improve this, please let me know.

 

Replies ...


AnonJr
31 May 2007, 08:23


Cool. Its a neat addition. The only change I'd make is put your code in [scrollcode] tags so it doesn't stretch the page. wink<
matko
31 May 2007, 13:17


AntonJr: I didn't know such a tag exists blush

I put widest part of code in scrollcode now, so the page is not stretching anymore.<
AnonJr
31 May 2007, 15:20


Its one of those little hidden gems that is set up just here. smile The code for adding it (or something like it) is floating around here if you want to add it to your forum.<
dcohn
02 July 2007, 02:27


Matko

Does everyone default to yes they can send without reaching and can that be changed to NO as the default so it is more like RUI's code without your added options. Otherwise I must go into every user with a yes and under the amount and change to no.

Where you write

2. in unmodified pop_mail.asp find this code (at around line 45):

I assume you mean you find the first few lines and then add the balance of the contents, correct?
Sorry for being so anal.
THANK YOU for what I have been looking for. I have a serious problem on a Feline health forum where crazies attack new users with lies etc.

I was also wondering whether these users that cannot email CAN email the ADMIN or does that defeat the purpose when it is used to prevent spammers?
IE In my case I need to just control people from their own bad behavior as well as protect against the more common spammer issue.
Thanks again as this is a great addition as it is for us non coder types.
Doug<
TastyNutz
29 July 2007, 14:24


I've added this mod and it successfully blocks email from members without enough posts. But the Admin override isn't working. I select "Yes" from the menu and click 'Submit' but the database doesn't update. When I check the profile again, the menu option has reverted back to "No."

Any ideas what I missed?<
TastyNutz
29 July 2007, 20:41


Oops. Missed a line of code.
Works great now!<
BroIgnatius
05 October 2007, 21:33


I am getting this error message when someone tries to register:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Microsoft Access Driver] The field 'FORUM_MEMBERS_PENDING.M_ALLOWEMAIL' cannot contain a Null value because the Required property for this field is set to True. Enter a value in this field.

/bbs/register.asp, line 730


line 730 is:
my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords


Any help appreciated.

<
© 2000-2021 Snitz™ Communications