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

Reply
 
Thread Tools Display Modes
  #1  
Old 09-24-2007, 12:29 PM
swehack swehack is offline
 
Join Date: Jan 2006
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default What is 'password' in the cookie?

I'm in the process of writing a portal that will be connected to our existing vb and share authentication. But i can't figure out what the password value in the cookie is, i assume it's some sort of extra authentication besides the userid but i can't find it's hash in the database.
Reply With Quote
  #2  
Old 09-24-2007, 03:37 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If its already connected to your vB doesn't that mean you are already including global.php from the forum directory? If so you shouldn't need to use information from the cookies and instead just check if $vbulletin->userinfo['userid'] == 0 to check if they are logged in or not.
Reply With Quote
  #3  
Old 09-24-2007, 05:38 PM
swehack swehack is offline
 
Join Date: Jan 2006
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Opserty View Post
If its already connected to your vB doesn't that mean you are already including global.php from the forum directory? If so you shouldn't need to use information from the cookies and instead just check if $vbulletin->userinfo['userid'] == 0 to check if they are logged in or not.
That's nice, i had no idea it was that easy.

I'm afraid i'd still like to know how this hash is calculated though. Because i know the logouthash is calculated from the cookie secret, salt and userid but i can't find out how this one is created.

The thing is that i only need the authentication part, i just need to see if they're logged in or not then i'll get the info i need from the database myself. Beucase the portal is in a totally different location from the message board on the server it would be unpractical to copy a bunch of vbulletin files there just to connect them when i could do it myself in so little code.

But now that i know that you can connect your app with vbulletin that easy i might just think about copying files over, or maybe moving the portal to the message board directories. It's just kinda complicated because the portal will be stand alone apart from the administration interface where one user will login using his vb credentials, and the comments which you will need to be logged in to use. Other than that i'll be writing huge ammounts of code that have nothing to do with vbulletin and need their own large directory structure, it would be cumbersome to have them among a bunch of vbulletin files.
Reply With Quote
  #4  
Old 09-24-2007, 07:09 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by swehack View Post
But now that i know that you can connect your app with vbulletin that easy i might just think about copying files over, or maybe moving the portal to the message board directories. It's just kinda complicated because the portal will be stand alone apart from the administration interface where one user will login using his vb credentials, and the comments which you will need to be logged in to use. Other than that i'll be writing huge ammounts of code that have nothing to do with vbulletin and need their own large directory structure, it would be cumbersome to have them among a bunch of vbulletin files.
vBulletin already has a lot of backend code which you can manipulate in your portal, such as the datamanagers, database and input classes.

You can always use the back-end code and just include global.php. (Not that much need to put the files in the vBulletin folders) and then include admincp/global.php for the ACP files
Reply With Quote
  #5  
Old 09-25-2007, 05:26 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$password md5(md5($password) . $salt);

$logouthash md5($userid $salt $license);

setcookie(COOKIE_PREFIX 'userid'$useridtime() + 14400);
setcookie(COOKIE_PREFIX 'password'md5($password $license), time() + 14400); 
Reply With Quote
  #6  
Old 09-25-2007, 12:16 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you would have a directory structure like:

/root/
/root/MyApp
/root/vBulletin

Then you could easily use the vBulletin files in your own application.

In your application:
cd ../vBulletin
include global.php
cd ../MyApp
...the rest of your code...
Reply With Quote
  #7  
Old 09-27-2007, 08:21 AM
swehack swehack is offline
 
Join Date: Jan 2006
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dismounted View Post
PHP Code:
$password md5(md5($password) . $salt);

$logouthash md5($userid $salt $license);

setcookie(COOKIE_PREFIX 'userid'$useridtime() + 14400);
setcookie(COOKIE_PREFIX 'password'md5($password $license), time() + 14400); 
Thank you! Also i thought the logouthash was userid, passwordmd5 and some sort of cookie secret constant i found defined, i was maybe wrong then.

To all you who still think i should include global.php, doesn't that require me to copy a whole lot of other files so my app can see them? For example init.php, config.inc.php and so on, all files included indirectly by global.php, right?

I'm reluctant to copy too many files from vbulletin into the app directory because at each update i would have to do it again. Also all i needed was the password hash from the cookie so now i can authenticate the user and take it from there because the message board and the portal will share a database, with different table prefixes. It just seems easier to do it this way so far, i tried including global.php but sure enough i needed all the other files included by global.php.
Reply With Quote
  #8  
Old 09-27-2007, 11:37 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No, all you need would be this in your custom files.
PHP Code:
$curdir getcwd();
chdir('./forums');
require_once(
'./global.php');
chdir($curdir); 
Reply With Quote
  #9  
Old 01-26-2008, 06:42 PM
swehack swehack is offline
 
Join Date: Jan 2006
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dismounted View Post
No, all you need would be this in your custom files.
PHP Code:
$curdir getcwd();
chdir('./forums');
require_once(
'./global.php');
chdir($curdir); 
Thanks for that tip, sorry i'm late but when i try that it still tries to include from the app directory.

I have this structure, vbulletin is directly in public_html, the web root. The app i'm writing is in a subdirectory of public_html called new. So i do your code but i only do chdir('..'); and i get the error Warning: require_once(/usr/home/foo_bar/public_html/new/includes/init.php) failed to open stream and so forth. You get the idea, basically it's including from the wrong directory.

Edit: I'm sorry, this was my fault and i discovered why now.
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 05: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.04781 seconds
  • Memory Usage 2,258KB
  • 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
  • (4)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)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
  • 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