PDA

View Full Version : birthday in thread


Mas*Mind
15 Jun 2001, 19:25
Description: This hack prints some message or displays a picture in a post when that particular user has a birthday on that moment.

Version tested: 2.01, but will probaby work on all 2.0 versions

instructions:



Create a new file called birthday.php with the following content:

<?php

$today_day = date("d",mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y"))+($bbuserinfo[timezoneoffset]-$timeoffset)*3600);
$today_month = date("m",mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y"))+($bbuserinfo[timezoneoffset]-$timeoffset)*3600);
$today_year = date("Y",mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y"))+($bbuserinfo[timezoneoffset]-$timeoffset)*3600);
$userday = explode("-",$post[birthday]);

if($today_day == $userday[2] && $today_month == $userday[1])
{ $bday = explode("-",$userinfo[birthday]);
if(date("Y")>$bday[0] and $bday[0]>1901 && $bday[0]!='0000')
{ $birthday = @date($calformat1,mktime(0,0,0,$bday[1],$bday[2],$bday[0]));
}
else
{ // lets send a valid year as some PHP3 don't like year to be 0
// $calformat2 should not contania year identifier so the year doesn't matter
$birthday = @date($calformat2,mktime(0,0,0,$bday[1],$bday[2],1993));
}
if($birthday=="")
{ $birthday="$bday[1]-$bday[2]-$bday[0]";
}
if($today_year > $userday[0] && $userday[0] != '0000')
{ $age = $today_year-$userday[0];
}

eval ("\$post[has_a_birthday] = \"".gettemplate("postbit_birthday")."\";");
}

?>
create a new template called postbit_birthday

with some text like:

Congrats! It's $post[username]'s birthday!

(you can use the following variables in this template:

$birthday: Will contain the birthday of the user in a nice format
$age: Will only contain a value (obviously the age of this user) when the user has filled in his birthyear

backup showthread.php
open showthread.php

and add:

// Begin birthdayhack
include("birthday.php");
// End birthdayhack

before:

eval("\$post[profile] = \"".gettemplate("postbit_profile")."\";");
save showthread.php
insert $post[has_a_birthday] somewhere in the postbit template


enjoy :)

Blue2000
15 Jun 2001, 19:50
nice one dude.. Look alright that does.

do you have a demo?

Dakota
15 Jun 2001, 20:27
You can see it in action on my forum.

Great hack. you did a good job on it.

mister
15 Jun 2001, 20:56
just installed it, works great, thanks!

kicks
15 Jun 2001, 21:37
Thanks Mas*Mind :)

cditty
15 Jun 2001, 23:31
I just tried to install it and I get an error on line 25 of birthday.php.

All I did was cut & paste from here. Wierd.

This is the line:
eval ("\$post[has_a_birthday] = \"".gettemplate("postbit_birthday")."";");

Any ideas?

maverick1236
16 Jun 2001, 00:57
Mines on line 26......

Mas*Mind
16 Jun 2001, 01:49
yup....the [php] code screws code up:

eval ("\$post[has_a_birthday] = \"".gettemplate("postbit_birthday")."";

should be:

eval ("\$post[has_a_birthday] = \"".gettemplate("postbit_birthday")."\";");

maverick1236
16 Jun 2001, 03:08
now the problem is here: in showthread.php
// Begin birthdayhack
include("birthday.php");
// End birthdayhack


something is screwed up with the code here-im getting errors

any ideas?

cditty
16 Jun 2001, 04:15
Working for me. Thanks for the revised code.

Maverick, what errors are you getting now?

Chris

maverick1236
16 Jun 2001, 04:36
Warning: Failed opening 'birthday.php' for inclusion (include_path='') in e:\program files\nusphere\apache\htdocs\upload\showthread.php on line 479

cditty
16 Jun 2001, 04:40
That means that it can't find it. You sure the birthday.php file is there? Could you have named it .php3 by accident?

Chris

maverick1236
16 Jun 2001, 06:13
Right u are-thanks 4 helping me :)

Dakota
16 Jun 2001, 06:28
I had to change
eval ("\$post[has_a_birthday] = \"".gettemplate("postbit_birthday")."";

to

eval("\$post[has_a_birthday] = \"".gettemplate("postbit_birthday")."\"";");

on line 25 of birthday.php

Dakota
16 Jun 2001, 06:34
Well its not displaying it correctly, so I will put it in this attachment.

tazthedev
16 Jun 2001, 07:39
Warning: Failed opening 'birthday.php' for inclusion (include_path='.') in f:\apache\htdocs\divinefxp\showthread.php on line 430


here's the error i got ...

help

Mas*Mind
16 Jun 2001, 11:24
Originally posted by tazthedev
Warning: Failed opening 'birthday.php' for inclusion (include_path='.') in f:\apache\htdocs\divinefxp\showthread.php on line 430


here's the error i got ...

help

read a few posts up

Mas*Mind
16 Jun 2001, 11:27
Originally posted by Dakota
Well its not displaying it correctly, so I will put it in this attachment.

I know, there's some problem with the [php]-code... I allready changed my original instructions

Sarge
19 Jun 2001, 09:34
does this slow down the page loading much?
anyone know?

Mas*Mind
19 Jun 2001, 11:59
nope, not noticable anyway

TigerLily
20 Jun 2001, 17:08
Awesome hack! It didn't work for me in 2.0, but as soon as I upgraded to 2.01 it worked beautifully. Thank you so much!
TigerLily:)

Alien
05 Sep 2001, 00:04
Do these instructions need any updating? They're not working for me on my 2.0.3 board i'm testing...

For example, the line:

eval("\$post[profile] = \"".gettemplate("postbit_profile")."\";");

Does not exist in showthread.php

I tried to include it in a couple of other places in there (like near the global.php include, but it did not display a thing in threads..

Ideas?

Thanks! :)

Alien
05 Sep 2001, 00:57
Problem solved!

The line mentioned above is located in:

/admin/functions.php

Yay. :) Now works perfectly in 2.0.3!

Great hack!

squawell
16 Sep 2001, 19:34
it's a nice hack~~~

so interesting~~~

thanks your hack it's work very well in my forum!!!

tkhjosh
21 Sep 2001, 23:04
so it wont work on 2.0.0? if not then i am not going to try it :P

cyrus
13 Oct 2001, 16:00
it doesnt owrk in 2.0.3, i cant find what is needed in showthread.php !!!

:( :(

can someone help me add this hack !

Alien
13 Oct 2001, 19:40
Read a few lines up...

cyrus
21 Oct 2001, 21:00
done,. thats fine

but whee do I go to see if this hack is working fine and also where do I upload my birthday.php file ??

+ I do not understand what I have to do in step "6"

can anyone help

thanks

omniweapon
21 Oct 2001, 23:09
eval("\$post[profile] = \"".gettemplate("postbit_profile")."\";");

I can't find that line in functions.php .

Okiewan
03 Jan 2002, 18:59
eval("\$post[profile] = \"".gettemplate("postbit_profile")."\";");
Not in showthread or functions in ver 2.2.1

Any update available? Great hack!

Tim Wheatley
02 Feb 2002, 12:32
Works here too. (2.2.2)

Birdie501
22 May 2002, 15:34
hi,

can someone tell me what code i have to use when i want to show the age of the user in postbit also if he has no birthday??

Thanks!

afterlab
07 Jul 2002, 11:08
For some reason this doesn't work for me in vBulletin v2.2.6.

Schorsch
09 Aug 2002, 06:25
any advices on this problem with 2.2.6 ?

Schorsch

Diva
06 Sep 2002, 13:31
Hi. Would you mind a little more help with a hack? I have 2.2.7 and really enjoy this hack. The only problem is it won't 'turn off'. So one member is having a 2 day birthday. =/

Any help would be appreciated.