Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 07-20-2017, 08:57 PM
Medi0cr3 Medi0cr3 is offline
 
Join Date: Aug 2014
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Vb4 Custom external php login script - need help

I have a script that allows me to login a user without a password, having had integrated an SSO into my vbulletin, i'm using criteria from the SSO to secure the process for signing on. However, when I get redirected to the forum, it looks like the user is Logged on and their name is in the top corner and the page looks correct, the user tries to navigate somewhere on the page then is told that the user is not logged on. I'm at a loss for what is going on. Need some help reviewing the code please.

PHP Code:
class vBulletinUser{
    public static function 
login($username$remember_me true){
        
//chdir(VB_ROOT_PATH); //not required, file is in my forum directory
        //require_once('./global.php'); //already at the top of hte page
        //require_once(DIR . '/includes/functions_login.php'); //already at the top of hte page
        
global $vbulletin,$vbphrase;
        
$remember_me $remember_me true false;    //force to true or false value
        
$vbulletin->userinfo $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, infractiongroupids, 
            username, password, salt FROM "
.TABLE_PREFIX."user WHERE username = '".
            
$vbulletin->db->escape_string(htmlspecialchars_uni($username))."'");
            
        if (
$vbulletin->userinfo){
            
set_authentication_cookies(true);
            
process_new_login($vbulletin->GPC['logintype'], $remember_me$vbulletin->GPC['cssprefs']);
            
exec_shut_down();
            
$vbulletin->url '/index.php';
            
header('Location: /');
            return 
true;
        }
        return 
false;
    }

I'm invoking the class by:
PHP Code:
$vb = new vBulletinUser();
    
$vb->login($_SESSION['charName']); 
* The charName is infact present.

I could greatly use some help as to figure out why it shows it like its logged on, but as soon as you navigate away, it says its not logged on.
Reply With Quote
  #2  
Old 07-20-2017, 09:06 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Your script seems to be fine.

When you login, before clicking on any other page, do you see an entry in the session table that belongs to the logged in user?
Are the cookie settings properly setup at AdminCP > Settings > Options > Cookies and HTTP Header Options?
Reply With Quote
Благодарность от:
MarkFL
  #3  
Old 07-20-2017, 09:19 PM
Medi0cr3 Medi0cr3 is offline
 
Join Date: Aug 2014
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yes, an entry is in the session table that belongs to the user. I confirmed via IP address.

I confirmed that the settings for the cookie REQUIRES the folllowing for this code to work:

First cookie option:
/forum/

and second cookie option:
.DOMAIN.com

Thanks dude. It works like a champ now. I've been pounding my head over this for 48 hours now.
Reply With Quote
Благодарность от:
MarkFL
  #4  
Old 07-20-2017, 11:33 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No problem, glad it works.
Reply With Quote
Reply

Thread Tools
Display Modes

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 10:50 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.03887 seconds
  • Memory Usage 2,196KB
  • 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
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (2)post_thanks_box_bit
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete