Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-19-2004, 06:13 PM
dontpanic dontpanic is offline
 
Join Date: Jun 2003
Posts: 145
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Controlling access to external pages via vB credentials

In vB 2.x I was able to use this code to control access to a page based on member group.
PHP Code:
<?php
error_reporting
(7);

require(
'./global.php');

if (
$bbuserinfo[usergroupid]=="1" or $bbuserinfo[usergroupid]=="3" or $bbuserinfo[usergroupid]=="0") {
      eval(
"dooutput(\"".gettemplate('newsletter_subscribe_error')."\");");
      }else{        
eval(
"dooutput(\"".gettemplate('newsletter_subscribe')."\");");
}
exit;

?>
I'm missing something when I try to convert it over....can someone please show me what this should look like to accomplish the same basic goal in vB 3.x?

Thanks!
Reply With Quote
  #2  
Old 02-19-2004, 06:19 PM
assassingod's Avatar
assassingod assassingod is offline
 
Join Date: Jul 2002
Posts: 3,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Most of the variables and functions have changed in vB3 now, you should use something like
PHP Code:
 <?php
     error_reporting
(E_ALL & ~E_NOTICE);
      require(
"./global.php");
      
      
$globaltemplates = array(
          
'newsletter_subscribe_error',
          
'newsletter_subscribe'
      
);
      
      if(
in_array($bbuserinfo['usergroupid'], array(0,1,3)))
      {
          eval(
'print_output("' fetch_template('newsletter_subscribe_error') . '");');
      }
      else
      {
          eval(
'print_output("' fetch_template('newsletter_subscribe') . '");');
      }
  
?>
Reply With Quote
  #3  
Old 02-19-2004, 06:25 PM
dontpanic dontpanic is offline
 
Join Date: Jun 2003
Posts: 145
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, lemme try it out and I'll let you know how it went.

Thanks!
Reply With Quote
  #4  
Old 02-19-2004, 06:25 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Should that be require_once ? :P
Reply With Quote
  #5  
Old 02-19-2004, 06:27 PM
assassingod's Avatar
assassingod assassingod is offline
 
Join Date: Jul 2002
Posts: 3,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It doesn't have to but yes it can be.
Reply With Quote
  #6  
Old 02-19-2004, 06:44 PM
dontpanic dontpanic is offline
 
Join Date: Jun 2003
Posts: 145
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, works like a charm. I just dropped the correct code into a pre-existing page as you can see:
PHP Code:
<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS'1);
define('THIS_SCRIPT''index');

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// pre-cache templates used by all actions
$globaltemplates = array(
    
'navbar',
    
'flash1',
    
'STANDARD_ERROR'
);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once(
'./includes/functions_bigthree.php');
require_once(
'./includes/functions_forumlist.php');

// ### ALL DONE! SPIT OUT THE HTML AND LET'S GET OUTA HERE... ###

      
if(in_array($bbuserinfo['usergroupid'], array(6,11)))
      {
          eval(
'$navbar = "' fetch_template('navbar') . '";');
          eval(
'print_output("' fetch_template('flash1') . '");');
      }
      else
      {
          eval(
'print_output("' fetch_template('STANDARD_ERROR') . '");');
      }
?>
If we are evaluating members who's primary user group is 6 or 11, it works great. That's administrators and a subscription group. However, if you are a member of the subscription group (11) and its a secondary group, it does not work correctly, you fall into the else statement. Thoughts?
Reply With Quote
  #7  
Old 02-19-2004, 06:54 PM
assassingod's Avatar
assassingod assassingod is offline
 
Join Date: Jul 2002
Posts: 3,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can't think why that's happening. Also, theres unnessacary code in that script
(Unless you need to require bigthree.php and forumlist.php)
Reply With Quote
  #8  
Old 02-19-2004, 06:59 PM
dontpanic dontpanic is offline
 
Join Date: Jun 2003
Posts: 145
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, I got rid of those two requires...I didn't notice them at first. The only solution I see is to have the subscription event change the primary user group from 1 to 11 instead of configuring it as a secondary user group....I can't see that this would be a problem, but I'm not sure.
Reply With Quote
  #9  
Old 02-19-2004, 07:00 PM
assassingod's Avatar
assassingod assassingod is offline
 
Join Date: Jul 2002
Posts: 3,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What I would do is use 1 print_output and use the fetch_templates in each if section.

E.g;
PHP Code:
 <?php
 
 
// ####################### SET PHP ENVIRONMENT ###########################
 
error_reporting(E_ALL & ~E_NOTICE);
 
 
// #################### DEFINE IMPORTANT CONSTANTS #######################
 
define('NO_REGISTER_GLOBALS'1);
 
define('THIS_SCRIPT''pagename');
 
 
// ################### PRE-CACHE TEMPLATES AND DATA ######################
 // pre-cache templates used by all actions
 
$globaltemplates = array(
     
'navbar',
     
'flash1',
     
'STANDARD_ERROR'
 
);
 
 
// ######################### REQUIRE BACK-END ############################
 
require_once('./global.php');
 
 
 
// ### ALL DONE! SPIT OUT THE HTML AND LET'S GET OUTA HERE... ###
 
       
if(in_array($bbuserinfo['usergroupid'], array(6,11)))
       {
       eval(
'$var1 = "' fetch_template('template-for-usergroupids-specified') . '";');
       }
       else
       {
       eval(
'$var1 = "' fetch_template('template-for-everyone-else') . '";');
       }
       
       eval(
'$navbar = "' fetch_template('navbar') . '";');
       eval(
'print_output("' fetch_template('main-template-here') . '");');
 
?>
Then use $var1 in the main-template-here template.
Reply With Quote
  #10  
Old 02-19-2004, 07:04 PM
assassingod's Avatar
assassingod assassingod is offline
 
Join Date: Jul 2002
Posts: 3,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

^Recheck my post
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 12:52 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08388 seconds
  • Memory Usage 2,281KB
  • 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
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)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_postinfo_query
  • fetch_postinfo
  • 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