|
Post by Wormopolis on Dec 19, 2008 15:11:13 GMT -8
Browser Tested: IE and FF placement: Global Footer
hides a specific board from a user or group of users.
<script type="text/javascript"> <!-- // Selective Board Hide // version 3.1 // By Wormopolis - www.wormocodes.com // do not repost - keep header intact
function vanish(u_name, b_name, negated) { if (negated==undefined) negated=false; if (u_name.match(/GROUP/)) { u_name=u_name.replace(/GROUP/,''); var idchk2=new RegExp('^'+u_name+'$',''); var blankUGchk=(pb_usergroup==''); uchk=(pb_usergroup.toString().match(idchk2) && !blankUGchk); } else { var uchk=(pb_username.match(u_name) || u_name=='all');} if (((!negated && uchk) || (negated && !uchk)) && pb_username!='admin') { var rgx=new RegExp("board="+b_name+"(&|$|\'|\")",''); var rgx2=new RegExp("board-"+b_name+'(>|")','');
// if they got on the board somehow send em home if (location.href.match(rgx)) location.href="/index.cgi";
// take care of forum jumper first iTsel=document.getElementById('forumjump'); iTopt=iTsel.options; for (n=0; n<iTopt.length; n++) { if (iTopt[n].value.match(rgx)) { iTopt[n]=null; while(iTopt[n].innerHTML.match('---')) iTopt[n]=null; } }
// now check body of page to see if board shows up var holdit = document.getElementsByTagName('body')[0]; if (holdit.innerHTML.match(rgx) || holdit.innerHTML.match(rgx2)) { // if it does THEN scan page and remove iTrw=document.getElementsByTagName('tr'); for (j=0; j<iTrw.length; j++) { if ( (iTrw[j].innerHTML.match(rgx) || iTrw[j].innerHTML.match(rgx2)) && !iTrw[j].innerHTML.match(/<table/i)) { if (!iTrw[j].innerHTML.match(/topic:/i)) { if (location.href.match(/search/i)) { iTrw[j].getElementsByTagName('input')[0].checked=false; p=j+1; while(iTrw[p] && iTrw[p].cells.length>1) { if (iTrw[p].cells[1].getElementsByTagName('font')[0].innerHTML.slice(0,2).match('-')=='-') { iTrw[p].getElementsByTagName('input')[0].checked=false; iTrw[p++].style.display='none'; } else break; } } iTrw[j].style.display='none'; } else { iTlnk=iTrw[j].getElementsByTagName('a'); for (k=0; k<iTlnk.length; k++) { if (iTlnk[k].href.match(rgx)) { iTlnk[k].href=''; iTlnk[k].innerHTML="hidden"; } } } } } } } }
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].className && lnks[ll].className.match(/group/i) && 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 }
/*------------------------------------------------------*/
/* // enter multiple calls below for each user/board you want to hide // boardname should be the board id // single names in quotes: vanish('test','general');
// multiple names for the same board in parenthesis seperated by | vanish(/(johnsmith|jackdaniel)/,'ladiesonly');
// if you want a board hidden from everyone except admin, make username 'all' vanish('all','secretstuff');
// you can also hide boards from Guest
// multiple boards use this syntax vanish('testuser','(board1|board2|board3)'); //seperate boardids by |
// new to v2.5 negation // set third parameter to true to invert the hide
vanish(/(user1|user2|user3)/,'testboard',true); // would hide board for everyone except those 3 users and admin
// new to v3.0 usergroups // instead of a username, put GROUP (all caps) followed by usergroup id, or (id1|id2|id3) vanish('GROUP4','(board1|board2|board3)'); vanish('GROUP(4|5|6)','secretstuff'); */ // put vanish calls for your site below:
// --> </script>
Preview: well.. it hides the board so you cant really see a preview.
|
|
Matt
Junior Member
Yep, I like making websites. Websites made: 5
Posts: 61
Matt said 0 great things
|
Post by Matt on Sept 18, 2009 2:39:41 GMT -8
Hi,
Can i use your code to hide a board from every member group except 1. EG: I have a Staff Area, and i have 3 boards: Admins, Global Moderators & Moderators, I want to haveonly the Admins to see the Admins board, Admins and Global moderators to see the Global Moderators board and all three Staff groupps to see the last. can your code do that or do i have to Make my own.
Matt
|
|
|
Post by Wormopolis on Sept 18, 2009 18:09:35 GMT -8
currently as written does not utilize group names. a minor modification would have to be made to go by group IDs.
|
|
Matt
Junior Member
Yep, I like making websites. Websites made: 5
Posts: 61
Matt said 0 great things
|
Post by Matt on Sept 19, 2009 14:18:58 GMT -8
oh ok.
|
|
|
Post by Wormopolis on Sept 19, 2009 15:14:42 GMT -8
the thing about group IDs, is that they arent available in the PB source variables. To get a member's group, you would have to scan the page looking for their username, then grab it from the class of the link its contained in. THEN you have to store it in a cookie if you want to be able to access it on other pages. I used this method with the postChoke code, so Im sure I coudl do it here as well.
|
|
|
Post by Dragon on Apr 10, 2011 10:20:15 GMT -8
How do you edit it so only the main admin or in my case, my username be able to see it? I have my account as technically the functions of the main admin, but the real admin main admin account isnt used unless neccessary....
|
|
|
Post by Wormopolis on Apr 10, 2011 13:24:02 GMT -8
what username?
|
|
|
Post by Dragon on Apr 10, 2011 16:26:03 GMT -8
well MY username in this case is: dragon
|
|
|
Post by Wormopolis on Apr 10, 2011 17:49:09 GMT -8
vanish(/^dragon$/,'ladiesonly');
|
|
|
Post by Dragon on Apr 11, 2011 5:36:54 GMT -8
errr... ladies only? O.o lol
|
|
|
Post by Wormopolis on Apr 11, 2011 10:51:05 GMT -8
whatever the board name is.. that was just what I copied from the text.
|
|
|
Post by Dragon on Apr 11, 2011 18:58:05 GMT -8
So with this Ill be able to hide the category boards I put down as "hidden boards" because I dont want members but me to see them? If so, thank you very much
|
|
|
Post by Wormopolis on Apr 12, 2011 14:39:38 GMT -8
the board should be hidden from everyone except the username dragon.
|
|
|
Post by Dragon on Apr 14, 2011 7:54:57 GMT -8
Thanks Worm.
Though now that I think about it, wouldnt it require me to put in that code for every hidden board? Thats a lot of coding if so and would likely slow things down. Is there anyway I can use that code for multiple pages without repeating the code per board? o.o Or edit it so it does multiple boards with only 1 set of code?
|
|
|
Post by Wormopolis on Apr 14, 2011 8:26:02 GMT -8
if you have full categories of boards, it would be more secure to just hide the category to everyone except your usergroup.
or just hide the board in the board settings and use the direct URL to get in.
this code was meant for a single or few boards.. not entire forums.
|
|