|
Post by Wormopolis on Mar 17, 2009 7:45:29 GMT -8
Browsers tested: IE and FF placement: Global Footer
allows you to restrict posting abilities to a member (or member group) for a single board/category or all boards.
<script type="text/javascript"> <!-- // PostChoke v 2.2 // Selective Board/category Restrict // Do not repost - keep header intact // By Wormopolis - wormocodes.proboards.com
function chokehold(u_name, b_name, type, pcount, dlapse) { if (u_name.match(/GROUP/)) { u_name=u_name.replace(/GROUP/,''); var idchk2=new RegExp('^'+u_name+'$',''); var blankUGchk=(pb_usergroup=='' && type>0); urgx=(pb_usergroup.toString().match(idchk2) || blankUGchk ? pb_username : ' '); } else {urgx=new RegExp('^('+u_name+')$','');} if (b_name.match(/CAT/)) { b_name=b_name.replace(/CAT/,''); var fj=document.getElementById('forumjump'); var idchk1=new RegExp('#'+b_name+'$',''); var switchcat=false, bArray='board=('; for (opts=0; opts<fj.options.length; opts++) { var valchk=fj.options[opts].value; if (!valchk.match(/board=/) && valchk.match(idchk1)) { switchcat=true; } else { if (switchcat && valchk.match(/board=(.*?)$/)) {bArray+=RegExp.$1+'|';} else {switchcat=(valchk ? false : switchcat);} } } bArray=bArray.substr(0,bArray.length-1)+')($|&)'; brgx=new RegExp(bArray,''); } else if (b_name.match(/THR/)) { b_name=b_name.replace(/THR/,''); var tchk=new RegExp('thread='+b_name+'($|&)',''); if (location.href.match(tchk)) { b_name=(location.href.match(/board=(.*?)($|&)/) ? RegExp.$1: ' '); } else {b_name=' '; } brgx=new RegExp('board='+b_name+'($|&)',''); } else {brgx=new RegExp('board='+b_name+'($|&)','');} if ((type>0 && pb_username.match(urgx)) || (type<0 && !pb_username.match(urgx))) { type=Math.abs(type); if (!pb_action.match(/pm(view|send)/)) { if (location.href.match(brgx) || b_name=='ALL') { var bpcount=(document.cookie.match(new RegExp('watchpcount_'+b_name+'=(\\d+?)(;|$)','')) ? RegExp.$1 : 0); if (!pcount || (pcount && parseInt(bpcount)>=parseInt(pcount))) { alnks=document.getElementsByTagName('a'); for (i=0; i<alnks.length; i++) { if ((alnks[i].href.match(/action=post/i) && (type==1 || (type==2 && !alnks[i].href.match(/thread=/i)))) || alnks[i].href.match(/action=modifypost/i) || alnks[i].href.match(/action=createpoll/i)) { alnks[i].style.display="none"; } if (alnks[i].href.match(/action=modifypost/i) && type==3) { alnks[i].style.display="none"; } } qrsub=document.getElementsByTagName('textarea'); for (a=0; a<qrsub.length; a++) { if (qrsub[a].name=='message' && type==1) { tmp=qrsub[a].parentNode.parentNode.parentNode.parentNode; tmp.parentNode.parentNode.parentNode.style.display="none"; } } } if (pcount && document.postForm) { var dt=new Date(); dt.setHours(dt.getHours()+(dlapse ? dlapse*24 : (365*24))); if (postForm.addEventListener) { postForm.addEventListener('submit',function() {document.cookie='watchpcount_'+b_name+'='+(++bpcount)+'; expires='+dt; }, true); } else { postForm.attachEvent('onsubmit',function() {document.cookie='watchpcount_'+b_name+'='+(++bpcount)+'; expires='+dt; }); } } if (pcount && pb_action=='display') { var dt=new Date(); dt.setHours(dt.getHours()+(dlapse ? dlapse*24 : (365*24))); for (ta=document.getElementsByTagName('textarea'), tt=ta.length-1; tt>=0; tt--) { if (ta[tt].name && ta[tt].name=='message' && ta[tt].accessKey && ta[tt].accessKey=='q') { qrbtn=ta[tt].nextSibling.nextSibling; break;} } if (qrbtn.addEventListener) { qrbtn.addEventListener('click',function() {document.cookie='watchpcount_'+b_name+'='+(++bpcount)+'; expires='+dt; }, true); } else { qrbtn.attachEvent('onclick',function() {document.cookie='watchpcount_'+b_name+'='+(++bpcount)+'; expires='+dt; }); } } } } } } var tmpUG=(document.cookie.match(/pb_usergroup=(group)?(\d+?)(;|$)/) ? RegExp.$2 : ''), tmpUG2=''; for (lnks=document.getElementsByTagName('a'), ll=0; ll<lnks.length; ll++) { if (lnks[ll].href.match(new RegExp('action=viewprofile&user='+pb_username+'($|&)',''))) { tmpUG2=lnks[ll].className.replace(/group/i,''); break; } } if (tmpUG2!='' && (tmpUG=='' || parseInt(tmpUG)!=parseInt(tmpUG2))) { //not in cookie but found on page OR cookie and found dont match - update cookie var pb_usergroup=parseInt(tmpUG2); exptime=new Date(); exptime.setFullYear(exptime.getFullYear()+1); document.cookie='pb_usergroup='+pb_usergroup+'; expires='+exptime; } else { var pb_usergroup=(tmpUG!='' ? parseInt(tmpUG) : ''); //from cookie or blank }
/*---------- Examples -------------------
// enter multiple calls below for each user/board you want to restrict posting // boardname should be the boardid, or enter ALL for all boards // type is 1 for create AND reply, 2 is create only.
chokehold('wormopolis','tankball',1); chokehold('timothy','ALL',2);
// you can REVERSE the chokehold by making the type a // negative number. this will restrict everyone EXCEPT // the username from posting
chokehold('test','ut',-1);
// and multiple usernames must be seperated by |
chokehold('timothy|wormopolis','foots',-2);
// adding a fourth optional argument of a number, will choke after post count in that board has been reached.
chokehold('kramer','general',1,10); //this would prevent kramer from making threads/replies after he makes 10 of them
// adding a fifth optional argument, sets the number of days the fourth argument lasts. omitting it makes it permanent (or they clear cookies)
chokehold('sanford','junk',2,10,7); //this would prevent sanford from making threads, after he makes 10 of them, for 7 days
// if you want to reset the members counter, set the fifth argument to -1
// NEW TO v 1.9 - User Group chokes
chokehold('GROUP2','manners',-1); //all caps GROUP followed by the group id, or for multiple groups: chokehold('GROUP(1|2|3)','gensub1',-1); //put all the ids into parenthesis seperated by |
// NEW TO v 1.95 - Category chokes
chokehold('martin','CATgeneral',-1); //all caps CAT followed by the category id, or for multiple groups: chokehold('stanley','CAT(general|apps|testing)', 2); //put all the ids into parenthesis seperated by |
// NEW TO v 2.0 - Thread chokes
chokehold('martin','THR1324',1); //all caps THR followed by the thread id, or for multiple threads: chokehold('stanley','THR(123|456|147)', -1); //put all the ids into parenthesis seperated by |
//NEW TO v 2.1 - Thread Chokes revamp
when using a thread choke, type 1 would restrict member from replying to that thread. type -1 would restrict everyone EXCEPT member from replying to that thread. type 2 would restrict member from replying to ANY thread except that one. -2 would restrict everyone EXCEPT member from replying to ANY thread except that one. that one might be too powerful.. maybe I shouldnt allow it...
//NEW TO v 2.2 - modifyChoke
use type 3 to prevent someone from modifying posts
chokehold('zeke','general', 3);
//----------------------------------- */
// enter your chokes below HERE
// --> </script>
Preview: self explanatory.
|
|
|
Post by Wormopolis on Apr 2, 2009 16:36:56 GMT -8
major revamp of the code to allow for type of posting restriction and Reverse restrictions (restrict everyone EXCEPT usernames).
|
|
|
Post by Wormopolis on Dec 21, 2010 11:21:08 GMT -8
version upgrade 1.6: changed the regexp
|
|
|
Post by Wormopolis on Mar 6, 2011 20:25:57 GMT -8
version update 1.7: added in ability to choke after member posts a certain number of times, with an optional expiration
|
|
|
Post by Wormopolis on Mar 11, 2011 19:48:43 GMT -8
version update 1.9: added the ability to choke user groups. see examples at bottom of code
|
|
|
Post by Wormopolis on Mar 12, 2011 21:22:59 GMT -8
version update 1.95: now allows for restriction of an entire category
|
|
|
Post by Wormopolis on Mar 13, 2011 5:20:33 GMT -8
thank you blackball for helping me find a bug
version update 1.591: bug fix for usergroup not found
|
|
|
Post by Wormopolis on Mar 13, 2011 7:35:39 GMT -8
I shouldnt code when Im so tired..
version update: 1.952: another bug fix I caused from the last fix
|
|
blackball
Not New Member
Posts: 21
blackball said 0 great things
|
Post by blackball on Mar 14, 2011 4:03:07 GMT -8
Thankyou for all your help with this Wormo, hope you got some sleep in the end Much appreciated.
|
|
|
Post by Wormopolis on Dec 28, 2011 16:39:32 GMT -8
version update 2.0: thread chokes.
you can now choke member's ability on specific threads using the thread ID. remember if you MOVE a thread, it gets a new ID and might make it possible for the user to post on it again. be sure to update the id in the call.
|
|
|
Post by Wormopolis on Jan 1, 2012 9:56:23 GMT -8
version update 2.02: fixed 2 small errors
|
|
|
Post by Wormopolis on Nov 1, 2012 17:01:00 GMT -8
version update 2.2: added ability to restrict modify button from members. do not use this in addition to a code that removes the delete button. that would be against TOS
|
|