Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-17-2012, 08:09 AM
newsun newsun is offline
 
Join Date: Jan 2012
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default php+curl+login woes...

Ok, so I am logging into vb from within another site that already has membership login. I am able to successfully login with the php+curl code I have.

The problem is that when I go to the forum the I am not actually logged in there. I thought maybe I could nab the bb_sessionhash cookie data from the curl session and the set the cookie, but this is not working.

Anyone have any ideas on how I can transfer this logged in state from the curl session to the actual forum I want to send them to?
Reply With Quote
  #2  
Old 02-17-2012, 03:23 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Transfering the session hash probably won't work because it's only accepted if it comes from the same ip address and user agent string. I guess you could fake the user agent in curl, but probably not the ip.

A couple things you might try (and I haven't tried either of them) - set the bb_password cookie to md5(password . COOKIE_SALT). COOKIE_SALT is defined in functions.php. I think that should work like "remember me" to log in the user. The other thing would be to create a session for the user by writing to the session table (and that way you can write the user's ip and user agent to get around that problem). ETA...or maybe keep things the way you have them but update the session table record with the user's ip and user agent (although after that you won't be able to use curl for that session).
Reply With Quote
  #3  
Old 02-17-2012, 05:02 PM
newsun newsun is offline
 
Join Date: Jan 2012
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have tried most of that.

First thing I was trying, was to create the session myself by inserting it directly to the database and then setting the cookie. This did not work.

So I tried logging in via cURL, this gets logged in though the idhash and host stored in the session table do not match the client as it's coming from my server. So I tried updating the session table to have the client's ip and an idhash based on this ip. Then set the cookie, this still does not work.

The main problem is not the logging in part via cURL, that works fine, it's getting that session to work on the client's end.
Reply With Quote
  #4  
Old 02-17-2012, 05:09 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by newsun View Post
I have tried most of that.

First thing I was trying, was to create the session myself by inserting it directly to the database and then setting the cookie. This did not work.

So I tried logging in via cURL, this gets logged in though the idhash and host stored in the session table do not match the client as it's coming from my server. So I tried updating the session table to have the client's ip and an idhash based on this ip. Then set the cookie, this still does not work.
So do you know why those things didn't work? Do you know if the browser is actually sending the cookies you set (to vb, I mean)?
Reply With Quote
  #5  
Old 02-17-2012, 05:20 PM
newsun newsun is offline
 
Join Date: Jan 2012
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am receiving the cookies, can see them in the headers in the chrome console and also via firecookie plugin. I can see them on both the sub-domain of the script and the forum subdomain as the cookie is set to .DOMAIN.com
Reply With Quote
  #6  
Old 02-17-2012, 05:33 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by newsun View Post
So I tried updating the session table to have the client's ip and an idhash based on this ip. Then set the cookie, this still does not work.
I guess if you got that far you were also using the client's user agent. Hmm...don't see why that wouldn't work.


Quote:
Originally Posted by newsun View Post
I am receiving the cookies, can see them in the headers in the chrome console and also via firecookie plugin. I can see them on both the sub-domain of the script and the forum subdomain as the cookie is set to .DOMAIN.com

OK, just checking. Clearly you're ahead of me on this so I don't have any other ideas unless maybe I get the chance to try to myself. Hopefully someone else will know.
Reply With Quote
  #7  
Old 02-17-2012, 06:54 PM
newsun newsun is offline
 
Join Date: Jan 2012
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am setting the user_agent, that's not a problem. I even have the correct 'idhash' via this cURL command:

PHP Code:
curl_setopt($chCURLOPT_HTTPHEADER, array("X-FORWARDED-FOR: $ip")); 
Everything in the session is set via cURL call correctly except the 'host' (ip address). I dunno yet if this is the problem or not.
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 01:58 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.03671 seconds
  • Memory Usage 2,220KB
  • Queries Executed 13 (?)
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)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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_postinfo_query
  • fetch_postinfo
  • 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