vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Using Usergroup ID's to allow/deny Permisson question (https://vborg.vbsupport.ru/showthread.php?t=202860)

haxcommunity 01-23-2009 08:23 PM

Using Usergroup ID's to allow/deny Permisson question
 
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:

PHP Code:

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

// Some Code



OR

PHP Code:

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

// Some Code



Obviously X needs replacing with the group :)

Lynne 01-23-2009 09:36 PM

PHP Code:

if (!isset($vbulletin->userinfo['userid']) OR $vbulletin->userinfo['userid'] == 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:

PHP Code:

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

if (!isset(
$vbulletin->userinfo['userid']) OR $vbulletin->userinfo['userid'] == 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

Quote:

Originally Posted by Lynne (Post 1723784)
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

PHP Code:

chdir('/path/to/your/forums');
require_once(
'./global.php'); 


Dismounted 01-25-2009 03:05 AM

PHP Code:

chdir('./forum/');
require_once(
'./global.php');

if (!
is_member_of($vbulletin->userinfo20))
{
    
print_no_permission();



King Justice 01-25-2009 01:37 PM

Quote:

Originally Posted by Dismounted (Post 1723890)
PHP Code:

chdir('./forum/');
require_once(
'./global.php');

if (!
is_member_of($vbulletin->userinfo20))
{
    
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) or [How-To] vBulletin API Basics: Creating Custom Pages & Misc.

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

Quote:

Originally Posted by King Justice (Post 1724246)
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

Quote:

Originally Posted by Lynne (Post 1725322)
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

Quote:

Originally Posted by Ewan McLean (Post 1725417)
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.


All times are GMT. The time now is 03:37 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01121 seconds
  • Memory Usage 1,785KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (28)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete