PDA

View Full Version : Private Messages Enhancements - Limit PMs Sent Per-Day


Sim9
05-25-2007, 10:00 PM
Description:
Very simple modification to limit the number of private messages sent per day. Useful to significantly limit damage spambots can do whilest not annoying users.

Installation:
Download product XML (attached).
Optional: Edit the XML to change the configuration variables section to your liking (sorry, no fancy frontend to the tweaks :))
Upload the product XML: In your AdminCP: Plugins & Products >> Manage Products >> [Add/Import Product] >> Upload.
Optional: Edit the phrase 'archivepm_limitexceed' if you want to change it from its default.
Test private messaging and limits.More information on configuration variables:
These are the configuration variables you're interested in:$arc_limit = 5; // How many PMs in a time period
$arc_timeperiod_secs = 60 * 60 * 24; // How long (One Day)
$arc_exempt_postcount = 50; // How many forum posts until user is considered exempt from this
This configuration reads as "Limit users who have less than 50 posts to making no more than 5 PMs within 24 hours." Tweak to your liking. :)

Version 1.1 Released (2/25/08):
I've released a small change which correctly handles automated welcome PMs. Special thanks to Adwade for testing & the donation :D

Boring Legal Disclaimer:

THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

FreshFroot
05-26-2007, 04:15 AM
this will be usefull!

Thanks!

dope15gd
05-26-2007, 04:25 PM
working beautifully on version 3.6.7

thanks

projectego
05-26-2007, 06:15 PM
Great idea.

/me clicks install

Paul M
05-27-2007, 11:42 AM
It would be better to have the parameters as vb options, not have to edit the plugin. :)

Konstantinos
05-27-2007, 11:45 AM
is it per usergroup ?

Sim9
05-27-2007, 06:30 PM
Thanks guys! :)

Paul: Definitely, but it's a simple seven-line addon. The code for the options screen would eclipse the code doing actual work :P

Konstantinos: Unfortunately, no. This applies globally to all users. On my site, staff members all have way above 50 posts each, so it was a non-issue during development :)

gforce75
05-28-2007, 01:03 AM
Spambots send PM's? Wow, well anyways, I'll keep this script in mind if I see such an issue. Probably good for heavy resourced forum sites.

Sim9
05-28-2007, 01:08 AM
Spambots send PM's? Wow, well anyways, I'll keep this script in mind if I see such an issue. Probably good for heavy resourced forum sites.

Yeah, I found this out the hard way after almost 200 PM's were sent, one per minute. I was surprised someone would do this, too. :(

Konstantinos
06-02-2007, 07:57 AM
can u make it per usergroup ?

criscokid
06-10-2007, 05:45 PM
This configuration reads as "Limit users who have less than 50 posts to making no more than 5 PMs within 24 hours." Tweak to your liking.
Any chance of a similar mod so that it's usergroup based?
ie: registered users get 15 PMs per day, premium users get unlimited PMs per day.

Lionel
08-07-2007, 02:06 AM
This is a cool mod. I'd like to add to it the functionality of sending me a PM when someone in the "waiting period" attempts to send more than X PM per day. I am able to send and receive the alert. But it also gives me a database error even though transaction was successful. This is what I included before the closing bracket

$pmtitle = "Spammer Alert";
$pmmessage = "A new member, " . $vbulletin->userinfo['username'] . " is attempting to send numerous PM. Please verify for possible spammer.";
$sendtoname="Lionel";
// create the DM to do error checking and insert the new PM
$botpermissions['adminpermissions'] = 2;
$pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_ARRAY);
$pmdm->set('fromuserid', $vbulletin->userinfo['userid']);
$pmdm->set('fromusername', $vbulletin->userinfo['username']);
$pmdm->set('title', $pmtitle);
$pmdm->set('message', $pmmessage);
$pmdm->set_recipients($sendtoname, $botpermissions);
$pmdm->set('dateline', TIMENOW + 5);
// If no errors, save.
if ($pmdm->errors) {
return $pmdm->errors;
}
$pmdm->save();

Like I said, transaction is fine but the next page is about a duplicate entry. Do you still save the blocked PM ?

MySQL Error : Duplicate entry '25031' for key 1
Error Number : 1062

JadedSouls
09-19-2007, 11:31 PM
I like!
*installed*

qdin
02-11-2008, 12:55 PM
Thanx it works fine with 3.6.8

qdin
02-17-2008, 12:04 PM
There is a bug with this hack guys. I installed it 1 week ago. But unfortunately when my guests try to register the result of the register is a blank page. And the Error is like that

