miniBB ® miniBB®
miniBB Support Forums
 | Forums | Register | Reply | Search | Statistics | 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 1 of 3:  1  2  3  Next »  
Author SpeedStick
Guest
#1 | Posted: 22 Jan 2007 10:03 
How to limit the number of topics per day for each user?

Author Paul
Lead Developer
#2 | Posted: 22 Jan 2007 12:37 
Do you want to limit the number of topics or replies actually?

Author SpeedStick
Guest
#3 | Posted: 22 Jan 2007 15:16 
Paul

I want to limit the number of TOPICS for 3 for user!

Author Paul
Lead Developer
#4 | Posted: 23 Jan 2007 06:33 
Try to paste this code in bb_plugins.php:

/* Allow only X topics in 24 hours */
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, $Tt, 'count(*)', 'topic_poster', '=', $user_id, '', '', 'topic_time', '>=', $timeLimit)){
if($row[0]>=3) $reachedLimit=TRUE;
}
if($reachedLimit) $poForums[]=$forum;
}
/* --Allow only X topics in 24 hours */

When user is close to the limit, the forums will become "post-only" for him. So he won't be able to create new topics...

Author SpeedStick
Guest
#5 | Posted: 23 Jan 2007 21:40 
Paul

Functioning ok!

Author Danny2000
Registered
#6 | Posted: 14 Dec 2007 15:15 | Edited by: Danny2000 
Is it possible that we make forums "read-only" for users that joined in last 2 days?

Author Paul
Lead Developer
#7 | Posted: 17 Dec 2007 04:46 
It is possible however it appears to be a custom modification (with and I could provide the code only on a paid basis...

Author SamSam
Registered
#8 | Posted: 18 Dec 2007 00:50 
oh my god, everything we have to buy :D

Author Paul
Lead Developer
#9 | Posted: 18 Dec 2007 03:40 
Program it yourself if you don't want to buy ;-) It's open source...

I am wondering how often people think the programs must be free... Programmers are the same people as you dudes and when you go to the car service, nobody will not even study your car for free to investigate their problems or add new functions. Programmers are the same kind of engineers but only in the other area.

Author marsbar
Associated Member
#10 | Posted: 29 Dec 2007 17:51 | Edited by: marsbar 
Hi Paul,

Hope you had a nice Christmas. :)

Is there is similar solution for limiting the number of replies per user per day?

Relatedly, in the case where only a few trouble-makers exist, is it possible to apply daily posting limits to only certain users? Here is a scenario: Users A, B and C can make only x topics and y replies per day. No limits apply to other users. In this scenario, user B is also a pre-moderated user.

Cheers,
mb

Author Paul
Lead Developer
#11 | Posted: 2 Jan 2008 04:50 | Edited by: Paul 
Hope you had a nice Christmas - if we talk about the Catholic Christmas, i.e. December 25-26 - thank you, they were nice holidays :-) However mentioning I am Orthodox and will celebrate Christmas on the 7th of January (which corresponds to December 25 in the Julian Calendar), my Christmas is not arrived yet.

Ok, closer to the solution - in my code only few lines are needed to change.

First of all, we would to define all IDs of the users which are limited in their rights.

For example

if($forum!=0 and $user_id>0 and $user_id!=1 and $isMod==0 and in_array($user_id, array(1,2,3)) ){

where 1,2,3 stand for your user IDs.

Then we would need to select postings amount from posting table

$row=db_simpleSelect(0, $Tp, 'count(*)', 'poster_id', '=', $user_id, '', '', 'post_time', '>=', $timeLimit)

So overall it would look like:

/* Allow only X posts in 24 hours for certain users */
if($forum!=0 and $user_id>0 and $user_id!=1 and $isMod==0 and in_array($user_id, array(1,2,3))){
$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;
}
/* --Allow only X posts in 24 hours for certain users */

Author marsbar
Associated Member
#12 | Posted: 3 Jan 2008 18:23 | Edited by: marsbar 
Happy New Year, Paul (and all at miniBB.com). Thanks for your helpful reply!

So far, I've learnt:

1) to limit the number of new topics a day per each user, we need to add to bb_plugins.php the code provided in Paul's post of 23 Jan 06:33.

2) to limit the number of replies/posts per day per certain users, we need to add to bb_plugins.php the code provided in Paul's post of 2 Jan 2008 04:50.

Now I assume: (if I am wrong, please correct me--gently, please!)

a) to limit the number of new topics per day per certain users, the code we need to apply might look something like this:

if($forum!=0 and $user_id>0 and $user_id!=1 and $isMod==0 and in_array($user_id, array(1,2,3))){
$reachedLimit=FALSE;
$timeLimit=date('Y-m-d H:i:s', time()-86400);
if($row=db_simpleSelect(0, $Tt, 'count(*)', 'topic_poster', '=', $user_id, '', '', 'topic_time', '>=', $timeLimit)){
if($row[0]>=3) $reachedLimit=TRUE;
}
if($reachedLimit) $poForums[]=$forum;
}

b) To limit the number of replies/posts per day per user, the code might look something like this:
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;
}

c) To limit BOTH the number of new topics AND replies/posts per day per user, one will need to apply two blocks of code - code blocks referred to in points 1 and b respectively. Similarly, to apply the same limits but only to certain users, apply code blocks referred to in points 2 and a respectively. Correct?

Thanks for your time and patience - and happy Christmas for the 7th. :-)

Greetings from Melbourne where it is a toasty 35C today -
marsbar

Author Paul
Lead Developer
#13 | Posted: 4 Jan 2008 03:59 | Edited by: Paul 
I suppose limiting replies also means you will limit new topics simultaneously (because in the database reply is the part of any topic). So yes - for limiting messages for any user you might use the code provided in b).

Happy new year, thanks! I've finally found the time today and sent to all miniBB users an official 2008 congratulation ;-)

Author marsbar
Associated Member
#14 | Posted: 6 Jan 2008 15:01 
Paul wrote: I suppose limiting replies also means you will limit new topics simultaneously (because in the database reply is the part of any topic). So yes - for limiting messages for any user you might use the code provided in b).

Just perfect! Thank you, Paul.
- marsbar

Author tom322
Registered
#15 | Posted: 7 Dec 2008 11:57 | Edited by: tom322 
It's not directly related to this addon, but something similar I'm trying to achieve.

Could someone please confirm that this is the correct query to get the number of topics started (at any time) by a particular user:

$row=db_simpleSelect(0, $Tt, 'count(*)', 'topic_poster', '=', $user_id)

or this one is better:

$row=db_simpleSelect(0, $Tt, 'count(*)', 'topic_poster','','', '=', $user_id)

I'm just confused if there should be any ",'',''," in this request or not :).

Also, it seems such query works (ie. provides the result) only on vtopic and vthread pages, it won't work on other pages (ie. prefs, search, checker, etc.); I wonder if it's possible to make sure it works on other pages too?

Thanks.

Page  Page 1 of 3:  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? Top

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

 Short link for this topic:

 ?
Only registered users are allowed to post here. Please, enter your username/password details upon posting a message, or register first.


Before posting, make sure your message is compliant with our forum posting rules. If not, it may be locked or deleted with no explanation.
 
 
miniBB Support Forums Powered by Forum Software miniBB ® Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contacts
Get the Captcha add-on: protect your miniBB-forums from the automated spam and flood.
Captcha Addon for miniBB