vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Allowing only certain users to visit script (https://vborg.vbsupport.ru/showthread.php?t=163714)

BamaStangGuy 11-27-2007 11:07 AM

Allowing only certain users to visit script
 
I have a new product I am creating and one of the setting options allows you to add userids, seperated by a comma, that you want to have access to the script.

How can I take those userids and compare them to the current users id trying to access the script to make sure that they match?

Right now this isn't working:

PHP Code:

$aids explode(',',$vbulletin->options['users_allowed']);
if ((!
$vbulletin->options['vbincome_enabled']) OR in_array($bbuserinfo[userid], $aids))
{
    
print_no_permission();


What is the correct way to do this?

jwocky 11-27-2007 05:22 PM

Do you want to check the user who is currently viewing the script and decide if that user is allowed to view the script?

Opserty 11-27-2007 05:24 PM

Use $vbulletin->userinfo['userid'] instead of $bbuserinfo[userid]

I think you need to add a not (!) before the in_array().

BamaStangGuy 11-28-2007 09:05 AM

Quote:

Originally Posted by jwocky (Post 1390456)
Do you want to check the user who is currently viewing the script and decide if that user is allowed to view the script?

Yes

Quote:

Originally Posted by Opserty (Post 1390460)
Use $vbulletin->userinfo['userid'] instead of $bbuserinfo[userid]

I think you need to add a not (!) before the in_array().

Thanks I'll give that a go.

Dean C 11-28-2007 09:39 AM

What!? You mean vBSEO doesn't do all of this for you and more :rolleyes: ;)

PHP Code:

$aids explode(',',$vbulletin->options['users_allowed']);
if (!empty(
$vbulletin->options['vbincome_enabled']) OR !in_array($bbuserinfo[userid], $aids))
{
    
print_no_permission();


Checking for !($value) will match false, as the poster below me pointed out.

Opserty 11-28-2007 10:58 AM

Are you sure you can use isset there? Because even if the option is set to say, false it will still read that the variable is set, won't it?

Dean C 11-28-2007 11:02 AM

Quote:

Originally Posted by Opserty (Post 1390938)
Are you sure you can use isset there? Because even if the option is set to say, false it will still read that the variable is set, won't it?

Woopsie, too used to checking to see if array keys exist :)


All times are GMT. The time now is 08:19 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.01020 seconds
  • Memory Usage 1,730KB
  • 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
  • (2)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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