|
Post by Wormopolis on Mar 15, 2009 2:22:36 GMT -8
Browser Tested: IE and FF placement: global footer
allows you to set up additional restrictions on specfic board based on post count. uses a cookie to store members post count, and updates itself when profile is viewed or member posts. You can set up 3 different kinds of restrictions:
1. view - links to board are blocked and board itself gets content hidden unless certain number of posts are reached.
2. post - board can be seen, but all links to reply to posts and quick reply are hidden.
3. create - board can be seen, replies can be made, but all links to create a new thread/poll are hidden.
keep in mind a mischevious user can get around these restrictions by disabling javascript.
<script language="JavaScript"> <!-- // Post Count Restrictions v1.5 // Original Concept: Only viewy boardity with certain number of postitys By T.J. // Original: [url]support.proboards.com[/url] // Modded by Wormopolis for multiple boards // Modded again for view/post privs by Wormopolis // Modded again for creation restrict // Modded again for exemptions
// [boardid, posts, "view" or "post" or "create"] // boardid can be "ALL" for all boards (only for create)
var dataArray=[ ["happy",1000,"create"], ["dopey",200,"post"], ["general",50,"view"], ["ALL",10,"create"], ["beavis",1000,"view"] ];
var exemptUsers="admin|user2|user3"; //seperate by |
// no need to edit below
if (!pb_username.match(new RegExp('^('+exemptUsers+')$',''))) {
if(!location.href.match('action=')){ var ah=document.getElementsByTagName('a') for(a=0;a<ah.length;a++){ var found=''; for(worm=0;worm<dataArray.length; worm++) { if(ah[a].href.match('board='+dataArray[worm][0]) && !ah[a].href.match('thread=') && !document.cookie.match('postcount=')){ found=dataArray[worm][2]; } if(document.cookie.match('postcount=')){ if(ah[a].href.match('board='+dataArray[worm][0]) && !ah[a].href.match('thread=') && document.cookie.split('postcount=')[1].split(';')[0]<dataArray[worm][1]) { found=dataArray[worm][2]; } } } if (found=="view") ah[a].href='javascript:alert("Not enough posts to view this board");'; } } var found2=''; for (worm2=0; worm2<dataArray.length; worm2++) { if( (location.href.match('board='+dataArray[worm2][0])) || (dataArray[worm2][0]=="ALL" && dataArray[worm2][2]=="create")) { if (!document.cookie.match('postcount=')) { found2=dataArray[worm2][2]; } else { if (document.cookie.split('postcount=')[1].split(';')[0]<dataArray[worm2][1]) found2=dataArray[worm2][2]; } } } if (found2!='') { if(found2=="view") { var td=document.getElementsByTagName('td') for(i=0;i<td.length;i++){ td[i].style.display='none'; } document.write('<center><div style="background-color:#000000"><h2>You do not have enough posts to view this board.</h2><a href="'+location.href.split('?')[0]+'">Go to the home page</a><BR><BR></div></center>') } if(found2=="post") { var lnks=document.getElementsByTagName('a') document.write('<center><div style="background-color:#000000"><h2>You do not have enough posts to post in this board.</h2></div></center><BR>'); for(i=0;i<lnks.length;i++){ if(lnks[i].href.match(/ion=post/i) || lnks[i].href.match(/ion=createpoll/i)) { lnks[i].style.display='none'; } } qrf=document.getElementById('qrform'); if (qrf) { qrf=qrf.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode; qrf=qrf.parentNode.parentNode.parentNode; qrf.style.display="none"; } } if(found2=="create" && !location.href.match(/thread=/)) { var lnks=document.getElementsByTagName('a') document.write('<center><div style="background-color:#000000"><h2>You do not have enough posts to create new threads in this board.</h2></div></center><BR>'); for(i=0;i<lnks.length;i++){ if(lnks[i].href.match(/ion=post/i) || lnks[i].href.match(/ion=createpoll/i)) { lnks[i].style.display='none'; } } } }
if(location.href.match('action=viewprofile') || (location.href.match('thread=') && !location.href.match(/action=post/i))){ var ahh=document.getElementsByTagName('a') for(q=0;q<ahh.length;q++){ if(ahh[q].href.match('viewprofile&user='+pb_username)){ postcount=ahh[q].parentNode.parentNode.innerHTML.split('Posts: ')[1].split(/</)[0]; expDate=new Date(); expDate.setYear(expDate.getFullYear()+1); document.cookie="postcount="+postcount+"; expires="+expDate; break; } } }
} // --> </script>
Preview: Eventually.. but its pretty self explanatory.
|
|
|
Post by Wormopolis on Mar 15, 2009 2:30:20 GMT -8
Not responsible for people figuring out how to get around this.
|
|
۞Quaalude™۞
Not New Member
65
Posts: 32
۞Quaalude™۞ said 0 great things
|
Post by ۞Quaalude™۞ on Mar 15, 2009 10:22:33 GMT -8
WoW That is cool - i see where your suposed to Edit it , but i have too much code already QC
|
|
|
Post by Wormopolis on Mar 15, 2009 10:49:07 GMT -8
It actually runs pretty fast. it does a quick link check on whatever page its on. 2/3 of the code only runs if its on a board page, and of that 2/3 it only does something if the board id is in the array you edit.
Its pretty convenient actually. even pops up a message telling a person they dont have enough posts to do something.
|
|
|
Post by Wormopolis on Mar 22, 2011 12:09:18 GMT -8
version update 1.5: added exemptions
|
|
deathfish
Not New Member
Posts: 2
deathfish said 0 great things
|
Post by deathfish on Oct 16, 2012 21:26:01 GMT -8
If I change this code or first time installing it:
- do I have to click on every single user profile for the cookie to update itself?
|
|
|
Post by Wormopolis on Oct 16, 2012 22:17:43 GMT -8
no the cookie is on THEIR computer. as they browse the board or check their profile, if their own post count is seen, it gets remembered. then if they go into a board you setup in the array, it checks their post count and does what it needs if they are under the post count.
if they dont have the cookie stored, it assumes they dont have the post count required
|
|
deathfish
Not New Member
Posts: 2
deathfish said 0 great things
|
Post by deathfish on Oct 17, 2012 3:40:04 GMT -8
what happens if the user does not happen to land on any pages which show their post count?
|
|
|
Post by Wormopolis on Oct 17, 2012 8:25:43 GMT -8
the code assumes they dont have the post count required. the first time they post somewhere though it automatically lands on a page with their post count.
|
|