Post by SubDevo on Jun 21, 2009 15:05:32 GMT -8
Guests Cannot Search or View Profiles by SubDevo
Tested in IE, FF and Opera.
I know you are saying, "Not another Guests can't view profiles code!", just read on...
This code is an "enhanced" version of my Guests Cannot View Profiles code.
I had a different approach this time. Instead of catching when a guest tries to search/view profile, this code simply replaces the URL in all Search and/or member's Display Name links, to redirect the guest to whatever page you want them to see.
This is the login page by default. But you can use ANY URL. A neat trick is to create a hidden board and make a locked thread with a message about your forum inviting them to join.
Preview:
Go HERE and try to search or view a profile. Look through some threads. Kick the tires!
You can also optionally hide non-staff member name links and/or Search links. These items will be hidden on every page that they appear. Even if they are hidden, the link still points to your guest "error" page.
If a guest enters the direct URL to a profile or search page, the code will still catch it. This time, presenting the guest with a blank page and an alert box with a message you provide.
Enjoy!!!
SubDevo
Edit the Maroon sections:
var eMsg='Sorry, You do not have Permission to Access this Area.\nPlease Click "Back" to Continue.';
var gProf=[0,1]; // Guests can View Profiles? , Hide Non-Staff? 1=Yes, 0=No.
Code:
<script type="text/javascript">
/* Guests Cannot Search or View Profiles by SubDevo */
/* Global Footer - Please leave this header intact. Do not repost. */
/* interoceandesigns.com or lsdp.proboards.com */
var gMsg='Sorry, You do not have Permission to Access this Area.\nPlease Click "Back" to Continue.';
var gSrch=[0,0]; // Guests can Search? , Hide Search Link? 1=Yes, 0=No.
var gProf=[0,1]; // Guests can View Profiles? , Hide Non-Staff? 1=Yes, 0=No.
var gURL="/index.cgi?action=login"; // URL to "Error" page for Guests.
function rLink(a,b,c,d){
if(!b[0]&&c.test(a.href)){a.href=gURL;
if(b[1]){if(!d||(d&&a.className=="group0")){a.style.display="none"; if(d){a.innerHTML="";}}}
}}
if(pb_username=="Guest"){ var b=(location.href.indexOf("n=newestth")!=-1)?1:0;
if(!gProf[0]&&pb_action=="viewprofile"||(!gSrch[0]&&(/^search(2)?$/).test(pb_action)||b)){
var tb=document.getElementsByTagName("table"),x=3;
while(tb[++x]){tb[x].style.display="none";} alert(gMsg);
}else{
var n=document.links,nx=/viewprofile&user=/i,ns=/n=(search|recent|newestt)/i,x=-1;
while(n[++x]){rLink(n[x],gSrch,ns,0); rLink(n[x],gProf,nx,1);}
}}
</script>
DISCLAIMER:
It is still possible to view profiles and/or search a forum (even with this code) if you have the knowledge. This code helps deter gleening your member's info by making it less convenient for the snoopy casual users. The only way to make sure this info is completely blocked is server side... That means making your forum members only. This code just bridges the gap between completely no guests and open to guests, while still giving some privacy to your members info.
(1/18/2011) EDIT:
Code updated to block the new "New Topics" feature if searching by guests is not allowed.
Tested in IE, FF and Opera.
I know you are saying, "Not another Guests can't view profiles code!", just read on...
This code is an "enhanced" version of my Guests Cannot View Profiles code.
I had a different approach this time. Instead of catching when a guest tries to search/view profile, this code simply replaces the URL in all Search and/or member's Display Name links, to redirect the guest to whatever page you want them to see.
This is the login page by default. But you can use ANY URL. A neat trick is to create a hidden board and make a locked thread with a message about your forum inviting them to join.
Preview:
Go HERE and try to search or view a profile. Look through some threads. Kick the tires!
You can also optionally hide non-staff member name links and/or Search links. These items will be hidden on every page that they appear. Even if they are hidden, the link still points to your guest "error" page.
If a guest enters the direct URL to a profile or search page, the code will still catch it. This time, presenting the guest with a blank page and an alert box with a message you provide.
Enjoy!!!
SubDevo
Edit the Maroon sections:
var eMsg='Sorry, You do not have Permission to Access this Area.\nPlease Click "Back" to Continue.';
The alert message that will be shown to guests, if they try to view a profile or search, by using the direct URL.var gSrch=[0,0]; // Guests can Search? , Hide Search Link? 1=Yes, 0=No.
var gProf=[0,1]; // Guests can View Profiles? , Hide Non-Staff? 1=Yes, 0=No.
You have two options in each of the above variables. Use 1=Yes, 0=No for these.var gURL="/index.cgi?action=login"; // URL to "Error" page for Guests.
The first is allow/disallow viewing. The second is hide/show the links.
URL to the page where guests will be redirected if not allowed to search and/or view profiles.Location: Global Footer
Code:
<script type="text/javascript">
/* Guests Cannot Search or View Profiles by SubDevo */
/* Global Footer - Please leave this header intact. Do not repost. */
/* interoceandesigns.com or lsdp.proboards.com */
var gMsg='Sorry, You do not have Permission to Access this Area.\nPlease Click "Back" to Continue.';
var gSrch=[0,0]; // Guests can Search? , Hide Search Link? 1=Yes, 0=No.
var gProf=[0,1]; // Guests can View Profiles? , Hide Non-Staff? 1=Yes, 0=No.
var gURL="/index.cgi?action=login"; // URL to "Error" page for Guests.
function rLink(a,b,c,d){
if(!b[0]&&c.test(a.href)){a.href=gURL;
if(b[1]){if(!d||(d&&a.className=="group0")){a.style.display="none"; if(d){a.innerHTML="";}}}
}}
if(pb_username=="Guest"){ var b=(location.href.indexOf("n=newestth")!=-1)?1:0;
if(!gProf[0]&&pb_action=="viewprofile"||(!gSrch[0]&&(/^search(2)?$/).test(pb_action)||b)){
var tb=document.getElementsByTagName("table"),x=3;
while(tb[++x]){tb[x].style.display="none";} alert(gMsg);
}else{
var n=document.links,nx=/viewprofile&user=/i,ns=/n=(search|recent|newestt)/i,x=-1;
while(n[++x]){rLink(n[x],gSrch,ns,0); rLink(n[x],gProf,nx,1);}
}}
</script>
DISCLAIMER:
It is still possible to view profiles and/or search a forum (even with this code) if you have the knowledge. This code helps deter gleening your member's info by making it less convenient for the snoopy casual users. The only way to make sure this info is completely blocked is server side... That means making your forum members only. This code just bridges the gap between completely no guests and open to guests, while still giving some privacy to your members info.
(1/18/2011) EDIT:
Code updated to block the new "New Topics" feature if searching by guests is not allowed.