Post by Ross on Jul 27, 2006 15:37:10 GMT -8
Global Footer
This will allow you to impose posting restrictions on certain boards. For example, if you have some form of request board with a request limit, then you can limit members to only being able to make 2 threads per week
<script type="text/javascript">
<!--
/* Limit Number of Posts Made Per X Days Per Board
By Ross of support.proboards.com */
var exclude_users = /^(admin|username1|username2)$/
var post_limit = [];
// Edit in the form post_limit['board_id'] = [maximum_posts, days_to_limit_for, include replies (true/false)];
post_limit['general'] = [5, 1, true];
// no need to edit below
if(location.href.match(/board=(.+?)(&|$)/)) {
var board_id = RegExp.$1;
if(post_limit[board_id]) {
var mes = document.getElementsByName('message');
function add_to_post_limit() {
var d = new Date();
d.setDate(d.getDate() + post_limit[board_id][1]);
var p_id = 1;
while(document.cookie.match(new RegExp(board_id +'_'+ p_id, 'i'))) {
p_id++;
}
document.cookie = board_id + '_'+ p_id +'=true;Expires='+ d;
return true;
}
var current_posts = 0;
for(c=1; c<=post_limit[board_id][0]+1; c++) {
if(document.cookie.match(new RegExp(board_id+'_'+c, 'i'))) {
current_posts++;
}
}
if(current_posts >= post_limit[board_id][0] && !pb_username.match(exclude_users)) {
if(post_limit[board_id][2] && mes.item(0) && !document.postForm) {
var obj = mes.item(0).parentNode;
while(obj.className != 'bordercolor') {
obj = obj.parentNode;
}
obj.style.display = 'none';
obj.previousSibling.style.display = 'none';
obj.previousSibling.previousSibling.style.display = 'none';
}
var a = document.getElementsByTagName('a');
for(i=0; i<a.length; i++) {
if((post_limit[board_id][2] && a.item(i).href.match(/ion=post&/)) || (a.item(i).href.match(/ion=(post|createpoll)$/))) {
a.item(i).style.display = 'none';
}
}
if(document.postForm) {
var table = document.getElementsByTagName('table');
for(i=0; i<table.length; i++) {
if(table.item(i).width == '100%' && table.item(i).className == 'bordercolor' && table.item(i).innerHTML.match(/Post (Message|Reply)/)) {
table.item(i).getElementsByTagName('b').item(0).innerHTML = 'An Error Has Occured';
while(table.item(i+1).rows.item(1)) {
table.item(i+1).deleteRow(1);
}
var new_cell = table.item(i+1).insertRow(1).insertCell(0);
new_cell.className = 'windowbg';
new_cell.innerHTML = '<font size="2">Your posting limit is currently full. Please try again later</font>';
}
}
}
} else if(document.postForm && (post_limit[board_id][2] || !document.postForm.thread)) {
document.postForm.onsubmit = function() {
if(document.postForm.nextaction == 'post') {
add_to_post_limit();
}
}
} else if(post_limit[board_id][2] && mes.item(0)) {
mes.item(0).parentNode.onsubmit = function() {
add_to_post_limit();
}
}
}
}
//-->
</script>
You can edit/repeat the bit in red as needed. Just keep it in the form of:
post_limit['general'] = [5, 1, true];
Where green is the board ID where the code will affect. The blue is the limit on the number of posts allowed. The purple is the number of days this limit lasts. And the orange sets if it counts replies or not (true will count replies, false will just count new threads). You can edit the bold to exclude certain users from this limit, just seperate each users username with a "|" line
This will allow you to impose posting restrictions on certain boards. For example, if you have some form of request board with a request limit, then you can limit members to only being able to make 2 threads per week
<script type="text/javascript">
<!--
/* Limit Number of Posts Made Per X Days Per Board
By Ross of support.proboards.com */
var exclude_users = /^(admin|username1|username2)$/
var post_limit = [];
// Edit in the form post_limit['board_id'] = [maximum_posts, days_to_limit_for, include replies (true/false)];
post_limit['general'] = [5, 1, true];
// no need to edit below
if(location.href.match(/board=(.+?)(&|$)/)) {
var board_id = RegExp.$1;
if(post_limit[board_id]) {
var mes = document.getElementsByName('message');
function add_to_post_limit() {
var d = new Date();
d.setDate(d.getDate() + post_limit[board_id][1]);
var p_id = 1;
while(document.cookie.match(new RegExp(board_id +'_'+ p_id, 'i'))) {
p_id++;
}
document.cookie = board_id + '_'+ p_id +'=true;Expires='+ d;
return true;
}
var current_posts = 0;
for(c=1; c<=post_limit[board_id][0]+1; c++) {
if(document.cookie.match(new RegExp(board_id+'_'+c, 'i'))) {
current_posts++;
}
}
if(current_posts >= post_limit[board_id][0] && !pb_username.match(exclude_users)) {
if(post_limit[board_id][2] && mes.item(0) && !document.postForm) {
var obj = mes.item(0).parentNode;
while(obj.className != 'bordercolor') {
obj = obj.parentNode;
}
obj.style.display = 'none';
obj.previousSibling.style.display = 'none';
obj.previousSibling.previousSibling.style.display = 'none';
}
var a = document.getElementsByTagName('a');
for(i=0; i<a.length; i++) {
if((post_limit[board_id][2] && a.item(i).href.match(/ion=post&/)) || (a.item(i).href.match(/ion=(post|createpoll)$/))) {
a.item(i).style.display = 'none';
}
}
if(document.postForm) {
var table = document.getElementsByTagName('table');
for(i=0; i<table.length; i++) {
if(table.item(i).width == '100%' && table.item(i).className == 'bordercolor' && table.item(i).innerHTML.match(/Post (Message|Reply)/)) {
table.item(i).getElementsByTagName('b').item(0).innerHTML = 'An Error Has Occured';
while(table.item(i+1).rows.item(1)) {
table.item(i+1).deleteRow(1);
}
var new_cell = table.item(i+1).insertRow(1).insertCell(0);
new_cell.className = 'windowbg';
new_cell.innerHTML = '<font size="2">Your posting limit is currently full. Please try again later</font>';
}
}
}
} else if(document.postForm && (post_limit[board_id][2] || !document.postForm.thread)) {
document.postForm.onsubmit = function() {
if(document.postForm.nextaction == 'post') {
add_to_post_limit();
}
}
} else if(post_limit[board_id][2] && mes.item(0)) {
mes.item(0).parentNode.onsubmit = function() {
add_to_post_limit();
}
}
}
}
//-->
</script>
You can edit/repeat the bit in red as needed. Just keep it in the form of:
post_limit['general'] = [5, 1, true];
Where green is the board ID where the code will affect. The blue is the limit on the number of posts allowed. The purple is the number of days this limit lasts. And the orange sets if it counts replies or not (true will count replies, false will just count new threads). You can edit the bold to exclude certain users from this limit, just seperate each users username with a "|" line