PDA

View Full Version : Using Usergroup ID's to allow/deny Permisson question


haxcommunity
01-23-2009, 08:23 PM
I'm making a seperate PHP based page, what code can I use to allow/deny access to the page based on a usergroup ID?

m002.p
01-23-2009, 09:27 PM
Hi once calling /global.php try using the following code:

if ($vbulletin->userinfo['usergroupid'] == x)
{

// Some Code

}

OR

if (is_member_of($vbulletin->userinfo,X))
{

// Some Code

}

Obviously X needs replacing with the group :)

Lynne
01-23-2009, 09:36 PM
if (!isset($vbulletin->userinfo['userid']) OR $vbulletin->userinfo['userid'] == 0 OR !is_member_of($vbulletin->userinfo,x,y,z))
{
print_no_permission();
}

haxcommunity
01-23-2009, 09:38 PM
Thanks guys, all fixed ;)

King Justice
01-24-2009, 10:37 PM
Hello, please help, not working for me:


include("./forum/global.php");

if (!isset($vbulletin->userinfo['userid']) OR $vbulletin->userinfo['userid'] == 0 OR !is_member_of($vbulletin->userinfo,20))
{
print_no_permission();
}

Lynne
01-24-2009, 11:01 PM
And what is happening instead?

You should do a chdir before including global instead of the way you did it.

King Justice
01-25-2009, 01:33 AM
And what is happening instead?

You should do a chdir before including global instead of the way you did it.
What's a chdir?
And the page breaks and doesn't work..

Please help..

Lynne
01-25-2009, 02:53 AM
chdir('/path/to/your/forums');
require_once('./global.php');

Dismounted
01-25-2009, 03:05 AM
chdir('./forum/');
require_once('./global.php');

if (!is_member_of($vbulletin->userinfo, 20))
{
print_no_permission();
}

King Justice
01-25-2009, 01:37 PM
chdir('./forum/');
require_once('./global.php');

if (!is_member_of($vbulletin->userinfo, 20))
{
print_no_permission();
}
Used that but page is still breaking... :o

Lynne
01-25-2009, 03:12 PM
Post your code and please use the code/html/php tags when you do so it's easy to read.

King Justice
01-25-2009, 10:15 PM
Err can't really post the code..but I'm using it exactly as above?
I have more PHP scripting going on to pull info out of the database as well because that's what the script is for...premium usergroups...and this is a script only they should be able to see.

Please help

Lynne
01-25-2009, 10:36 PM
Sorry, all I can suggest then is that you have something wrong in your code. I've used those same lines in my homemade pages and they work just fine as long as the rest of the page is coded correctly and all the paths to the files are correct. Did you do your page using one of these articles as a template? How to create your own vBulletin-powered page! (uses vB templates) (https://vborg.vbsupport.ru/showthread.php?t=62164) or [How-To] vBulletin API Basics: Creating Custom Pages & Misc. (https://vborg.vbsupport.ru/showthread.php?t=98009)

King Justice
01-26-2009, 01:33 AM
No..this page is in the root directory of my site...not the forum directory... :) :\

Lynne
01-26-2009, 02:43 AM
So? I don't understand why that changes anything? You do exactly what the article says only do the chdir before requiring the globals (like we did above).

Dismounted
01-26-2009, 03:46 AM
Used that but page is still breaking... :o
How is it "breaking"? (i.e. what is happening)

King Justice
01-26-2009, 03:25 PM
The PHP code should be in the <body> tag right?
I'm putting it in the PHP code just above the script, which pulls info out of the database..

The PHP code that you gave me makes the script break and the HTML code break as well..without he PHP code you gave me, the script works though. :o

Lynne
01-26-2009, 03:29 PM
php code should be in the php file, not in any html area.

King Justice
01-26-2009, 03:34 PM
What?..
It's in a .php file if that's what you mean?..
Are you saying this script should have it's own file ??..

Lynne
01-26-2009, 03:52 PM
But you said you put it in the <body> tag - in the html area of your page. It has to be within the php tag part of your page. Like at the top after you do a require of the global.php page.

Ewan McLean
01-26-2009, 05:45 PM
But you said you put it in the <body> tag - in the html area of your page. It has to be within the php tag part of your page. Like at the top after you do a require of the global.php page.

PHP can be opened/closed anywhere within the html document though, as long as you specify your statements within a <?php?> tag.

King Justice
01-26-2009, 09:18 PM
Yes the person above me works within my company and his statement is true. :)

Please assist. Also, PHP Safe Mode is on I believe..if that has anything to do with it.

Lynne
01-26-2009, 10:58 PM
I'm sorry, but since you won't post the code, I'm not sure what else to suggest.

Dismounted
01-27-2009, 03:09 AM
PHP can be opened/closed anywhere within the html document though, as long as you specify your statements within a <?php?> tag.
Lynne is talking in the context of vBulletin and its templating engine. vBulletin does not allow PHP in templates.

King Justice
01-27-2009, 04:12 PM
Dismounted, this page is not in vB...it's not in the forum directory at all, and isn't a vB template. :o It's just a page on the root directory of the site...that we want to protect so that only certain usergroups we specify can see it.

Lynne
01-27-2009, 04:38 PM
OK, I'll repeat what I said before. Those lines of code should go just after you include global.php - before you start spitting out any html.

derfy
01-28-2009, 12:54 AM
Let me try (I'm another admin on the site)

We're using a CMS. We have a page that I wrote using PHP to pull out vB's ban info. When we try and include('./forum/global.php'), it breaks. The page stops executing and no output past the include() is printed. No error message is printed, as well.

I *think* it's either a file perm issue or open_basedir.

Neg on open_basedir.

Chdir'ing to our forums dir and requiring from there produces the same results.

I'm begining to lean toward a safe mode issue...

Dismounted
01-28-2009, 04:21 AM
My guess is that vBulletin is conflicting with the CMS. There is probably some variables that are named the same, and therefore, it breaks.