vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Logging in a User to VB from an external Script Help? (https://vborg.vbsupport.ru/showthread.php?t=155505)

dzineit 08-17-2007 06:08 PM

Logging in a User to VB from an external Script Help?
 
hey guys,

Going to try and keep figuring this out, but this is where I stand.

I have an external login script, login a user to my own backend I am building and VB. I want it so they only login once. So anyways long story short. When they Login, it inserts the required data to Sessions for VB. It has a row setup in user for VB.

When I login, I see my username in Active Users. But, when trying to post, It says I must login.

I have the following cookies set on login.

bbsessionhash
bblastactivity
bblastvisit

Long story short.

When posting, how does the system verify your logged on?

Dismounted 08-18-2007 04:43 AM

Here's how to log users in.
PHP Code:

setcookie(COOKIE_PREFIX 'password'$passwordtime() + 14400);
setcookie(COOKIE_PREFIX 'userid'$useridtime() + 14400);

$password md5(md5(md5($password) . $salt) . $license); 

That's all there needs to be, other cookies will be automatically created by vBulletin.

dzineit 08-20-2007 12:45 PM

strangely this is not working...

BulletxxProof89 08-20-2007 12:52 PM

The function:
PHP Code:

function login($userid$pass_plaintext$salt$license){

$password md5(md5(md5($pass_plaintext) . $salt) . $license); 

setcookie('bbpassword'$passwordtime() + 14400);
setcookie('bbuserid'$useridtime() + 14400);



The login:
PHP Code:


login
(1,'password','3vt','1234567890'); 

Of course you fill in the data correctly from your MySQL query and your files.

dzineit 08-20-2007 01:03 PM

When is that function called?

lets try something else... So far my userid is set, password is set, but its not inserting my userid into the session in the database. So where does Vbulletin initally set the session from the forums index page. This way I can have the userid be inserted along with it.

When I manually do this via PHPMYADMIN I am logged it, and all is well...

This shit is not working. VB keeps deleting the cookies. How the hell. Help guys, common.

Both of those solutions successfully created the cookies but it is not working.. ANy Help???

Dismounted 08-21-2007 12:58 PM

You need to create the sessions in the database yourself.

Norco 08-23-2007 01:00 AM

Uhm.. what does the license mean?

treelovinhippie 08-23-2007 01:21 AM

Quote:

Originally Posted by Dismounted (Post 1322341)
You need to create the sessions in the database yourself.

How?

Dismounted 08-23-2007 07:41 AM

Quote:

Originally Posted by Norco (Post 1323618)
Uhm.. what does the license mean?

License number
Quote:

Originally Posted by treelovinhippie (Post 1323630)
How?

Search for it, it was posted here, somewhere.

Norco 08-23-2007 04:33 PM

I have found my license. But, if I was logging in from mydomain.com and my forum is located on mydomain.net - it still wouldn't work because the cookie is set from mydomain.com, right?

And.. I have realized I am in the same situation as dzineit and treelovinhippie. Where does vbulletin have the query to set the session stuff in the database?

This is how it is adding the user into the forum AFTER they have logged into my website:
PHP Code:

function loginforum($userid$pass_plaintext$salt$license){
                
$password md5(md5(md5($pass_plaintext) . $salt) . $license); 
                
setcookie(COOKIE_PREFIX 'bbpassword'$passwordtime() + 14400);
                
setcookie(COOKIE_PREFIX 'bbuserid'$useridtime() + 14400);
                }
                
                
$getinfo mysql_query("SELECT * FROM `users` WHERE `username` = '$username'");
                while(
$r mysql_fetch_array($getinfo)){
                
$useridf $r['id'];
                
$passf $r['password'];
                
$saltf $r['salt'];
                }  
                
loginforum('$useridf','$passf','$saltf','LICENSE'); 


dzineit 08-23-2007 05:42 PM

This is how I fixed the problem.

Ill try to show tidbits, because it is integrated with some other site im doing.

Ignore MID in the sql code, thats something I added to th Vbulletin database.

$license = your license number
the $salt I hard coded sicne I am the one adding users to the database. So I know the salt.

Code:

function logintoforum($userid, $pass_plaintext, $salt, $license){

$SQLCODE[0] = "SELECT * FROM `user` WHERE `mid` = '$userid'";
$QRYCODE[0] = mysql_query($SQLCODE[0]) or die(mysql_error());
$ASSCODE[0] = mysql_fetch_assoc($QRYCODE[0]);

$password = md5(md5(md5($pass_plaintext) . $salt) . $license);

setcookie('bbpassword', $password, time() + 14400);
setcookie('bbuserid', $ASSCODE[0]['userid'], time() + 14400);

}

Are you still trying to register the user with an external script into Vbulletin?

Norco 08-23-2007 06:16 PM

Right now, I have it so it sets the cookies (I checked in my browser). But it is on a different domain then my forum so I am unsure if it will work until I transfer everything over to the domain the forum is on.

treelovinhippie 08-24-2007 06:03 AM

Awesome... all I need to know now is how to log the user OUT externally. Ideas?

Is it just clear the two created cookies and then clear the session in the database? (how do you do that with the sessions?)

Edit: removing the userid, password and sessionhash cookies worked... ie:

setcookie('bbpassword', "", time() - 14400);
setcookie('bbuserid', "", time() - 14400);
setcookie('bbsessionhash', "", time() - 14400);

Although yeah it still doesn't remove the session data from the database

dzineit 08-24-2007 03:18 PM

Well,

I don't see V bulletin doing this either.

I just clear the cookies and that works well enough for me.

Its really sad that Vbulletin has no better support. PHPbb has better response and its free. Unbelievable.

Tree, cookies are not held to one server, and they can work cross domains. Sessions cannot since they are saved on the server. Cookies are stored on the clients computer.


All times are GMT. The time now is 04:53 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.01160 seconds
  • Memory Usage 1,769KB
  • 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
  • (1)bbcode_code_printable
  • (4)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (14)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