vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   How do I redirect non-logged in users to login page? (https://vborg.vbsupport.ru/showthread.php?t=63846)

royli57 04-14-2004 01:34 AM

How do I redirect non-logged in users to login page?
 
Hi

I am using a cookie check to see if the user is logged in.

If the user is not logged in, I want to redirect the user to the forum login page, and then have the user be returned to the original page after login.

Any ideas how I can do this? I could not find a page that was only login that I could redirect to.

Thanks,

Roy :bandit:

Scrub 04-14-2004 02:32 PM

Are you wanting this to happen when they try to view the index or threads? I belive you could edit the usergroup options for Unregistered/Logged Out users in your admincp to make it so they have to log in before viewing anything.

sydude 08-21-2004 12:32 AM

Royli57,

Can you please post or email the code for what you have? What you already had was good enough for me. I just want some of my non-VB pages to check to see if there's a bbuserid cookie present before allowing access. I can't figure out how to do it - of course, I have no clue what I'm doing, so maybe that's why...

Thanks

Sy

deathemperor 08-21-2004 01:05 PM

this could be easily done by using an if condition:
PHP Code:

if ($bbuserinfo['userid'] == 0)
{
        
print_no_permission();


this checks wether one is a user of your board and if he is not it will open the login page, if he is of course he can view that page.
I think we can change $bbuserinfo['userid'] == 0 to something like $bbuserinfo['usergroupid'] == 2 ( which is a usergroup of guests)

sydude 08-21-2004 01:29 PM

deathemperor, thank you for the response. I'm pretty uneducated with all of this stuff, so I'm not sure exactly what to do with it. I've taken just the snippet of code you provided and placed it within <?php and ?> tags at the head of my html file, and renamed my file to end in .php.

But that doesn't seem to work. All I get is a white screen. Do I need to use any other code? BTW, when I check to see what the cookie names are for my vbulletin site, the userid cookie comes back as 'bbuserid'.

It would be really appreciated if you could help me with this.

Thanks

Sy

deathemperor 08-22-2004 10:25 AM

it's not simple by placing that code in a php file and hope it work for you. you must include the global.php to that file, and that code does something like:
PHP Code:

if ($bbuserinfo['userid'] == 0

        
print_no_permission(); 

else
{
        echo 
"you can access this page";


you don't have to check for any cookies.
depending on what your purpose is use it properly

sydude 08-24-2004 04:54 PM

Thank you, Deathemperor. I really appreciate the help, but this is still too complicated for me. I have no idea how include a global.php in the file, etc. I don't really know anything about php, I only know html.

What I really need is a complete block of code to just insert into my html files that will redirect a user to the vbulletin login page if they aren't already logged in. Again, I really appreciate your help on this.

Thanks

Sy

deathemperor 08-25-2004 04:35 AM

then you would need these:
https://vborg.vbsupport.ru/showthread.php?t=62164
and
php.net

for how to include a page in a page
and it's must be an php file, no way it can be html file
I actually don't understand what you need for that file


All times are GMT. The time now is 09:27 PM.

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.00997 seconds
  • Memory Usage 1,729KB
  • 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
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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