The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
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:
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:
|
#2
|
||||
|
||||
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:
|
#3
|
||||
|
||||
Shouldnt that be:
PHP Code:
Satan |
#4
|
||||
|
||||
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: |
#5
|
||||
|
||||
I'm still having some issues with this, if anybody would be so kind to help I'd really appreciate it
|
#6
|
||||
|
||||
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/ |
#7
|
||||
|
||||
Drkfusion is right bblastvisit is saved in timestamp, so you have to use time:
PHP Code:
|
#8
|
||||
|
||||
Fant?stico! It works great, thanks for the help Drkfusion, Xenon, and Hellsatan.
|
#9
|
||||
|
||||
good to hear you're welcome |
#10
|
||||
|
||||
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:
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|