The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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?
|
#2
|
||||
|
||||
insert the vbulletin backend and then use an if statement...
chdir("./forumdir"); require("./global.php"); chdir("../"); if($bbuserinfo['userid']) { ......... exit; } else { print_no_permission(); } |
#3
|
|||
|
|||
Thank you very much for the reply!
the uh.. *cough* backend? Sorry I am a little new to VB and PHP |
#4
|
||||
|
||||
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. |
#5
|
|||
|
|||
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? |
#6
|
||||
|
||||
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(); } ?> |
#7
|
|||
|
|||
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? |
#8
|
|||
|
|||
Bump!
|
#9
|
||||
|
||||
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/) |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|