PDA

View Full Version : Guests cannot view threads


LanciaStratos
09-08-2001, 05:24 PM
I want to block guests from viewing individual topics. (e.g. A guest enters the forum home page, clicks on a forum, sees the topic titles, click on a topic title, and is then asked to log-in or register.)

I know that there is a similar option in the AdminCP that prevents guests from "viewing other's topics", but it makes each forum appear blank, as if there were no topics at all. :(

Hopefully someone can help, as I believe this would be a hack that others would appreciate as well. :)

tweak
09-08-2001, 09:20 PM
All done in your CNTRL panel

User Groups and Permissions
Add | Modify
Modify forums <-------HERE

LanciaStratos
09-09-2001, 02:38 AM
Tweak, please read my post again.

I know that there is a similar option in the AdminCP that prevents guests from "viewing other's topics", but it makes each forum appear blank, as if there were no topics at all.This is the "similar option" that I'm mentioning, and that's the effect that it creates (which isn't what I want).

showthread.php is really the only thing I don't want guests to see...

Admin
09-09-2001, 08:07 AM
Try this.
In your showthread.php, add the code in red
error_reporting(7);
if ( isset($goto) and ($goto=='lastpost' or $goto=='newpost')) {
$noheader=1;
}

if ($bbuserinfo[userid]!=0) {
and also this
getforumrules($forum,$getperms);
eval("dooutput(\"".gettemplate("showthread")."\");");

} else {
show_nopermission();
}
This should work (untested).

LanciaStratos
09-09-2001, 05:12 PM
Thanks FireFly, but it didn't work. :( Showthread.php only returned this error:

Fatal error: Call to undefined function: show_nopermission() in /home/gtplanet/public_html/forums/showthread.php on line 442

Admin
09-09-2001, 05:14 PM
Oh right, global.php was yet to be included. I'll work something out and post it here. :)

LanciaStratos
09-09-2001, 05:15 PM
Sounds great, thanks! :)

Admin
09-09-2001, 05:18 PM
Undo all changes. :)

Add the code in red in all 4 places.
include('./global.php');

if ($bbuserinfo[userid]!=0) {

if (isset($postid) and $postid!=0 and $postid!="") {
$postid = verifyid("post",$postid);

$getthread=$DB_site->query_first("SELECT threadid FROM post WHERE postid='$postid'");
$threadid=$getthread[threadid];
}
eval("dooutput(\"".gettemplate("showpost")."\");");
exit;
} else {
show_nopermission();
}
require('./global.php');

if ($bbuserinfo[userid]!=0) {

// oldest first or newest first
if ($postorder==0) {
$postorder="";
} else {
$postorder="DESC";
}
getforumrules($forum,$getperms);
eval("dooutput(\"".gettemplate("showthread")."\");");
} else {
show_nopermission();
}
Now it has to work. :)

LanciaStratos
09-09-2001, 05:40 PM
Uh-oh, now I'm getting a new error:

Parse error: parse error in /home/gtplanet/public_html/forums/showthread.php on line 448

I'm almost positive I placed the code in all the right places, I've checked and re-checked. But, here's a copy of my (modified) showthread.php file, if you'd like to look at it.

Admin
09-09-2001, 05:42 PM
You dropped one } right before that ### block that says showthread.

(also remove that file)

LanciaStratos
09-09-2001, 05:54 PM
Ah, it works like a charm! You are the man, and I appreciate all your help! :D

(also remove that file)Oops...I hadn't even thought about that. :eek: Thanks for letting me know!

amykhar
09-10-2001, 11:41 PM
Any way this could be set up on a forum by forum basis? I only have a handful of forums that guests are not allowed to read. The rest are open to lurkers in order to lure in new members.

I know, I am a royal pain :D I guess I just like to do things the hard way.

Amy

p.s. Firefly you have been cranking out some darn good stuff lately. Thank you for your efforts.

Admin
09-11-2001, 12:04 PM
Thanks amykhar. :)

To do it per forum, undo all changes you (might) did to showthread.php.

Now, add what's in red (in showthread.php):
$forum=getforuminfo($thread['forumid']);

if ($bbuserinfo[userid]==0 and ($thread['forumid']!=1 or $thread['forumid']!=2 or $thread['forumid']!=3 or $thread['forumid']!=4)) {
show_nopermission();
}
Note: appears twice, add in both places.
This will prevent all guests from viewing threads in forums 1, 2, 3 and 4.

LanciaStratos, undo all changes.
Add what's in red:
$forum=getforuminfo($thread['forumid']);

if ($bbuserinfo[userid]==0) {
show_nopermission();
}
Same note, do it twice.
(no difference, just "nicer")

amykhar
09-12-2001, 01:53 PM
One small oops firefly :)

$thread['forumid']!=1 should be $thread['forumid']==1

(and for the other forums as well).

It works like a charm though. Thank you.

See it in action:

http://www.eaforums.com/forumdisplay.php?forumid=28


Amy

Admin
09-12-2001, 02:01 PM
D'oh, of course. :)
You're welcome.

Scott MacVicar
09-12-2001, 02:54 PM
The ability to ban certain user groups from certain forums is already integrated in to vBulletin.

Within the Admin Panel there is a Groups are Permissions section, click the "modify forums" part and you can edit access permission for certain user groups within certain forums. Which includes stopping them from reading posts within certain forums.

Admin
09-12-2001, 03:16 PM
Yes, but
[QUOTE]Originally posted by LanciaStratos
I know that there is a similar option in the AdminCP that prevents guests from "viewing other's topics", but it makes each forum appear blank, as if there were no topics at all. :(

Scott MacVicar
09-12-2001, 07:18 PM
simply remove
if (!$getperms[canviewothers]) {
$limitothers="AND postuserid='$bbuserinfo[userid]'";
}

from forumdisplay.php
around line 276.

There is something similar to that in viewthread.php so settings Can View Others to NO will allow them to view a list of threads but not the thread itself.

I already removed those 3 lines from my board as it was an annoyance.

LanciaStratos
09-12-2001, 11:51 PM
Originally posted by PPN
simply remove
if (!$getperms[canviewothers]) {
$limitothers="AND postuserid='$bbuserinfo[userid]'";
}

from forumdisplay.php
around line 276.

There is something similar to that in viewthread.php so settings Can View Others to NO will allow them to view a list of threads but not the thread itself.

I already removed those 3 lines from my board as it was an annoyance. Ah, that also works very well! :)

NYI Fan
11-04-2001, 07:22 PM
Hi all

I had Firefly's tweak working perfectly in 2.0.3, but now in 2.2.0 no go
The fix may be obvious, but I can't seem to get it working again...

any help would be most appreciated!

(I think i goofed and posted this in the wrong place - if so can a mod please move it to correct forum for me? Sorry!!)

Scott MacVicar
11-04-2001, 08:02 PM
Mine will work on vb 2.2.0

its located on line 306-308 now and its changed format

looks like

if (!$getperms[canviewothers]) {
$limitothers="AND postuserid='$bbuserinfo[userid]'";
}

NYI Fan
11-04-2001, 08:10 PM
Thanks PPN
will try that

any specific directions I need, other than what you posted??

Scott MacVicar
11-04-2001, 08:23 PM
Go to the guest permissions and set Can View Others to NO.

This will stop guests from viewing threads in all forums but they can see the thread titles.

NYI Fan
11-04-2001, 08:39 PM
Worked like a charm!

Thanks much!

Scott MacVicar
11-04-2001, 09:51 PM
look at
https://vborg.vbsupport.ru/showthread.php?s=&threadid=32132

for a better solution, this allows you to turn it on in a forum by forum basis.

freakyshiat
10-27-2002, 06:20 AM
I need to restric usergroup 0 and 4.
How can i change this to add 0 and 4?

if ($bbuserinfo[userid]==0) {
show_nopermission();
}