miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | Manual |
Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /  
 

How to limit the number of topics or messages per day for each user?

 
 
Page  Page 2 of 3:  « Previous  1  2  3  Next »

Author Paul
Lead Developer 
#16 | Posted: 8 Dec 2008 02:50 
The first one is right.

I'm not sure why it doesn't work in other sections because it definitely should (but it depends on what actually you are trying to achieve with that request - it means, you are getting the amount of topics posted for the currently logged in user, it's not for the users listed in topics listings or search results or anywhere else).

Author tom322
Active Member
#17 | Posted: 8 Dec 2008 18:12 
Paul:
The first one is right.
That was the most important part to confirm, thanks :)

Paul:
I'm not sure why it doesn't work in other sections because it definitely should (but it depends on what actually you are trying to achieve with that request - it means, you are getting the amount of topics posted for the currently logged in user, it's not for the users listed in topics listings or search results or anywhere else).
I'm not sure either, but it turns out I only need it on vtopic and vthread pages anyway so I'm good for now..

Author marsbar
Associated Member
#18 | Posted: 30 Dec 2010 04:05 
In a recent discussion on anti-spam/flooding measures, Paul mentioned the idea of imposing a daily message (topics + replies) quota for new users.

I thought I'd try implement this great idea by adapting code snippets found in this thread. The following code (found in reply#12), which is supposed to allow x messages per user per day, seems to be the closest to what I need:

if($forum!=0 and $user_id>0 and $user_id!=1 and $isMod==0){
$reachedLimit=FALSE;
$timeLimit=date('Y-m-d H:i:s', time()-86400);
if($row=db_simpleSelect(0, $Tp, 'count(*)', 'poster_id', '=', $user_id, '', '', 'post_time', '>=', $timeLimit)){
if($row[0]>=3) $reachedLimit=TRUE;
}
if($reachedLimit) $poForums[]=$forum;
}
And I figure I probably only need to modify the first line - change all users to just new users ... somehow! Yes, I am stuck. Any help/pointers will be gratefully received. Thanks -
marsbar

Edit: The above quoted code snippet when implemented as is, it only limited the number of topics users can post in a day, but not the number of replies. :-(

Author tom322
Active Member
#19 | Posted: 30 Dec 2010 15:01 
Maybe the first line change to:

if($forum!=0 and $user_id>0 and $user_id!=1 and $isMod==0 and $user_num_posts=0){

Author Paul
Lead Developer 
#20 | Posted: 3 Jan 2011 06:34 
Instead $user_num_posts=0 condition it's also possible to have $user_num_posts<=X where X stands for a total posts limit of certain user.

You may also try the code of how to prevent posting more than X messages per day from the certain IP address:

if($forum!=0 and $user_id>0 and $user_id!=1 and $isMod==0){
$reachedLimitMessages=20; //the amount of daily allowed messages
$reachedLimit=FALSE;
$thisIp=getIP();
$timeLimit=date('Y-m-d H:i:s', time()-86400);
if($row=db_simpleSelect(0, $Tp, 'count(*)', 'poster_ip', '=', $thisIp, '', '', 'post_time', '>=', $timeLimit)){
if($row[0]>=$reachedLimitMessages) $reachedLimit=TRUE;
}
if($reachedLimit) $roForums[]=$forum;
}
(I didn't test it, so if it doesn't work, let me know)

Author marsbar
Associated Member
#21 | Posted: 5 Jan 2011 04:14 
Thanks to tom322 and to Paul for your helpful replies.

Paul:
You may also try the code of how to prevent posting more than X messages per day from the certain IP address ...
Thanks for the code snippet, Paul; I intend to implement it, for I am sure my miniBB community will appreciate the added protection against spammers and flooders provided by your code.

Does it matter where I paste the code snippet in the bb_plugins file? Plugins I have in place already: CAPTCHA, who is online, disclaimer, pre-moderation, moving replies, and message preview - in that order.

While I believe I can follow the logic of the code, I do not know what the highlighted if statement says exactly:

$forum!=0 means If forum is not ... ??
$user_id>0 means user ID is not anon/guest ?
$user_id!=1 means not Admin ?
$isMod==0 means not moderator ?
---> admin and moderators are exempt from quota ?

I probably have got it all wrong (hence all the question marks!) ... I would be grateful if Paul would not mind providing a plain English translation. Understanding what the first line says, I hope to know whether nor not it is necessary to add additional conditions to target specific users (e.g. all new members, or anyone with a low post count, or a particular user ... etc, etc).

Ever thankful -
marsbar

Author Paul
Lead Developer 
#22 | Posted: 5 Jan 2011 05:31 
I've updated the code above a bit.

Here is how the code works:

1. it checks if there is a $forum var provided, which would mean the user is viewing the forum or posting in some forum. $user_id>0 means this thing is only for logged users. $user_id!=1 and $isMod==0 excludes the admin and moderators from this condition.

2. The code defines the limit of messages per day and gets the user IP. Actually the script also will use this string later in the code, we should define it here, because bb_plugins.php is included earlier than IP is defined. Not a big deal. $timeLimit is about to get the 24 hours difference time (86400 seconds = 24 hours). At first, $reachedLimit flag is FALSE which means the user is allowed to make posts.

3. mySQL statement uses miniBB's mySQL function which checks how many messages (count(*)) were posted in 24 hours from the determined IP address.

4. If this amount is bigger or equal to the defined $reachedLimitMessages (if it's equal, it means the user *already* has such amount and can't post anymore), then $reachedLimit flag becomes TRUE. That means, user can't post anymore, and the forum is added to the core miniBB's $roForums array (read-only forums). Executing the next code, index.php will take this into consideration and won't allow user to post basing on all conditions this setting defines.

So this code is only about extending $roForums array on the fly.

Author marsbar
Associated Member
#23 | Posted: 5 Jan 2011 06:04 
Hi again, Paul; thanks so much for your updated solution and your helpful explanation. :-D
You may have missed this question from earlier: does it matter where the message quota code snippet appears in bb_plugins.php? (Plugins I have in place already: CAPTCHA, who is online, disclaimer, pre-moderation, moving replies, and message preview - in that order.)
Thanks -
marsbar

Author Paul
Lead Developer 
#24 | Posted: 5 Jan 2011 08:24 
It doesn't matter, but preferably put it after 'who is online' code, or to the top of file.

Author marsbar
Associated Member
#25 | Posted: 6 Jan 2011 04:06 
Paul, you are a genius! Many thanks for your quick response; the solution works beautifully now. :-D
Cheers -
marsbar

Author Paul
Lead Developer 
#26 | Posted: 6 Jan 2011 08:14 
If I would be genius, I would rather invent something else but miniBB. Anyway, thank you :-) Enjoy.

Author taylorc
Partaker
#27 | Posted: 20 Jan 2011 02:37 
I guess this is useful for people who open alot of useless threads, or duplicate threads, but otherwise I let them do what they want.

Author Mahmoud
Guest
#28 | Posted: 13 May 2011 11:52 
Hi,

This topic is very helpful indeed...However, what I need is something a bit more complicated :)

I need to correlate the number of replies to the number of new posts for a particular forum. That is to say:

If (forum=1 AND noOfReplies=x) {

maxNoOfNewTopicsAllowed = 0.5*x }

In this case, for this forum 1, a particular member can only post one new topic for every two replies he/she makes..

Is this at all possible?

Thanks a lot

Mahmoud

Author Paul
Lead Developer 
#29 | Posted: 16 May 2011 02:52 
Mahmoud:
Is this at all possible?
Yes.

In the code above, this line:

if($row=db_simpleSelect(0, $Tp, 'count(*)', 'poster_ip', '=', $thisIp, '', '', 'post_time', '>=', $timeLimit)){
should be a more complicated request. Similar to:

if($res=mysql_query("select count(*) from {$Tp} where poster_ip='{$thisIp}' and post_time='{$timeLimit}'" and forum='12'") and mysql_num_rows($res)>0 and $row=mysql_fetch_row($res))
Then further in the code, you should compare $row[0] to the values from the associated array, where each element defines a limit for the forum.

Author marsbar
Associated Member
#30 | Posted: 29 Jan 2012 08:44 
Hi Paul,

Paul:
try the code of how to prevent posting more than X messages per day from the certain IP address
Your "daily message quota per IP" solution will limit replies AND new toipcs allowed per IP per day. Can this useful solution be extended to include a further rule that will limit the number of topics non-staff members can reply to? The additional rule might tackle the problem of members (typically new ones) going on a fox-in-a-hen-house spree of pointless replies to a load of old threads in one go.

Thanks and cheers,
mb

Page  Page 2 of 3:  « Previous  1  2  3  Next » 
Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /
 How to limit the number of topics or messages per day for each user?
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Try the File and Picture Attachments add-on: extend your miniBB-forums, attaching images and files.


  ⇑