Fatal error: Call to a member function query_read() on a non-object in
/var/www/vhosts/******.net/httpdocs/forum/includes/class_dm_user.php(2449) : eval()'d code on line 13

When I disable this hack everything works fine. Could anyone find the problem :S I am not a good coder :S

P:S. the version of my board is 3.6.8

Sim9
02-17-2008, 07:38 PM
Konstantinos/criscokid - if you're interested in usergroup permissions, this is the line to change:
if ($vbulletin->userinfo['posts'] < $arc_exempt_postcount)

Off the top of my head, I'm not sure what the check usergroup code is, but you could change that condition to check for it. Should only be a one line change :)

Lionel - I like the idea of warning an admin about PM spam, but you wouldn't want to send one warning per attempt or your inbox would be badly spammed. I'm guessing that the reason you can't send a pm at that time is that another PM (the user's) is being constructed at that time. Maybe try erroring out and clearing the user's PM first, then send the admin pm (being sure to initialize a fresh PM with a unique ID)?

qdin, are you running a PM member on register plugin? It's possible this plugin is not compatible with that, though it runs fine on my board with other automated PMs (though I don't have a registration PM). Try sending automated PMs from a user account with a postcount higher than the spam check postcount

adwade
02-23-2008, 01:03 AM
One other question, not being a 'coder' I guess this

$arc_timeperiod_secs = 60 * 60 * 24; // How long (One Day)

is probably what controls the 60 second new posting delay? If one wanted to make the forced delay between postings 120secs (instead of 1min) would you change one of the 60's above, and if so which one?

Update: Nevermind, I found Private Messaging Options in AdminCP that controls the delay between sending PMs!

INSTALLED!

Sim9
02-23-2008, 02:53 AM
Sounds like you cleared it up, but just so everyone knows the distinction in case all they really need is the stock vB functionality:

Stock vBulletin provides an option to control the timeout between two individual PMs (adwade's post) - this lets you say a normal user can PM no more than once per sixty seconds. With a sixty second delay, a user can potentially send 1,440 privates messages a day (1,440 minutes in a day). Setting this to an hour interval mitigates this down to 24 private messages a day, at the cost of potentially annoying legitimate users who now have to wait a full hour between sending PMs.

This plugin lets you restrict the number of PMs sent over a span of a full day (or whatever other interval you set). So you could set the vBulletin delay between PMs to a negligible five seconds, but only allow five PMs per day for new users. This shouldn't affect legitimate new users, but will significantly limit the damage a spam bot could do.

Hope that makes the plugin clearer :)

adwade
02-24-2008, 04:44 AM
I'm running vB v3.6.4 and when I installed and tested your MOD, everything acted normally until :( I 'clicked' on the LINK in the verification email sent out when a new user registers. Then, this is what I got:

Fatal error: Call to a member function on a non-object in /home/*******/public_html/forums/includes/class_dm_user.php(2385) : eval()'d code on line 11

Toggle the MOD OFF and the error went away, whenever I signed up as a new user and clicked the verification LINK in the email. I get the same error using MS-IE or FireFox either one with the MOD Enabled. Any ideas??

EDIT: One other thing I forgot to add, is the Verification LINK actually works, regardless of this error. It's just seeing the Fatal Error vs. the You're Registered Now screen confuses new users.

adwade
02-24-2008, 05:01 AM
qdin, are you running a PM member on register plugin? It's possible this plugin is not compatible with that, though it runs fine on my board with other automated PMs (though I don't have a registration PM). Try sending automated PMs from a user account with a postcount higher than the spam check postcount

FWIW, I'm not. However, I am running Cyb - PM System Enhancements (https://vborg.vbsupport.ru/showthread.php?t=141838) Could that be doing it, when installed alongside your MOD? I disabled it and re-tried signing up as a new user with your MOD enabled and still got the Fatal Error above.

Sim9
02-24-2008, 08:17 PM
vBulletin apparently has a built-in send pm to user function on sign-up, as that's what class_dm_user is calling, and my plugin wasn't written to handle that (at least when the fromuser switch is on - otherwise it doesn't call my code at all in that function). Let's do an experiment and see if this fixes it. Open up the XML and change this line:

if ($vbulletin->userinfo['posts'] < $arc_exempt_postcount)

to this:

if (isset($vbulletin) && isset($db) && isset($vbulletin->userinfo) &&
$vbulletin->userinfo['posts'] < $arc_exempt_postcount)

Then reupload the XML and see if you still get errors.

adwade
02-25-2008, 05:08 AM
:cool:S-W-E-E-T job there Sim9! That little change seems to have fixed things right up for me. :up: Many Thanxx, as this is one MOD I could have used a few weeks ago. :eek: It's in place now though, and that's what counts. ;)

Sim9
02-26-2008, 01:19 AM
Excellent! I've updated the main download with version 1.1 so new users benefit from this change :)

Mark Tomlinson
03-02-2008, 03:49 PM
KISS principal at work! Excellent.

One thing our forum was discussing is that there is a 10 recipient limit on PMs. Even if a spammer can knock off only one PM, they could possibly send it to 10 members. I've been poking around to see if there is a way to limit the number of recipients, but not having any luck.

Thoughts? If I come up with anything, I'll share it.

adwade
03-03-2008, 03:54 AM
I've been poking around to see if there is a way to limit the number of recipients, but not having any luck.

Thoughts? If I come up with anything, I'll share it.

In AdminCP, under Usergroups choose Usergroup Manager then select a usergroup and you can specify the Maximum Recipients to Send PMs at a time.(with 0 disabling the feature) Just set it to 1 there and that should impede a spammer's ability to spread messages 10 at a time.

Mark Tomlinson
03-03-2008, 01:22 PM
Yeah, I figured this out last night. I was thinking that was something for the mod, but it can be done through permissions.

What I'm going to do is set 'Registered Users' to be able to only PM one recipient at a time. Then I'll create a group called 'Registered Users in Good Standing', and promote people there after a few posts.

Sorry to bother this thread about it.

adwade
03-04-2008, 03:46 AM
No bother at all, as threads such as these is where I've learned so many little things about vB. And besides, gives me a chance for another accolade to SIM9 for creating and modify this MOD so I could employ it! THANXX. :D

athlon64bit
01-01-2010, 01:17 AM
It would be nice if this could be brought out for vb4.:) Happy New Year everyone!

Sim9
01-01-2010, 04:53 AM
I haven't gotten around to upgrading my forum to v4 yet (too much custom coding & themeing done on v3), so I'll have to set aside a lot of time to get everything ported over. Once I do, I'll update this thread with a new version of this plugin (assuming of course v4 hasn't made it obsolete!).

MaKayWeB
03-09-2011, 12:45 PM
vb4.x ?