vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   birthday in thread (https://vborg.vbsupport.ru/showthread.php?t=20344)

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:

  1. 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")."\";");
    }

    ?>
  2. 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
  3. backup showthread.php
  4. open showthread.php

    and add:

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


    before:

    eval("\$post[profile] = \"".gettemplate("postbit_profile")."\";");
  5. save showthread.php
  6. 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:
PHP Code:

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


All times are GMT. The time now is 08:11 AM.

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.01076 seconds
  • Memory Usage 1,736KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete