Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-19-2007, 01:25 PM
squishi squishi is offline
 
Join Date: May 2006
Location: Frankfurt
Posts: 282
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default $vbulletin->userinfo['usergroupid']

I need some help with coding.
I use the mod "login simple v1.10" in a non-vb page.

Code:
<?php
if ($vbulletin->userinfo['usergroupid'] == '17' )
	{
	echo "This is only visible to people in usergroup 17";
	}
?>

<br /><br />

<?php
if ($vbulletin->userinfo['usergroupid'] == '2' )
	{
	echo "This is only visible to registered users";
	}
?>
Usergroup 17 is a custom usergroup with only additional members and no primary members.
Usergroup 2 is the usual registered member group.

With a user who visits this page, only the second if-statement works.
Testing the usergroup 17 doesn't work.

What to do? Checking Usergroup 17 is what I want to do.
Reply With Quote
  #2  
Old 10-19-2007, 02:02 PM
Andrew Green's Avatar
Andrew Green Andrew Green is offline
 
Join Date: Nov 2005
Location: Winnipeg, MB
Posts: 996
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try this:

Code:
if (! is_member_of($vbulletin->userinfo, 17))
{
	print_no_permission();
}
Reply With Quote
  #3  
Old 10-19-2007, 03:52 PM
squishi squishi is offline
 
Join Date: May 2006
Location: Frankfurt
Posts: 282
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This didn't work.

I want to check if the user is in usergroup 17 and show him the content of the page if it is true.

--------------- Added [DATE]1192813103[/DATE] at [TIME]1192813103[/TIME] ---------------

Okay, I modded it slightly and it works. :up:
Thanks.

--------------- Added [DATE]1192822078[/DATE] at [TIME]1192822078[/TIME] ---------------

I ran into another problem:
I want to load a file for the members of the usergroup 17.

The code looks like this:



If I remove the code between the //*** and remove the if statements, the file is loaded.
But it seems the header function collides with something in the forum's global.php?
I tried to puffer the output with ob_start / ob_flush, but it didn't work.
The script is doing nothing.
Reply With Quote
  #4  
Old 10-20-2007, 12:13 PM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You're going to have to include the global.php file in order to use vBulletin's functions.
Reply With Quote
  #5  
Old 10-20-2007, 02:26 PM
Analogpoint's Avatar
Analogpoint Analogpoint is offline
 
Join Date: Feb 2007
Posts: 656
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Remove exit; (both of them.)
Reply With Quote
  #6  
Old 10-21-2007, 10:49 AM
cagatayh cagatayh is offline
 
Join Date: Aug 2006
Posts: 70
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

https://vborg.vbsupport.ru/showthread.php?t=160679

I want to do another thing. I want to

<?php
if ($vbulletin->forum['forumno'] == '67 ) like that...

for example;https://vborg.vbsupport.ru/forumdisplay.php?f=15

<?php
if ($vbulletin->forum['forumno'] == '15 ) like that...
Reply With Quote
  #7  
Old 10-21-2007, 08:30 PM
squishi squishi is offline
 
Join Date: May 2006
Location: Frankfurt
Posts: 282
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dismounted View Post
You're going to have to include the global.php file in order to use vBulletin's functions.
Okay, I have replaced the "require_once" with "include" and removed the exits, but the script still does not produce any result.
Reply With Quote
  #8  
Old 10-21-2007, 10:01 PM
Analogpoint's Avatar
Analogpoint Analogpoint is offline
 
Join Date: Feb 2007
Posts: 656
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by squishi View Post
Okay, I have replaced the "require_once" with "include" and removed the exits, but the script still does not produce any result.
require_once does the same as include, except how it handles it if the file is not found, or if you try to include it more than once.

Post your code as you now have it.
Reply With Quote
  #9  
Old 10-22-2007, 07:35 AM
squishi squishi is offline
 
Join Date: May 2006
Location: Frankfurt
Posts: 282
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here's the full code (with changed paths):

If I leave out the global.php include and remove the usergroup check, the movies are loading...
Reply With Quote
  #10  
Old 10-22-2007, 02:22 PM
Analogpoint's Avatar
Analogpoint Analogpoint is offline
 
Join Date: Feb 2007
Posts: 656
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try something like this. (untested)

PHP Code:
<?php

$curdir 
getcwd ();
chdir('/home/myforumpath.com/forum');
@include(
'/home/myforumpath.com/forum/global.php');
chdir ($curdir);

if (!
$vbulletin->userinfo['userid'])
{
    
// not logged in
    
echo "<html>";
    echo 
"<head>";
    echo 
"<title>";
    echo 
"Restricted Area";
    echo 
"</title>";
    echo 
"</head>";
    echo 
"<body>";
    @require_once(
'/home/pathtomyforum/login_inc.php'); //login_inc.php shows a login panel
    
echo "<br />Access only for members of group 17.";
    echo 
"</body>";
    echo 
"</html>";
}
else
{
    
// logged in
    
if (!is_member_of($vbulletin->userinfo17))
    {
        
// not a member of group 17
        
echo "<html>";
        echo 
"<head>";
        echo 
"<title>";
        echo 
"Restricted Area";
        echo 
"</title>";
        echo 
"</head>";
        echo 
"<body>";
        echo 
"<br />Access only for members of group 17.";
        echo 
"</body>";
        echo 
"</html>";
    }
    else
    {
        
// show the movies
        
$id intval($_GET['id']);
        switch (
$id) {
            case 
1:
                
$file "movies/showitifid1.avi";
                
$content_len = @filesize($file);
                
header("Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0"); // HTTP/1.1
                
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Datum in der Vergangenheit
                
header('Pragma: no-cache'); //HTTP/1.0
                
header("Content-type: video/x-msvideo");
                
header("Content-type: octet-stream");
                
header('Content-Disposition: attachment; filename="'.$file.'"');
                if(
$content_len!=FALSE)
                {
                    
header("Content-length: $content_len");
                }
                
readfile($file);
                break;
            
            case 
2:
                
$file "movies/showitifid2.avi";
                
$content_len = @filesize($file);
                
header("Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0"); // HTTP/1.1
                
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Datum in der Vergangenheit
                
header('Pragma: no-cache'); //HTTP/1.0
                
header("Content-type: video/x-msvideo");
                
header("Content-type: octet-stream");
                
header('Content-Disposition: attachment; filename="'.$file.'"');
                if(
$content_len!=FALSE)
                {
                    
header("Content-length: $content_len");
                }
                
readfile($file);
                break;
        }
    }
}

?>
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:18 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.04255 seconds
  • Memory Usage 2,285KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete