Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 09-08-2008, 06:19 PM
CtrlAltDel CtrlAltDel is offline
 
Join Date: Feb 2002
Location: Ohio
Posts: 107
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default TIMENOW and access to it outside the Forum Software

I want to display a logout button to logged in users on my new custom homepage that I am writing. I have been able to recreate the logout hash, but since it is based off of appending "time()-" to the front, the value it gets is different than what the value would be when generated by login.php.

How do I get to the global TIMENOW variable that VB uses? Do I need to just include global.php into my application?

Is there another way to do this without including that entire file? Trying to avoid unnecessary bloat from 'over including' files.

TIA
Reply With Quote
  #2  
Old 09-08-2008, 06:58 PM
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Location: Tallahassee, Florida
Posts: 2,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There is no difference; vBulletin uses time() as TIMENOW.

See line 32 of init.php:
Code:
define('TIMENOW', time());

Check out line 1335 of functions.php:
Code:
$user['securitytoken'] = sha1($user['userid'] . sha1($user['salt']) . sha1(COOKIE_SALT));
$user['logouthash'] =& $user['securitytoken'];
Reply With Quote
  #3  
Old 09-08-2008, 07:11 PM
CtrlAltDel CtrlAltDel is offline
 
Join Date: Feb 2002
Location: Ohio
Posts: 107
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Maybe I need to update the forum that I'm working with. As this is the code from my functions.php...

PHP Code:
$user['securitytoken_raw'] = sha1($user['userid'] . sha1($user['salt']) . sha1(COOKIE_SALT));
$user['securitytoken'] = TIMENOW '-' sha1(TIMENOW $user['securitytoken_raw']);
$user['logouthash'] =& $user['securitytoken']; 
Assume:
1. myscript.php is a script outside my forum root directory
2. login.php is the standard file included in vB

Appending time() in myscript.php is going to be different than the generated one that would be generated from login.php. So when I pass the hash from one myscript.php to login.php, login.php will error out and then display a new (and correct) logout link w/proper logouthash.

If the newest version of VB has dropped this timestamping feature of the logout hash then this simplifies things dramatically.
Reply With Quote
  #4  
Old 09-08-2008, 07:27 PM
Kirk Y's Avatar
Kirk Y Kirk Y is offline
 
Join Date: Apr 2005
Location: Tallahassee, Florida
Posts: 2,604
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah, I didn't realize the 3.7.3 hash now included the time (I was looking at 3.7.0).

Try including your global file. At least then the constant would be in namespace.

Code:
chdir('/path/to/forum');
require_once('global.php');
Reply With Quote
  #5  
Old 09-08-2008, 07:48 PM
CtrlAltDel CtrlAltDel is offline
 
Join Date: Feb 2002
Location: Ohio
Posts: 107
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah I figured I had to do that so I started playing with that.

It works all well and good, but the logout hash is not correct. I click it and then I get an error page on login.php and it then generates a logouthash that is correct.

I wonder what magical step I'm missing. Maybe I'm missing setting some cookie var, or session var.

--------------- Added [DATE]1220931509[/DATE] at [TIME]1220931509[/TIME] ---------------

By including the global.php shouldnt I be able to use things like $bbuserinfo inside my custom php page?

--------------- Added [DATE]1220983002[/DATE] at [TIME]1220983002[/TIME] ---------------

figured it out, just needed to use the right variable, $vbulletin->userinfo['logouthash']
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 08:01 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.04174 seconds
  • Memory Usage 2,198KB
  • 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
  • (3)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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