[Fixed] Both January and October BD's show in October

Mod that adds a birthday field to the users profile, theire age are displayed beside the posts, and on there birthday they will have a greeting popup
Forum rules
The content in this forum is dated Dec. 21 2005 and can be used as Archive only. This Forum is LOCKED and READ ONLY !

[Fixed] Both January and October BD's show in October

Postby parad0x on Tue 07. Oct, 2003 02:21

As always, great MODs and fantastic support :D

On to the problem. I searched as well as read through the first 17 pages for an answer to my question ... sorry if I have missed something. The Birthday MOD has been installed for quite a while and updated a few times. The only problem I have encountered is that users with a birthday in January also show up during October when I look ahead 30 days.

The only thing I can think of that might cause this is the way Windows sorts numbers, like 1, 10, 2, 3, 4 ... Maybe I am way off mark, not sure. Has anyone heard of/fixed this problem?

Any Ideas?

TIA


[Edited by kooky: see the latest post to resume all the topic]
parad0x
Poster
Poster
 
Posts: 18
Joined: Sun 23. Mar, 2003 23:52

Postby kooky on Thu 09. Oct, 2003 03:26

i was trying to reproduce your error, but nothing :?

i guess you made an error into index.php !!! or functions.php
Check these files... :)
kooky
brilliant supporter
 
Posts: 1329
Joined: Tue 31. Dec, 2002 17:52
Location: Au pays des rêves

Postby parad0x on Thu 09. Oct, 2003 16:44

Hello kooky,

I looked through both files, and the code for the birthday MOD is fine. I may very well have something elsewhere in one of those files that is conflicting, but I have no idea what it could be.

Do you have any guess what snipit of code might cause this effect?

Thanks again :D

Oh, forum is here is you want to see http://forum.crucialpc.com
parad0x
Poster
Poster
 
Posts: 18
Joined: Sun 23. Mar, 2003 23:52

Postby Niels on Thu 09. Oct, 2003 21:00

it seam to me, like a problem in index.php, maybe due to version of DB server.
you may try the old code, witch is a bit slower, but more compatible.
Code: Select all
#
#-----[ OPEN ]------------------------------------------
#
index.php

#
#-----[ FIND ]------------------------------------------
#
//
// Start output of page

#
#-----[ BEFORE, ADD ]------------------------------------------
#
// Birthday Mod, Show users with birthday
$sql = ($board_config['birthday_check_day']) ? "SELECT user_id, username, user_birthday,user_level FROM " . USERS_TABLE. " WHERE user_birthday!=999999 ORDER BY username" :"";
if($result = $db->sql_query($sql))
{
   if (!empty($result))
   {
      $time_now = time();
      $this_year = create_date('Y', $time_now, $board_config['board_timezone']);
      $date_today = create_date('Ymd', $time_now, $board_config['board_timezone']);
      $date_forward = create_date('Ymd', $time_now+($board_config['birthday_check_day']*86400), $board_config['board_timezone']);
         while ($birthdayrow = $db->sql_fetchrow($result))
      {
            $user_birthday2 = $this_year.($user_birthday = realdate("md",$birthdayrow['user_birthday'] ));
            if ( $user_birthday2 < $date_today ) $user_birthday2 += 1000;
         if ( $user_birthday2 > $date_today  && $user_birthday2 <= $date_forward )
         {
            // user are having birthday within the next days
            $user_age = ( $this_year.$user_birthday < $date_today ) ? $this_year - realdate ('Y',$birthdayrow['user_birthday'])+1 : $this_year- realdate ('Y',$birthdayrow['user_birthday']);
            switch ($birthdayrow['user_level'])
            {
               case ADMIN :
                     $birthdayrow['username'] = '<b>' . $birthdayrow['username'] . '</b>';
                     $style_color = 'style="color:#' . $theme['fontcolor3'] . '"';                  break;
               case MOD :
                     $birthdayrow['username'] = '<b>' . $birthdayrow['username'] . '</b>';
                     $style_color = 'style="color:#' . $theme['fontcolor2'] . '"';                  break;
               default: $style_color = '';
            }
            $birthday_week_list .= ' <a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $birthdayrow['user_id']) . '"' . $style_color .'>' . $birthdayrow['username'] . ' ('.$user_age.')</a>,';
         } else if ( $user_birthday2 == $date_today )
            {
            //user have birthday today
            $user_age = $this_year - realdate ( 'Y',$birthdayrow['user_birthday'] );
            switch ($birthdayrow['user_level'])
            {
               case ADMIN :
                     $birthdayrow['username'] = '<b>' . $birthdayrow['username'] . '</b>';
                     $style_color = 'style="color:#' . $theme['fontcolor3'] . '"';                  break;
               case MOD :
                     $birthdayrow['username'] = '<b>' . $birthdayrow['username'] . '</b>';
                     $style_color = 'style="color:#' . $theme['fontcolor2'] . '"';                  break;
               default: $style_color = '';
            }
            $birthday_today_list .= ' <a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $birthdayrow['user_id']) . '"' . $style_color .'>' . $birthdayrow['username'] . ' ('.$user_age.')</a>,';
            }
      }
      if ($birthday_today_list) $birthday_today_list[ strlen( $birthday_today_list)-1] = ' ';
      if ($birthday_week_list) $birthday_week_list[ strlen( $birthday_week_list)-1] = ' ';
   }
   $db->sql_freeresult($result);
}


Also if runing on a LINUX / UNIX server, I would recorment using the UNIX version of code into functions.php (see the how-to) - this will solve that that old version of code is slower (in fact it should be faster)
(if a how-to is EM ready, it will mostly be bullet prof, since a machine is more picky than a human. :D)
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

Postby parad0x on Fri 10. Oct, 2003 01:30

Hi Niels,

That is actually the version of code I am using. I compared differences between what you suggested and what I have ... the only difference I found is that I have a 3rd case for LESS_ADMIN. Below is the exact code I am using.
Code: Select all
// Birthday Mod, Show users with birthday
$sql = ($board_config['birthday_check_day']) ? "SELECT user_id, username, user_birthday,user_level FROM " . USERS_TABLE. " WHERE user_birthday!=999999 ORDER BY username" :"";
if($result = $db->sql_query($sql))
{
   if (!empty($result))
   {
      $time_now = time();
      $this_year = create_date('Y', $time_now, $board_config['board_timezone']);
      $date_today = create_date('Ymd', $time_now, $board_config['board_timezone']);
      $date_forward = create_date('Ymd', $time_now+($board_config['birthday_check_day']*86400), $board_config['board_timezone']);
         while ($birthdayrow = $db->sql_fetchrow($result))
      {
            $user_birthday2 = $this_year.($user_birthday = realdate("md",$birthdayrow['user_birthday'] ));
            if ( $user_birthday2 < $date_today ) $user_birthday2 += 1000;
         if ( $user_birthday2 > $date_today  && $user_birthday2 <= $date_forward )
         {
            // user are having birthday within the next days
            $user_age = ( $this_year.$user_birthday < $date_today ) ? $this_year - realdate ('Y',$birthdayrow['user_birthday'])+1 : $this_year- realdate ('Y',$birthdayrow['user_birthday']);
            switch ($birthdayrow['user_level'])
            {
               case ADMIN :
                  $birthdayrow['username'] = '<b>' . $birthdayrow['username'] . '</b>';
                  $style_color = 'style="color:#' . $theme['fontcolor3'] . '"';
                  break;
               case MOD :
                  $birthdayrow['username'] = '<b>' . $birthdayrow['username'] . '</b>';
                  $style_color = 'style="color:#' . $theme['fontcolor2'] . '"';
                  break;
               case LESS_ADMIN :
                  $birthdayrow['username'] = '<b>' . $birthdayrow['username'] . '</b>';
                  $style_color = 'style="color:#' . $theme['fontcolor4'] . '"';
                  break;
               default: $style_color = '';
            }
            $birthday_week_list .= ' <a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $birthdayrow['user_id']) . '"' . $style_color .'>' . $birthdayrow['username'] . ' ('.$user_age.')</a>,';
         } else if ( $user_birthday2 == $date_today )
         {
            //user have birthday today
            $user_age = $this_year - realdate ( 'Y',$birthdayrow['user_birthday'] );
            switch ($birthdayrow['user_level'])
            {
               case ADMIN :
                  $birthdayrow['username'] = '<b>' . $birthdayrow['username'] . '</b>';
                  $style_color = 'style="color:#' . $theme['fontcolor3'] . '"';
                  break;
               case MOD :
                  $birthdayrow['username'] = '<b>' . $birthdayrow['username'] . '</b>';
                  $style_color = 'style="color:#' . $theme['fontcolor2'] . '"';
                  break;
               case LESS_ADMIN :
                  $birthdayrow['username'] = '<b>' . $birthdayrow['username'] . '</b>';
                  $style_color = 'style="color:#' . $theme['fontcolor4'] . '"';
                  break;
               default: $style_color = '';
            }
            $birthday_today_list .= ' <a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $birthdayrow['user_id']) . '"' . $style_color .'>' . $birthdayrow['username'] . ' ('.$user_age.')</a>,';
         }
      }
      if ($birthday_today_list) $birthday_today_list[ strlen( $birthday_today_list)-1] = ' ';
      if ($birthday_week_list) $birthday_week_list[ strlen( $birthday_week_list)-1] = ' ';
   }
   $db->sql_freeresult($result);
}


BTW, I am also using
Windows 2000
PHP 4.2.2
Apache 1.3.26
MySQL 4.0.0

Any other ideas?

Thanks
parad0x
Poster
Poster
 
Posts: 18
Joined: Sun 23. Mar, 2003 23:52

Postby Niels on Fri 10. Oct, 2003 22:15

if there is a problem, it should be around these lines

Code: Select all
$user_birthday2 = $this_year.($user_birthday = realdate("md",$birthdayrow['user_birthday'] ));
            if ( $user_birthday2 < $date_today ) $user_birthday2 += 1000;
         if ( $user_birthday2 > $date_today  && $user_birthday2 <= $date_forward )

what have you set your "birthday look forward" to ?
(if a how-to is EM ready, it will mostly be bullet prof, since a machine is more picky than a human. :D)
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

Postby parad0x on Sat 11. Oct, 2003 01:24

look forward is set to 30 days
parad0x
Poster
Poster
 
Posts: 18
Joined: Sun 23. Mar, 2003 23:52

Postby kooky on Sun 12. Oct, 2003 01:15

That's weird :?
on my main site with more than 650 users (and a big db ~38Mo)
i have the same problem :idea:
a user born on january has his birthday in october (birthday look forward to 30 days)
The mod was installed on January and updated each time without not any problem

i don't know where that could come from :?
kooky
brilliant supporter
 
Posts: 1329
Joined: Tue 31. Dec, 2002 17:52
Location: Au pays des rêves

Next

Return to Birthday [2.0.10/EM]

Who is online

Users browsing this forum: No registered users and 2 guests

cron