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

Reply
 
Thread Tools Display Modes
  #1  
Old 12-28-2004, 06:24 AM
thephonemall thephonemall is offline
 
Join Date: Oct 2004
Posts: 40
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Add VB login to custom pages?

I have some custom content and PHP scripts that I would like to make only available to my forum members. How can I VB password protect a custom page?
Reply With Quote
  #2  
Old 12-29-2004, 09:57 PM
rake's Avatar
rake rake is offline
 
Join Date: Nov 2002
Posts: 311
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

insert the vbulletin backend and then use an if statement...

chdir("./forumdir");
require("./global.php");
chdir("../");

if($bbuserinfo['userid'])
{

.........
exit;
}
else
{
print_no_permission();
}
Reply With Quote
  #3  
Old 12-30-2004, 05:51 AM
thephonemall thephonemall is offline
 
Join Date: Oct 2004
Posts: 40
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you very much for the reply!
the uh.. *cough* backend? Sorry I am a little new to VB and PHP
Reply With Quote
  #4  
Old 12-30-2004, 01:30 PM
rake's Avatar
rake rake is offline
 
Join Date: Nov 2002
Posts: 311
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Including the global.php file in any other file will allow you to access all vbulletin functions, classes ($DB_site for database connection...) and all other vbulletin resources. That's what i meant.

In this case you need to check if the user visiting the page is a member or not. vBulletin checks the cookies, the sessions and determines if the user is a member and is logged in, which is reflected in the $bbuserinfo array. Therefore, you can check the $bbuserinfo['userid'] variable to see if you've got a valid viewer or not. If the id is greater than 0, it's a member. If it's 0, it's a guest.

Hope it helps.
Reply With Quote
  #5  
Old 12-30-2004, 02:59 PM
thephonemall thephonemall is offline
 
Join Date: Oct 2004
Posts: 40
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks again.. I will five that a try. I just realized that one of the pages I would like to VB password protect is an HTML file instead of PHP. Will that pose a problem?
-- Would you be willing to password protect and add my VB header to a couple pages for $25.00 CAD via PayPal?
Reply With Quote
  #6  
Old 12-30-2004, 03:03 PM
rake's Avatar
rake rake is offline
 
Join Date: Nov 2002
Posts: 311
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

for the html file, change the extension to .php and add this:

<?php
chdir("./forumdir");
require("./global.php");
chdir("../");

if($bbuserinfo['userid'])
{
?>

plain html code here

<?php
exit;
}
else
{
print_no_permission();
}
?>
Reply With Quote
  #7  
Old 01-01-2005, 07:03 AM
thephonemall thephonemall is offline
 
Join Date: Oct 2004
Posts: 40
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is the code I added:

--------------------------

<? chdir("/home/thephone/public_html/forums");
require("./global.php");
chdir("../");

if($bbuserinfo['userid'])
{

exit;
}
else
{
print_no_permission();
}
?>
---------------------------
If I am logged into the forums I receive a blank page. When I am not logged in I get this error:

Warning: construct_forum_jump(./includes/functions_forumlist.php): failed to open stream: No such file or directory in /home/thephone/public_html/forums/includes/functions.php on line 2270

Fatal error: construct_forum_jump(): Failed opening required './includes/functions_forumlist.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/thephone/public_html/forums/includes/functions.php on line 2270

Any ideas?
Reply With Quote
  #8  
Old 01-04-2005, 04:00 PM
thephonemall thephonemall is offline
 
Join Date: Oct 2004
Posts: 40
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Bump!
Reply With Quote
  #9  
Old 01-04-2005, 04:16 PM
rake's Avatar
rake rake is offline
 
Join Date: Nov 2002
Posts: 311
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you should put something before the exit; if you want something to be displayed while you are logged in.

for the second, i really have no idea. a member confirmed that the code works in another thread: https://vborg.vbsupport.ru/showthread.php?t=73731

try using just chdir("./forums"); and see what happens. (assuming your site and this script are in: /home/thephone/public_html/)
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:57 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.04458 seconds
  • Memory Usage 2,231KB
  • Queries Executed 11 (?)
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
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete