Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 12-08-2002, 03:31 PM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Working with vBulletin cookies..

I'm attempting to make a hack that if you are a guest, and you visit the forum without having a cookie set (or it is expired), you will be redirected to another page requesting alittle info for quick registration.

I can do this easily with a cookie javascript, but I'm wondering how to integrate it with PHP instead.

The code would reside in the global.php, and then make a couple checks:

1. If the viewer is not registered.
2. If the vBulletin cookie for last visit is greater than 1 day, probably using the cookie bblastvisit.

If both return true, then the following line of code is executed:
PHP Code:
eval("dooutput(\"".gettemplate('guest_register')."\");"); 
And some template like that, not necessarily with that name, is opened. This makes it much more simple than creating a javascript and opening up a separate .html or .php file when the body has loaded.

My only problem is figuring out how to do this, or if my logic is right.

Here is my test run (as ridiculous as it might be)
PHP Code:

$dayvalue 
86400;

if(
$bbuserinfo[userid] == 0){
   if(
$HTTP_COOKIE_VARS['bblastvisit'] == "" || $HTTP_COOKIE_VARS['bblastvisit'] + $dayvalue date()){
      eval(
"dooutput(\"".gettemplate('guest_register')."\");");
   }

Does any of this seem plausible?
Reply With Quote
  #2  
Old 12-08-2002, 04:06 PM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I just tried it out, and the condition for no cookie being set returns true if none has really been set, but if it has expired I can't seem to get the check to work. Which must mean something in this part of the code:
PHP Code:
$HTTP_COOKIE_VARS['bblastvisit'] + $dayvalue date()){ 
Is wrong... :ermm:
Reply With Quote
  #3  
Old 12-08-2002, 04:38 PM
Chris M's Avatar
Chris M Chris M is offline
 
Join Date: Dec 2001
Location: Northampton, England
Posts: 6,186
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Shouldnt that be:

PHP Code:
$HTTP_COOKIE_VARS['bblastvisit'] + $dayvalue vbdate()){ 
??

Satan
Reply With Quote
  #4  
Old 12-08-2002, 05:19 PM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's more or less the logic of that condition, not whether its vbdate() or date() (and using just plain date() actually gives you a parse error)...

vbdate() just puts it in the vBulletin time format, but I'm just trying to get the unix timestamp of the present date, then compare it with the "bblastvisit" timestamp+1 day to see if it has been over 1 day since the guest last visited.

/me falls over :dead:
Reply With Quote
  #5  
Old 12-09-2002, 12:14 AM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm still having some issues with this, if anybody would be so kind to help I'd really appreciate it
Reply With Quote
  #6  
Old 12-09-2002, 12:53 AM
DrkFusion's Avatar
DrkFusion DrkFusion is offline
 
Join Date: Nov 2001
Posts: 1,926
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

time() maybe? Neo once was telling me you subtract 8000 something minutes or something from time() and that is 24 hours past.

Don't quote me on it, but I think time() is/should be used/
Reply With Quote
  #7  
Old 12-09-2002, 02:08 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Drkfusion is right bblastvisit is saved in timestamp, so you have to use time:

PHP Code:
$HTTP_COOKIE_VARS['bblastvisit'] + 3600*24 time()){ 
Reply With Quote
  #8  
Old 12-09-2002, 02:26 PM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Fant?stico! It works great, thanks for the help Drkfusion, Xenon, and Hellsatan.
Reply With Quote
  #9  
Old 12-09-2002, 02:35 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default


good to hear

you're welcome
Reply With Quote
  #10  
Old 12-10-2002, 03:00 AM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Looks like I've got one more question (for now) concerning PHP & cookies.

How is the vBulletin function for creating a cookie, vbsetcookie(), differ from the PHP preloaded function, setcookie()?

From sessions.php, I've noted that most uses of vbsetcookie() only have two arguements, the name and value. Whether it can take more, I'm not sure, but what I really need which setcookie() has is the expire arguement, which lets me set a time for when the cookie expires.

Could the following be used in vbsetcookie()?
PHP Code:
vbsetcookie ("TestCookie"$valuetime()+3600*24); 
I'm just not sure of the differences between setcookie() and vbsetcookie(), that's the real question
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 01:12 PM.


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.02431 seconds
  • Memory Usage 2,264KB
  • 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
  • (6)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete