MOD download & history

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 !

Postby kooky on Sun 04. May, 2003 02:41

Lot of change and added a New PART 4 to support Chinese Zodiac

PART 1 is now updated new version is 1.4.14, some change
Added align="absmiddle" tag to align image on the text and a space between Age and value

to upgrade in viewtopic.php
Code: Select all
#
#-----[ FIND ]------------------------------------------
#
if ( $postrow[$i]['user_birthday'] != 999999 )
{
   $poster_birthdate=realdate('md', $postrow[$i]['user_birthday']);
//   $n=0;
//   while ($n<26)
//   {
//      if ($poster_birthdate>=$zodiacdates[$n] & $poster_birthdate<=$zodiacdates[$n+1])
//      {
//         $zodiac = $lang[$zodiacs[($n/2)]];
//         $u_zodiac = $images[$zodiacs[($n/2)]];
//         $zodiac_img = '<img src="'.$u_zodiac.'" alt="'.$zodiac.'" title="'.$zodiac.'" border="0"/>';
//         $n=26;         
//      } else
//      {
//         $n=$n+2;
//      }
//   }
   $poster_age = $this_year - realdate ('Y',$postrow[$i]['user_birthday']);
   if ($this_date < $poster_birthdate) $poster_age--;
   $poster_age = $lang['Age'] . ':' . $poster_age .' ';
} else
{
//   $zodiac='';
//   $u_zodiac='';
//   $zodiac_img='';   
   $poster_age = ' ';
}

#
#-----[ REPLACE BY ]------------------------------------------
#

if ( $postrow[$i]['user_birthday'] != 999999 )
{
   $poster_birthdate=realdate('md', $postrow[$i]['user_birthday']);
//   $n=0;
//   while ($n<26)
//   {
//      if ($poster_birthdate>=$zodiacdates[$n] & $poster_birthdate<=$zodiacdates[$n+1])
//      {
//         $zodiac = $lang[$zodiacs[($n/2)]];
//         $u_zodiac = $images[$zodiacs[($n/2)]];
//         $zodiac_img = '<img src="' . $u_zodiac . '" alt="' . $zodiac . '" title="' . $zodiac . '" align="absmiddle" border="0" />';
//         $n=26;
//      } else
//      {
//         $n=$n+2;
//      }
//   }
   $poster_age = $this_year - realdate ('Y',$postrow[$i]['user_birthday']);
   if ($this_date < $poster_birthdate) $poster_age--;
   $poster_age = $lang['Age'] . ': ' . $poster_age;
} else
{
//   $zodiac = '';
//   $u_zodiac = '';
//   $zodiac_img = '';
   $poster_age = '';
}

Remove the // in line if you want use zodiac


only if you use zodiac Part (PART 3)
upgrade in viewtopic.php
Code: Select all
#
#-----[ FIND ]------------------------------------------
#
'L_ZODIAC' => ($zodiac) ? $lang['Zodiac'].':' : '',

#
#-----[ REPLACE BY ]------------------------------------------
#

'L_ZODIAC' => ($zodiac) ? $lang['Zodiac'] . ': ' : '',



PART 3 is now updated new version is 1.0.2, minor change
Only for those who use zodiac part

to upgrade in usercp_viewprofile.php
Code: Select all
#
#-----[ FIND ]------------------------------------------
#
if ($profiledata['user_birthday']!=999999)
{
   $poster_birthdate=realdate('md', $profiledata['user_birthday']);
   $i=0;
   while ($i<26)
   {
      if ($poster_birthdate>=$zodiacdates[$n] & $poster_birthdate<=$zodiacdates[$i+1])
      {
         $zodiac = $lang[$zodiacs[($i/2)]];
         $u_zodiac = $images[$zodiacs[($i/2)]];
         $zodiac_img = $lang['Zodiac'].': <img src="'.$u_zodiac.'" alt="'.$zodiac.'" title="'.$zodiac.'" border="0"/>';
         $i=26;         
      } else
      {
         $i=$i+2;
      }
   }
}

#
#-----[ REPLACE BY ]------------------------------------------
#

if ($profiledata['user_birthday']!=999999)
{
   $user_birthdate=realdate('md', $profiledata['user_birthday']);
   $i=0;
   while ($i<26)
   {
      if ($user_birthdate>=$zodiacdates[$n] & $user_birthdate<=$zodiacdates[$i+1])
      {
         $zodiac = $lang[$zodiacs[($i/2)]];
         $u_zodiac = $images[$zodiacs[($i/2)]];
         $zodiac_img = $lang['Zodiac'] . ': <img src="' . $u_zodiac . '" alt="' . $zodiac . '" title="' . $zodiac . '" align="absmiddle" border="0" />';
         $i=26;
      } else
      {
         $i=$i+2;
      }
   }
}


to upgrade in subsilver.cfg
Code: Select all
#
#-----[ FIND ]----------------------------------------
#
//added for birthday mod
$images['Capricorn'] = "$current_template_images/icon_mini_capricorn.gif";
$images['Aquarius'] = "$current_template_images/icon_mini_aquarius.gif";
$images['Pisces'] = "$current_template_images/icon_mini_pisces.gif";
$images['Aries'] = "$current_template_images/icon_mini_aries.gif";
$images['Taurus'] = "$current_template_images/icon_mini_taurus.gif";
$images['Gemini'] = "$current_template_images/icon_mini_gemini.gif";
$images['Cancer'] = "$current_template_images/icon_mini_cancer.gif";
$images['Leo'] = "$current_template_images/icon_mini_leo.gif";
$images['Virgo'] = "$current_template_images/icon_mini_virgo.gif";
$images['Libra'] = "$current_template_images/icon_mini_libra.gif";
$images['Scorpio'] = "$current_template_images/icon_mini_scorpio.gif";
$images['Sagittarius'] = "$current_template_images/icon_mini_sagittarius.gif";

#
#-----[ REPLACE BY ]-------------------------------------
#

//added for birthday mod
$images['Capricorn'] = "$current_template_images/icon_zodiac_capricorn.gif";
$images['Aquarius'] = "$current_template_images/icon_zodiac_aquarius.gif";
$images['Pisces'] = "$current_template_images/icon_zodiac_pisces.gif";
$images['Aries'] = "$current_template_images/icon_zodiac_aries.gif";
$images['Taurus'] = "$current_template_images/icon_zodiac_taurus.gif";
$images['Gemini'] = "$current_template_images/icon_zodiac_gemini.gif";
$images['Cancer'] = "$current_template_images/icon_zodiac_cancer.gif";
$images['Leo'] = "$current_template_images/icon_zodiac_leo.gif";
$images['Virgo'] = "$current_template_images/icon_zodiac_virgo.gif";
$images['Libra'] = "$current_template_images/icon_zodiac_libra.gif";
$images['Scorpio'] = "$current_template_images/icon_zodiac_scorpio.gif";
$images['Sagittarius'] = "$current_template_images/icon_zodiac_sagittarius.gif";


Rename your zodiac images icon_mini_xxxxx.gif to icon_zodiac_xxxxx.gif
This new name is to have a better order in your images dir

to upgrade in profile_view_body.tpl
Code: Select all
#
#-----[ FIND ]----------------------------------
#
  <td><b><span class="gen">{BIRTHDAY}</b></span></td>
</tr>

#
#-----[ AFTER, ADD ]--------------------------------
#

<tr>
  <td valign="middle" align="right" nowrap="nowrap"><span class="gen">{L_ZODIAC}:&nbsp;</span></td>
  <td><b><span class="gen">{ZODIAC}&nbsp;{ZODIAC_IMG}</b></span></td>
</tr>


New PART 4 version 0.9.1,
Only needed if you use (or want to use) Chinese zodiac.
Added new chinese zodiac images, new lang entry and display chinese zodiac in viewprofile.

to install new PART 4 follow this:

in file lang_main.php
Code: Select all
#
#-----[ FIND ]------------------------------------------
#
$lang['month_long'] = array ($lang['datetime']['January'],$lang['datetime']['February'],$lang['datetime']['March'],$lang['datetime']['April'],$lang['datetime']['May'],$lang['datetime']['June'],$lang['datetime']['July'],$lang['datetime']['August'],$lang['datetime']['September'],$lang['datetime']['October'],$lang['datetime']['November'],$lang['datetime']['December']);

#
#-----[ AFTER, ADD ]------------------------------------------
#
$lang['Chinese_zodiac']= 'Chinese zodiac';
$lang['Unknown'] = 'Unknown';
$lang['Rat'] = 'Rat';
$lang['Buffalo'] = 'Buffalo';
$lang['Tiger'] = 'Tiger';
$lang['Cat'] = 'Cat';
$lang['Dragon'] = 'Dragon';
$lang['Snake'] = 'Snake';
$lang['Horse'] = 'Horse';
$lang['Goat'] = 'Goat';
$lang['Monkey'] = 'Monkey';
$lang['Cock'] = 'Cock';
$lang['Dog'] = 'Dog';
$lang['Pig'] = 'Pig';


in file usercp_viewprofile.php
Code: Select all
#
#-----[ FIND ]------------------------------------------
#
//
// Generate page

#
#-----[ BEFORE, ADD ]------------------------------------------
#
if ($profiledata['user_birthday']!=999999)
{
   include('chinese.'.$phpEx);
   $chinese = get_chinese_year (realdate('Ymd', $profiledata['user_birthday']));
   $u_chinese = $images[$chinese];
   $chinese_img = ($chinese=='Unknown') ? '' : '<img src="' . $u_chinese . '" alt="' . $lang[$chinese] . '" title="' . $lang[$chinese] . '" align="absmiddle" border="0" />';
}

#
#-----[ FIND ]------------------------------------------
#
'BIRTHDAY' => ($profiledata['user_birthday']!=999999) ? $poster_birthday=realdate($lang['DATE_FORMAT'], $profiledata['user_birthday']) : $poster_birthday=$lang['No_birthday_specify'],

#
#-----[ AFTER, ADD ]------------------------------------------
#
'CHINESE' => $lang[$chinese],
'CHINESE_IMG' => $chinese_img,
'U_CHINESE' => $u_chinese,
'L_CHINESE' => $lang['Chinese_zodiac'],


in file subsilver.cfg
Code: Select all
#
#-----[ FIND ]------------------------------------------
#
?>

#
#-----[ BEFORE, ADD ]------------------------------------------
#
//added for birthday mod
$images['Rat'] = "$current_template_images/icon_chinese_rat.gif";
$images['Buffalo'] = "$current_template_images/icon_chinese_buffalo.gif";
$images['Tiger'] = "$current_template_images/icon_chinese_tiger.gif";
$images['Cat'] = "$current_template_images/icon_chinese_cat.gif";
$images['Dragon'] = "$current_template_images/icon_chinese_dragon.gif";
$images['Snake'] = "$current_template_images/icon_chinese_snake.gif";
$images['Horse'] = "$current_template_images/icon_chinese_horse.gif";
$images['Goat'] = "$current_template_images/icon_chinese_goat.gif";
$images['Monkey'] = "$current_template_images/icon_chinese_monkey.gif";
$images['Cock'] = "$current_template_images/icon_chinese_cock.gif";
$images['Dog'] = "$current_template_images/icon_chinese_dog.gif";
$images['Pig'] = "$current_template_images/icon_chinese_pig.gif";


in file profile_view_body.tpl
Code: Select all
#
#-----[ FIND ]------------------------------------------
#
  <td><b><span class="gen">{BIRTHDAY}</b></span></td>
</tr>

#
#-----[ AFTER, ADD ]------------------------------------------
#
<tr>
  <td valign="middle" align="right" nowrap="nowrap"><span class="gen">{L_CHINESE}:&nbsp;</span></td>
  <td><b><span class="gen">{CHINESE}&nbsp;{CHINESE_IMG}</b></span></td>
</tr>


Upload file chinese.php to includes/chinese.php
Upload icon_chinese_xxxxx.gif (12 images) in your templates/subSilver/images dir (included in birthday zip archive)
kooky
brilliant supporter
 
Posts: 1329
Joined: Tue 31. Dec, 2002 17:52
Location: Au pays des rêves

Postby Niels on Sun 04. May, 2003 15:21

PART 4 is now update to version 0.9.2.
to upgrade:

in file usercp_viewprofile.php
Code: Select all
[FIND]
include('chinese.'.$phpEx);

[REPLACE WITH]
include($phpbb_root_path . 'includes/chinese.'.$phpEx);
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

Postby Niels on Sat 17. May, 2003 02:35

I have resently changed a find tag in part one witch was giving lots of users truble, unforgently this was posted in a wrong way witch made the problem even worse, security could in very reare cases have been compromised, to correct this please verify that your usercp_register.php is like this

Code: Select all
#
#-----[ FIND ]------------------------------------------
#
# NOTIS - IMPORTENT SECURITY RISK
#
# If you some how do not preform the following VERY carefully you have the
# potential to compromise your forum SECURITY, your users may easyly get ADMIN access if you make mistake
# meny users do make mistake in the step, so please be very careful
#
$sql = "INSERT INTO " . USERS_TABLE . "
VALUES ($user_id,

#
#-----[ IN-LINE FIND ]------------------------------------------
#
, user_active, user_actkey,)
VALUES

#
#-----[ IN-LINE BEFORE, ADD ]------------------------------------------
#
, user_birthday, user_next_birthday_greeting

#
#-----[ IN-LINE FIND ]------------------------------------------
#
,";

#
#-----[ IN-LINE BEFORE, ADD ]------------------------------------------
#
,'$birthday','$next_birthday_greeting'
Last edited by Niels on Sat 17. May, 2003 03:01, edited 3 times in total.
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

Postby Niels on Sat 17. May, 2003 02:45

if you have installed PART 1 version 1.3.14 you should preform the following SQL
Code: Select all
UPDATE prefix_users SET user_level=0 where user_regdate>(now()-(86400*7)) AND user_level=1


remember to replace the prefix_ with what ever you are using (usually phpbb_)

this SQL will make shure that users registerd the last 7 days can in no way have got ADMIN access (witch version 1.3.14 potential could have giving users in very special cases)

this SQL should only be executed if your have been runing your board for more than 7 days in total, since it will reset all admin account not more than 7 days old
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

upgrade

Postby Niels on Thu 17. Jul, 2003 22:49

I have made some minor speed improvements, so it should act a litle faster.....
EDIT: some users have reported problems related to this upgrade, you should therefore wait to upgrade, until this is clearifyed....
EDIT2: I have now correct the code, and it should work well on other machines as well

new version of PART 1 is 1.4.17

to upgrade, please do this:
in file functions.php
Code: Select all
[FIND]
      $year=date%1461;
      $days = $date - $year*1461;
      while ($days > 364)
      {
         $year++;
         $days-=365;
         if ($i++==3)
         {
            $i=0;
            $days--;
         }
      }
      if (days<=0 && $i==0)
      {
         $days++;
      }

[REPLACE WITH]
return date($date_syntax,$date*86400+1);


in file index.php
Code: Select all
[FIND]
   // 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 += 10000;
            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);
   }


[REPLACE WITH]
//
// Birthday Mod, Show users with birthday
$time_now = time();
$date_now = create_date('md', $time_now, $board_config['board_timezone']);
$date_forward = create_date('md', $time_now+($board_config['birthday_check_day']*86400), $board_config['board_timezone']);
$sql = ($board_config['birthday_check_day']) ? "SELECT user_id, username, user_birthday, user_level FROM ".USERS_TABLE." WHERE (user_birthday BETWEEN 0 AND 999998 AND
DATE_FORMAT(FROM_DAYS(user_birthday),'%m%d') BETWEEN '($date_now+0)' AND '$date_forward') OR user_birthday<0 ORDER BY username" : "";
if(!$result = $db->sql_query($sql))
{
        message_die(GENERAL_ERROR, "Could not fetch birthday for users.", "", __LINE__, __FILE__, $sql);
} else
{
   $birthdayrows = array($db->sql_fetchrowset($result));
}
   if (!empty($result))
   {
      $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 (list($user_number, $birthdayrow) = each($birthdayrows))
      {
            $user_birthday2 = $this_year.($user_birthday = realdate("md",$birthdayrow['user_birthday'] ));
         // give user a year more, if he alread have birthday
            if ( $user_birthday2 < $date_today ) $user_birthday2 += 10000;
         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] = ' ';
   }
if (!empty($result))
{
   $db->sql_freeresult($result);
}
Last edited by Niels on Wed 10. Dec, 2003 00:53, edited 2 times in total.
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

Postby Niels on Fri 18. Jul, 2003 17:26

some users did report that the previous upgrade did not work on theire sites.
I have upgraded the above posted code, and new version is now 1.4.18 of PART 1

EDIT: this have also been reported as buggy, please wait
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

Postby kooky on Wed 30. Jul, 2003 23:19

Until Niels is available, the main Birthday Mod zip archive will not be updated to latest version

New PART 1 is now v1.4.20.
fixed parse error into functions.php

OPEN file includes/functions.php
Code: Select all
EDIT: code removed, see post below


For New installation, just FIND
Code: Select all
?>
and ADD BEFORE the code above


Really more faster now 8)
kooky
brilliant supporter
 
Posts: 1329
Joined: Tue 31. Dec, 2002 17:52
Location: Au pays des rêves

Postby Niels on Sat 02. Aug, 2003 10:29

birthday mod PART 1 ver 1.4.20. is now released, plaece update the added code in file functions.php
User avatar
Niels
Poster
Poster
 
Posts: 4390
Joined: Sat 27. Jul, 2002 15:46

PreviousNext

Return to Birthday [2.0.10/EM]

Who is online

Users browsing this forum: No registered users and 1 guest

cron