PDA

View Full Version : birthday in thread


Mas*Mind
06-14-2001, 10:00 PM
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
06-15-2001, 05:50 PM
nice one dude.. Look alright that does.

do you have a demo?

Dakota
06-15-2001, 06:27 PM
You can see it in action on my forum.

Great hack. you did a good job on it.

mister
06-15-2001, 06:56 PM
just installed it, works great, thanks!

kicks
06-15-2001, 07:37 PM
Thanks Mas*Mind :)

cditty
06-15-2001, 09:31 PM
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
06-15-2001, 10:57 PM
Mines on line 26......

Mas*Mind
06-15-2001, 11:49 PM
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
06-16-2001, 01:08 AM
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
06-16-2001, 02:15 AM
Working for me. Thanks for the revised code.

Maverick, what errors are you getting now?

Chris

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

cditty
06-16-2001, 02:40 AM
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
06-16-2001, 04:13 AM
Right u are-thanks 4 helping me :)

Dakota
06-16-2001, 04:28 AM
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
06-16-2001, 04:34 AM
Well its not displaying it correctly, so I will put it in this attachment.

tazthedev
06-16-2001, 05:39 AM
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
06-16-2001, 09:24 AM
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
06-16-2001, 09:27 AM
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
06-19-2001, 07:34 AM
does this slow down the page loading much?
anyone know?

Mas*Mind
06-19-2001, 09:59 AM
nope, not noticable anyway

TigerLily
06-20-2001, 03:08 PM
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
09-04-2001, 10:04 PM
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
09-04-2001, 10:57 PM
Problem solved!

The line mentioned above is located in:

/admin/functions.php

Yay. :) Now works perfectly in 2.0.3!

Great hack!

squawell
09-16-2001, 05:34 PM
it's a nice hack~~~

so interesting~~~

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

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

cyrus
10-13-2001, 02:00 PM
it doesnt owrk in 2.0.3, i cant find what is needed in showthread.php !!!

:( :(

can someone help me add this hack !

Alien
10-13-2001, 05:40 PM
Read a few lines up...

cyrus
10-21-2001, 07:00 PM
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
10-21-2001, 09:09 PM
eval("\$post[profile] = \"".gettemplate("postbit_profile")."\";");

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

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

Any update available? Great hack!

Tim Wheatley
02-02-2002, 10:32 AM
Works here too. (2.2.2)

Birdie501
05-22-2002, 01:34 PM
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-07-2002, 09:08 AM
For some reason this doesn't work for me in vBulletin v2.2.6.

Schorsch
08-09-2002, 04:25 AM
any advices on this problem with 2.2.6 ?

Schorsch

Diva
09-06-2002, 11:31 AM
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.