• [MOD] Birthday Mod v1.0 5 0 5 1
Currently:  

Author Topic: [MOD] Birthday Mod v1.0  (Read 213027 times)

0 Members and 1 Guest are viewing this topic.

Offline IcEcReaM

  • Hero Member
  • *****
  • Posts: 714
    • View Profile
    • My little Testboard
[MOD] Birthday Mod v1.0
« on: February 10, 2006, 08:20:12 AM »
[ Introduction ]
With this Mod Users are able to input their birthday when registering or when updating their profile.
Fully configurable if
- birthday age also shown in profile next to birthday
- countdown to be shown in profile till next birthday
- if the birthday must be entered or is optional on registration/updating profile
- that todays birthdays are shown on index
- it's also possible to enter only day & month, then for year 0000 must be entered
- Birthday message can set when a user enters the site and has birthday (can be set on/off)

German:
Mit diesem Mod können User bei der Registrierung oder in ihren Einstellungen ihr Geburtstagsdatum eingeben.
Dieser Mod bietet verschiedene Einstellungsmöglichkeiten:
- einstellbar ob Alter im Profil auch angezeigt wird.
- einstellbarer Countdown bis zum nächsten Geburtstag im Profil
- einstellbar ob der Geburtstag eingegeben werden muss oder nur optional eingegeben werden kann.
- einstellbar ob die jeweilg heutigen Geburtstag auf der Indexseite erscheinen
- möglich nur Monat & Tag als Geburtstag einzugeben, dann muss für die Jahreseingabe "0000" eingegeben werden.
- wenn ein Geburtstagskind die Seite betritt kann eine Geburtstagsnachricht gesetzt werden.

Demo Link

[ Changed Files ]
includes/functions.php
includes/db_field_definitions.php
includes/session.php
register.php
index.php
member.php
templates/register_form.html
templates/member_profile.html
templates/member_editprofile.html
templates/home.html
admin/settings.php
lang/<your language>/admin.php
lang/<your language>/main.php

[ Installation ]

First Backup your Files

Step 1
Open register.php

Find
Code: [Select]
$user_icq = (isset($HTTP_POST_VARS['user_icq'])) ? ((intval(trim($HTTP_POST_VARS['user_icq']))) ? intval(trim($HTTP_POST_VARS['user_icq'])) : "") : "";
below insert
Code: [Select]
  $user_birthday_day = (isset($HTTP_POST_VARS['user_birthday_day'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['user_birthday_day'])) : "";
  $user_birthday_month = (isset($HTTP_POST_VARS['user_birthday_month'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['user_birthday_month'])) : "";
  $user_birthday_year = (isset($HTTP_POST_VARS['user_birthday_year'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['user_birthday_year'])) : "";
 

Find
Code: [Select]
if ($user_password == "") {above insert
Code: [Select]
    //Birthday Mod
    if (!$user_birthday = check_birthday($user_birthday_day,$user_birthday_month,$user_birthday_year,$config['birthday_required'])) {
      $msg .= (($msg != "") ?  "<br />" : "").$field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['birthday']), $lang['field_required']);
      $error = 1;
    }

Find
Code: [Select]
$activationkey = get_random_key(USERS_TABLE, get_user_table_field("", $user_table_fields['user_activationkey']));above insert

Code: [Select]
    // Birthday Mod
    $additional_field_sql .= ", ".get_user_table_field("", "birthday");
    $additional_value_sql .= ", '$user_birthday'";

Find
Code: [Select]
$site_template->register_vars(array(
      "user_name" => htmlspecialchars(stripslashes($user_name)),
above insert
Code: [Select]
  $birthday_day_options = "<option value=\"\">--</option>\n";
  $birthday_month_options = "<option value=\"\">--</option>\n";

  for ($i=1;$i<=31;$i++){
    $birthday_day_options .= "<option value=\"".sprintf("%02d",$i)."\"".(($i == $user_birthday_day) ? "selected" : "").">".$i."</option>\n";

  }
  for ($i=1;$i<=12;$i++){                                                                                                                        //getmonth($i)
    $birthday_month_options .= "<option value=\"".sprintf("%02d",$i)."\"".(($i == $user_birthday_month) ? "selected" : "").">".$lang['months'][sprintf("%02d",$i)]."</option>\n";
  }

Find
Code: [Select]
"user_icq" => $user_icq,below insert
Code: [Select]
      "birthday_day_options" => $birthday_day_options,
      "birthday_month_options" => $birthday_month_options,
      "user_birthday_year" => $user_birthday_year,
      "lang_day" => $lang['day'],
      "lang_month" => $lang['month'],
      "lang_year" => $lang['year'],

Step 2
Open templates/register_form.html

Find
Code: [Select]
          <tr>
            <td class="row1"><b>{lang_email}</b></td>
            <td class="row1"><input type="text" name="user_email" size="30" class="input" value="{user_email}" /></td>
          </tr>
below insert
Code: [Select]
<!--  Birthday Mod     -->
          <tr>
             <td class="row1"><b>{lang_birthday}</b></td>
             <td class="row1"><table>
                      <tr>
                          <td>{lang_day}</td>
                          <td>{lang_month}</td>
                          <td>{lang_year}</td>
                      </tr>

                      <tr>
                           <td><select name="user_birthday_day">{birthday_day_options} </select></td>
                           <td><select name="user_birthday_month">{birthday_month_options}</select></td>
                           <td><input class="input" name="user_birthday_year" value="{user_birthday_year}" maxlength="4" size="5" type="text">
                           </td>
                      </tr>

            </table></td>
           </tr>
<!--  Birthday Mod     -->

Step 3

Open includes/db_field_definitions.php

Find
Code: [Select]
?>above insert
Code: [Select]
$additional_user_fields['birthday'] = array($lang['birthday'], "text", 0);
Step 4

Open includes/session.php
Find

Code: [Select]
"user_icq" => "user_icq"above insert
Code: [Select]
"birthday" => "birthday",

Step 5

Open member.php

Find

Code: [Select]
      $user_email_button = REPLACE_EMPTY;
    }
and replace with
Code: [Select]
      $user_email_button = REPLACE_EMPTY;
    }
   
    // Birthday Mod
    $user_birthday = (isset($user_row[$user_table_fields['birthday']])) ? $user_row[$user_table_fields['birthday']] : REPLACE_EMPTY;
    if (!empty($user_birthday) && $user_birthday != REPLACE_EMPTY  && $user_row[$user_table_fields['birthday']] != "0000-00-00") {

           $birthday = explode("-",$user_row[$user_table_fields['birthday']]);
           $user_birthday = $birthday[2].".".$lang['months'][sprintf("%02d",$birthday[1])];
           $user_birthday .= ($birthday[0]!="0000") ? " ".$birthday[0]."" : "";
           
           // Show Age in Profile
           if (($config['birthday_show_profile_age'] == 1) && ($age = calc_age ($user_row[$user_table_fields['birthday']]))) {
                $user_birthday .= " ($age)";
           }
           
           // Show Birthdaycountdown in Profile
           if ($config['birthday_profile_countdown'] == 1 && $b_cdown = calc_countdown ($user_row[$user_table_fields['birthday']]))  {

                $site_template->register_vars(array(
                     "lang_birthday_cdown" => $lang['birthday_cdown'],
                     "cdown_days" => $b_cdown['days'],
                     "cdown_hours" => $b_cdown['hours'],
                     "cdown_minutes" => $b_cdown['minutes'],
                     "lang_days" => $lang['days'],
                     "lang_hours" => $lang['hours'],
                     "lang_minutes" => $lang['minutes']
                ));
           }
          // End Show Birthdaycountdown in Profile

    }
    else {
      $user_birthday = REPLACE_EMPTY;
    }
    // Birthday Mod

Find

Code: [Select]
"user_name" => (isset($user_row['user_name'])) ? htmlspecialchars($user_row['user_name']) : REPLACE_EMPTY,insert below
Code: [Select]
"user_birthday" => $user_birthday,
Find

Code: [Select]
$user_invisible = (isset($HTTP_POST_VARS['user_invisible'])) ? intval($HTTP_POST_VARS['user_invisible']) : 0;insert below
Code: [Select]
  $user_birthday_day = (isset($HTTP_POST_VARS['user_birthday_day'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['user_birthday_day'])) : "";
  $user_birthday_month = (isset($HTTP_POST_VARS['user_birthday_month'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['user_birthday_month'])) : "";
  $user_birthday_year = (isset($HTTP_POST_VARS['user_birthday_year'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['user_birthday_year'])) : "";

directly at the same place after

Code: [Select]
$error = 0;insert below
Code: [Select]
  if (!$user_birthday = check_birthday($user_birthday_day,$user_birthday_month,$user_birthday_year,$config['birthday_required'])) {
     $msg .= (($msg != "") ? "<br />" : "").$lang['birthday_error'];
     $error = 1;
  }

Find
Code: [Select]
      $table_fields = $site_db->get_table_fields(USERS_TABLE);
      foreach ($additional_user_fields as $key => $val) {
        if (isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])) {
          $additional_sql .= ", $key = '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
        }
      }
    }
below insert
Code: [Select]
    // Birthday Mod
    $additional_sql .= ", ".get_user_table_field("", "birthday")." = '$user_birthday'";

Find
Code: [Select]
    $user_icq = $user_info['user_icq'];
  }
and replace with
Code: [Select]
    $user_icq = $user_info['user_icq'];
      $birthday = explode("-",$user_info['birthday']);
    $user_birthday_day = $birthday[2];
    $user_birthday_month = $birthday[1];
    $user_birthday_year = $birthday[0];
  }

  $birthday_day_options = "<option value=\"\">--</option>\n";
  $birthday_month_options = "<option value=\"\">--</option>\n";

  for ($i=1;$i<=31;$i++){
    $birthday_day_options .= "<option value=\"".sprintf("%02d",$i)."\"".(($i == $user_birthday_day) ? "selected" : "").">".$i."</option>\n";

  }
  for ($i=1;$i<=12;$i++){                                                                                                                        //getmonth($i)
    $birthday_month_options .= "<option value=\"".sprintf("%02d",$i)."\"".(($i == $user_birthday_month) ? "selected" : "").">".$lang['months'][sprintf("%02d",$i)]."</option>\n";
  }

Find
Code: [Select]
"user_homepage" => htmlspecialchars(stripslashes($user_homepage)),below insert
Code: [Select]
    "birthday_day_options" => $birthday_day_options,
    "birthday_month_options" => $birthday_month_options,
    "user_birthday_year" => $user_birthday_year,
    "lang_day" => $lang['day'],
    "lang_month" => $lang['month'],
    "lang_year" => $lang['year'],

Step 6

Open templates/member_profile.html

Find
Code: [Select]
        <tr>
          <td class="row2"><b>{lang_icq}</b></td>
          <td class="row2">{if user_icq}<a href="http://wwp.icq.com/scripts/search.dll?to={user_icq}">{user_icq}</a> (<b>{user_icq_status}</b>){endif user_icq}</td>
        </tr>
below insert
Code: [Select]
        <tr>
          <td class="row1"><b>{lang_birthday}</b></td>
          <td class="row1">{if user_birthday}{user_birthday}{endif user_birthday}</td></td>
        </tr>
        {if cdown_days}
        <tr>
          <td class="row2"><b>{lang_birthday_cdown}</b></td>
          <td class="row2">{cdown_days} {lang_days} {cdown_hours} {lang_hours} {cdown_minutes} {lang_minutes} </td></td>
        </tr>
        {endif cdown_days}


Step 7

Open templates/member_editprofile.html

Find
Code: [Select]
           <tr>
            <td class="row2"><b>{lang_icq}</b></td>
            <td class="row2"><input type="text" name="user_icq"  size="30" value="{user_icq}" class="input" /></td>
          </tr>
insert below

Code: [Select]
          <tr>
             <td class="row1"><b>{lang_birthday}</b></td>
             <td class="row1"><table>
                      <tr>
                          <td>{lang_day}</td>
                          <td>{lang_month}</td>
                          <td>{lang_year}</td>
                      </tr>

                      <tr>
                           <td><select name="user_birthday_day">{birthday_day_options}</select></td>
                           <td><select name="user_birthday_month">{birthday_month_options}</select></td>
                           <td><input class="input" name="user_birthday_year" value="{user_birthday_year}" maxlength="4" size="5" type="text"></td>
                      </tr>

            </table></td>
           </tr>

Step 8

Open includes/functions.php

Search at the bottom
Code: [Select]
?>and above insert
Code: [Select]
function check_birthday($birthday_day = "", $birthday_month = "", $birthday_year = "", $valid = 0) {
  $error = 0;
  if($birthday_day && $birthday_month && $birthday_year) {
      switch(strlen($birthday_year)) {
      case 2:
          $birthday_year = "19$birthday_year";
          break;
      case 4:
          break;
      default:
        $birthday_year = "0000";
        if ($valid) $error = 1;
        break;
      }
   $birthday = "$birthday_year-$birthday_month-$birthday_day";
   }
   else {
       $birthday = "0000-00-00";
       $error = 1;
   }
   if ($valid == 1 && ($error || (!ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})", $birthday)))) return false;
   else return $birthday;
}

function calc_age ($birthday = "") {
    $user_birthday = explode("-",$birthday);
    if ($user_birthday[0]!= "0000" && $user_birthday) {
      $today = getdate (time());
      $age = ($today['year'] - $user_birthday[0]);
      if ($age > 0 )  {
      $birthday_thisyear_var = mktime(0,0,0,$user_birthday[1],$user_birthday[2],$today['year']);
      $birthday_thisyear = getdate ($birthday_thisyear_var);
      if ($birthday_thisyear['yday']>$today['yday']) $age--;
      return $age;
      }
      else return false;
    }
}

function calc_countdown ($birthday = "") {
    $user_birthday = explode("-",$birthday);
    if ($user_birthday[1] != "00" && $user_birthday[2] != "00") {
      $today = getdate (time());
      $birthday_thisyear_var = mktime(0,0,0,$user_birthday[1],$user_birthday[2],$today['year']);
      $birthday_thisyear = getdate ($birthday_thisyear_var);
      if ($birthday_thisyear['yday']<=$today['yday']) $birthday_thisyear_var = mktime(0,0,0,$user_birthday[1],$user_birthday[2],$today['year']+1);
      $difference = $birthday_thisyear_var - time();
      if ($difference < 0) $difference = 0;
      $dleft = floor($difference/60/60/24);
      $hleft = floor(($difference - $dleft*60*60*24)/60/60);
      $mleft = floor(($difference - $dleft*60*60*24 - $hleft*60*60)/60);
$return = array(
'days'=>$dleft,
'hours'=>$hleft,
'minutes'=>$mleft,
);
return $return;
    }
    else return false;
}


Step 9

Open admin/settings.php

Find the last line that is like
show_table_separator($setting_group[9], 2, "#setting_group_9");
and notice the number, and then add  1
e.g. if the highest number you can find is $setting_group[9] then the next number will be 10
You need that number to replace it for the XX in the next 2 instructions.

Find
Code: [Select]
show_form_footer($lang['save_changes'], "", 2);above insert
Code: [Select]
  //Birthday Mod
  show_table_separator($setting_group[XX], 2, "#setting_group_XX");
  show_setting_row("birthday_required", "radio");
  show_setting_row("birthday_show_profile_age", "radio");
  show_setting_row("birthday_index", "radio");
  show_setting_row("birthday_profile_countdown", "radio");
  show_setting_row("birthday_message", "radio");
  //Birthday Mod

Don't forget to replace the XX with the number mentioned above.

Step 10

Open lang/<your language>/admin.php
Find
Code: [Select]
?>insert above
Code: [Select]
/*-- Setting-Group XX --*/   // Birthday Mod
$setting_group[XX]="Birthday Config";
$setting['birthday_required'] = "Must be entered a birthday?";
$setting['birthday_show_profile_age'] = "Show also Age in Profile?";
$setting['birthday_index'] = "Show on Index Users have birthday today";
$setting['birthday_profile_countdown'] = "Show Time till next birthday in profile";
$setting['birthday_message'] = "Show Birthday Message on Index (when user has B-Day)";

or in German
Code: [Select]
/*-- Setting-Group XX --*/   // Birthday Mod
$setting_group[XX]="Geburtstags Mod Einstellung";
$setting['birthday_required'] = "Ist der Geburtstag eine Pflichtangabe?";
$setting['birthday_show_profile_age'] = "Alter im Profil anzeigen?";
$setting['birthday_index'] = "Zeige auf der Index die heutigen Geburtstage an";
$setting['birthday_profile_countdown'] = "Geburtstagscountdown im Profil";
$setting['birthday_message'] = "Geburtstagsgruss auf der Index zeigen (für User die Geb. haben)";

Don't forget to replace the XX with the number mentioned above.


Step 11

Open index.php

Find
Code: [Select]
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
above insert:
Code: [Select]
// Birthday Mod  Start Events
if($config['birthday_message'] == 1)  {
    $user_birthday = explode("-",$user_info[$user_table_fields['birthday']]);
    if (($user_birthday[1] == date ("m", time())) && ($user_birthday[2] == date ("d", time()))) {
         $birthday_message = $site_template->parse_template("birthday_message");
         $site_template->register_vars(array(
                      "birthday_message" => $birthday_message
              ));
    }
}
if($config['birthday_index'] == 1)  {
 $currentdate = date("m-d", time());
 
$sql = "SELECT ".get_user_table_field("", "user_id").", ".get_user_table_field("", "user_name").", ".get_user_table_field("", "birthday")."
          FROM ".USERS_TABLE."
          WHERE ".get_user_table_field("", "birthday")." LIKE '%-$currentdate'
          ORDER BY ".get_user_table_field("", "user_name");
$result = $site_db->query($sql);

$birthday_list = "";
   while($row = $site_db->fetch_array($result)) {
        $age = calc_age($row[$user_table_fields['birthday']]);
        $birthday_list .= ($birthday_list) ? ", " : "";
        $birthday_list .= "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row[$user_table_fields['user_id']])."\">".$row[$user_table_fields['user_name']]."</a> (".$age.")";
    }
 
$site_template->register_vars(array(
  "lang_events" => $lang['events'],
  "birthday_list" => $birthday_list,
  "lang_congratulate" => $lang['congratulate']
   ));
}

Step 12

Open templates/home.html

Find
Code: [Select]
{if categories}

insert above
Code: [Select]
                   {if birthday_message}{birthday_message}{endif birthday_message}


Find
Code: [Select]
  {whos_online}
  <br />
insert below
Code: [Select]
<!--  Start Events   -->
{if birthday_list}
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td >
      <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#000000">
        <tr>
          <td valign="top" class="head1">
            <table width="100%" border="0" cellpadding="4" cellspacing="2">
              <tr>
                <td class="head1" valign="top">{lang_events}</td>
              </tr>
            </table></td>
        </tr>

        <tr>
          <td valign="top" >
              <table  width="100%" border="0" cellpadding="4" cellspacing="1" width="98%">
              <tr>
                <td width="40" class="catbgcolor"><img src="{template_url}/images/birthday_baloon.gif" alt=""></td>
                <td class="catbgcolor"><b>{lang_congratulate}</b><br>{birthday_list}</td>
              </tr>
            </table></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<br />
{endif birthday_list}
<!--  End Events   -->

Step 12

Open lang/<your language>/main.php
Find
Code: [Select]
?>insert above
Code: [Select]
//-----------------------------------------------------
//--- Birthday Mod ---------------------------------------
//-----------------------------------------------------

$lang['days'] = "day(s)";
$lang['hours'] = "hour(s)";
$lang['minutes'] = "minute(s)";
$lang['day'] = "day";
$lang['month'] = "month";
$lang['year'] = "year";
$lang['birthday'] = "Birthday:";
$lang['birthday_cdown'] = "Time till next Birthday:";
$lang['birthday_error'] = "Please enter correct birthday";
$lang['months'] = array(
"01" => "January",
"02" => "February",
"03" => "March",
"04" => "April",
"05" => "May",
"06" => "June",
"07" => "July",
"08" => "August",
"09" => "September",
"10" => "October",
"11" => "November",
"12" => "December",
);
$lang['events'] = "Actual Events:";
$lang['congratulate'] = "Congratulations to Birthday:";


or in German /Deutsch:
Code: [Select]
//-----------------------------------------------------
//--- Birthday Mod ---------------------------------------
//-----------------------------------------------------

$lang['days'] = "Tag(e)";
$lang['hours'] = "Stunde(n)";
$lang['minutes'] = "Minute(n)";
$lang['day'] = "Tag";
$lang['month'] = "Monat";
$lang['year'] = "Jahr";
$lang['birthday'] = "Geburtstag:";
$lang['birthday_cdown'] = "Zeit bis zum nchsten Geburtstag:";
$lang['birthday_error'] = "Korrektes Geburtstagsdatum eintragen";
$lang['months'] = array(
"01" => "Januar",
"02" => "Februar",
"03" => "M&auml;rz",
"04" => "April",
"05" => "Mai",
"06" => "Juni",
"07" => "Juli",
"08" => "August",
"09" => "September",
"10" => "Oktober",
"11" => "November",
"12" => "Dezember",
);
$lang['events'] = "Actual Events:";
$lang['congratulate'] = "Congratulations to Birthday:";


an dutch langauge file can be found here:
dutch translation

Step 12

Execute the install_birthday.php on your root directory and then delete it.

Step 13
the birthday_baloon.gif must be placed in your templates/<your template folder>/images

Step 14
Upload birthday_message.html in your templates/<your templates/

You can modify your Birthday Message in that template to customize it.

Finished!



For Users that using other mods like these and wont delete the old entries of their user's birthday can use the old database entries if
the entries are given in the format like xxxx-xx-xx  (year-month-day).
That means if in USERS TABLE the field for the birthday entries are saved in DATE Format can use their entries with this mod,
by making some changes.

Here the instructions:
Just replace the value "birthday" with your db field name.

In Step 3
Code: [Select]
$additional_user_fields['birthday'] Instead of birthday use your db filed name

In Step 4
Code: [Select]
"birthday" => "birthday",Instead of => "birthday"  use your db filed name

Edit the birthday_install.php
delete the line
Code: [Select]
"ALTER TABLE `".USERS_TABLE."` ADD `birthday` DATE DEFAULT '0000-00-00' NOT NULL"
Thats all.

I've tested the mod on a fresh & clean 4images installation.



Additional Options / show asterisk (Sternzeichen):
If you want that the asterisk (german: Sternzeichen) should be displayed next to birthday in profile,
follow these steps.

Open includes/functions.php
Search for
Code: [Select]
?>insert above
Code: [Select]
function sternzeichen($tag, $monat) {
    $sternzeichen = array(
        array(mktime(0, 0, 0, 1, 1, date('Y')), mktime(0, 0, 0, 1, 20, date('Y')), 1),
        array(mktime(0, 0, 0, 1, 21, date('Y')), mktime(0, 0, 0, 2, 19, date('Y')), 2),
        array(mktime(0, 0, 0, 2, 20, date('Y')), mktime(0, 0, 0, 3, 20, date('Y')), 3),
        array(mktime(0, 0, 0, 3, 21, date('Y')), mktime(0, 0, 0, 4, 20, date('Y')), 4),
        array(mktime(0, 0, 0, 4, 21, date('Y')), mktime(0, 0, 0, 5, 21, date('Y')), 5),
        array(mktime(0, 0, 0, 5, 22, date('Y')), mktime(0, 0, 0, 6, 21, date('Y')), 6),
        array(mktime(0, 0, 0, 6, 22, date('Y')), mktime(0, 0, 0, 7, 22, date('Y')), 7),
        array(mktime(0, 0, 0, 7, 23, date('Y')), mktime(0, 0, 0, 8, 23, date('Y')), 8),
        array(mktime(0, 0, 0, 8, 24, date('Y')), mktime(0, 0, 0, 9, 23, date('Y')), 9),
        array(mktime(0, 0, 0, 9, 24, date('Y')), mktime(0, 0, 0, 10, 23, date('Y')), 10),
        array(mktime(0, 0, 0, 10, 24, date('Y')), mktime(0, 0, 0, 11, 22, date('Y')), 11),
        array(mktime(0, 0, 0, 11, 23, date('Y')), mktime(0, 0, 0, 12, 21, date('Y')), 12),
        array(mktime(0, 0, 0, 12, 22, date('Y')), mktime(0, 0, 0, 12, 31, date('Y')), 1)
    );

    foreach ($sternzeichen as $value) {
        if ((mktime(0, 0, 0, intval($monat), intval($tag), date('Y')) >= $value[0]) && (mktime(0, 0, 0, $monat, $tag, date('Y')) <= $value[1])) {
            return $value[2];
        }
    }
    return false;
}

Open lang/<your language>/main.php
Search for
Code: [Select]
?>insert above
Code: [Select]
$lang['asterisk'] = "Sternzeichen";
$lang['asterisks'] = array(
  1 => "Steinbock",
       "Wassermann",
       "Fische",
       "Widder",
       "Stier",
       "Zwillinge",
       "Krebs",
       "Löwe",
       "Jungfrau",
       "Waage",
       "Skorpion",
       "Schütze",
       "Steinbock"
);

Open templates/member_profile.html
Search for
Code: [Select]
{user_birthday}
replace it with
Code: [Select]
{user_birthday} {sternzeichen}Note: you can insert {sternzeichen} anywhere you want in that template wherever it should be displayed

Open member.php
Search for
Code: [Select]
// End Show Birthdaycountdown in Profilereplace it with
Code: [Select]
          // End Show Birthdaycountdown in Profile
          $sternzeichen = sternzeichen($birthday[2], $birthday[1]);

search for
Code: [Select]
      "user_birthday" => $user_birthday,and replace it with
Code: [Select]
      "user_birthday" => $user_birthday,
      "sternzeichen" => ($sternzeichen) ? " &nbsp;&nbsp;".$lang['asterisk']." : ".$lang['asterisks'][$sternzeichen]." "  : "",

If you want, that also the asteriks images are displayes next to birthday.
Create in your templates/<your templates>/images/ folder an new folder named sternzeichen
--> templates/<your templates>/images/sternzeichen
There you should place 12 images named from 1.jpg to 12.jpg,
which are the corresponding images like the asterisk.
you can find some images attached. thx to trez for these images.
Here you can find also some from Loda



you should use following code instead
Code: [Select]
      "user_birthday" => $user_birthday,
      "sternzeichen" => ($sternzeichen) ? " &nbsp;&nbsp;".$lang['asterisk']." : ".$lang['asterisks'][$sternzeichen]." "  : "",
user following
Code: [Select]
      "sternzeichen" => ($sternzeichen) ? " &nbsp;&nbsp;".$lang['asterisk']." : ".$lang['asterisks'][$sternzeichen]." <img src=\"".TEMPLATE_PATH."/images/sternzeichen/".$sternzeichen.".jpg\" alt=\"".$lang['asterisks'][$sternzeichen]."\">"  : "",
finished!

P.S.: Maybe someone can translate the asteriks language into english.


17.02. Added additonal option

@German Users: check your language/<your language>/main.php
I did a correction above, cause "03" => "M&auml;", should be like this "03" => "M&auml;rz",
Otherwise only Mä is displayed instead of März.
Corrected above.


Installer and needed files are attached.
You can also download it from here: Link
Just log in as 4images/4images.
Of course you can also create your own account (no email verification is needed, cause its an testboard).
Demo can be also seen there.
« Last Edit: March 23, 2006, 05:33:31 PM by IcEcReaM »
Coding is a everlasting competition between programmers who tries to write larger, better and idiot-safe programs and the universe producing larger and stupider idiots...
...so far the universe won
bump

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: Birthday Mod v1.0
« Reply #1 on: February 10, 2006, 10:53:26 AM »
... very nice MOD ... especially the birthday countdown ... and the birthday_baloon ...  :wink:
... a very good and clear presentation ...
... thanks for it ...

mawenzi
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline Loda

  • Sr. Member
  • ****
  • Posts: 353
    • View Profile
    • Fotosucht Schweiz
Re: Birthday Mod v1.0
« Reply #2 on: February 10, 2006, 01:59:06 PM »
WOW!
thank you very much for this great mod! works perfekt!
only the installation file don't work for me and so i made it manuell.

Offline insane

  • Newbie
  • *
  • Posts: 47
    • View Profile
    • Gallery
Re: Birthday Mod v1.0
« Reply #3 on: February 10, 2006, 02:59:48 PM »
whats the db field name?
where can i find it?
do i have to do all again? (i already executed the birthday_install.php)
« Last Edit: February 10, 2006, 03:09:51 PM by insane »

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: Birthday Mod v1.0
« Reply #4 on: February 10, 2006, 04:28:18 PM »
Quote

// Birthday Mod
    $additional_sql .= ", ".get_user_table_field("", "birthday")." = '$user_birthday'";


I have been told recently that the get_user_table_field function only complys with the core fields within the USERS_TABLE and not on additional user fields. ;)

Meaning, the above should be changed to :

Code: [Select]

// Birthday Mod
    $additional_sql .= ", birthday" = ".$user_birthday;


;)

In the mean time, could we see a screenshot of this presentation ? ;)

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: Birthday Mod v1.0
« Reply #5 on: February 10, 2006, 05:10:21 PM »
So this show "Today Birthday's " ?? on Home ?  :roll:

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: Birthday Mod v1.0
« Reply #6 on: February 10, 2006, 05:20:23 PM »
So this show "Today Birthday's " ?? on Home ?  :roll:

Please read the changed files from the first post. It mentions index.php file. In the mean time, read step 11. ;)

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: Birthday Mod v1.0
« Reply #7 on: February 10, 2006, 05:22:59 PM »
@icecream:

By the way, since you added this :

Quote

$birthday_list = "";


find :

Quote

$site_template->register_vars(array(
  "lang_events" => $lang['events'],
  "birthday_list" => $birthday_list,
  "lang_congratulate" => $lang['congratulate']
   ));
}


replace with :

Code: [Select]

$site_template->register_vars(array(
  "lang_events" => $lang['events'],
  "birthday_list" => $birthday_list,
  "lang_congratulate" => $lang['congratulate']
   ));

unset ($birthday_list);
}


Then :

Quote

$sql = "SELECT ".get_user_table_field("", "user_id").", ".get_user_table_field("", "user_name").", ".get_user_table_field("", "birthday")."
          FROM ".USERS_TABLE."
          WHERE ".get_user_table_field("", "birthday")." LIKE '%-$currentdate'
          ORDER BY ".get_user_table_field("", "user_name");


to read :

Code: [Select]

$sql = "SELECT ".get_user_table_field("", "user_id").", ".get_user_table_field("", "user_name").", "birthday"
          FROM ".USERS_TABLE."
          WHERE birthday LIKE '%-$currentdate'
          ORDER BY ".get_user_table_field("", "user_name");


;)

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: Birthday Mod v1.0
« Reply #8 on: February 10, 2006, 05:37:54 PM »
But another question , for who have used the User Age V.1  ?  :oops:

we need uninstall all your make some modifications ? or we can install it without any problem ? :|

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: Birthday Mod v1.0
« Reply #9 on: February 10, 2006, 05:54:48 PM »
on birthday MOD installer :

Quote
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/blacktra/public_html/test-gallery/birthday_install.php on line 14

 :|

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: Birthday Mod v1.0
« Reply #10 on: February 10, 2006, 06:28:46 PM »
I could be wrong but

change :

Quote

NOT NULL"


to :

Code: [Select]

NOT NULL",


Then, try the installation file again.

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: Birthday Mod v1.0
« Reply #11 on: February 10, 2006, 07:06:34 PM »
this have work  :D

So Let's see it working  8)

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: Birthday Mod v1.0
« Reply #12 on: February 10, 2006, 07:12:32 PM »
Another question its how make it show 1 username by line :

user1 (xx)
user 2 (xx)



 :?:

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: Birthday Mod v1.0
« Reply #13 on: February 10, 2006, 07:16:58 PM »
In index.php file,

find :

Quote

$birthday_list .= "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row[$user_table_fields['user_id']])."\">".$row[$user_table_fields['user_name']]."</a> (".$age.")";


replace with :

Code: [Select]

$birthday_list .= "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row[$user_table_fields['user_id']])."\">".$row[$user_table_fields['user_name']]."</a> (".$age.")<br />";


Offline IcEcReaM

  • Hero Member
  • *****
  • Posts: 714
    • View Profile
    • My little Testboard
Re: Birthday Mod v1.0
« Reply #14 on: February 10, 2006, 10:18:09 PM »
... a very good and clear presentation ...

yep, i learned from the others, how it should be,
although it takes a lot of time just for the documention and testing on a fresh 4images install.
Thats why i didn't like to publish such mods.. :mrgreen:

only the installation file don't work for me and so i made it manuell.

Fixed the installation file,
i uploaded the wrong file from the wrong folder.. :oops:




I have been told recently that the get_user_table_field function only complys with the core fields within the USERS_TABLE and not on additional user fields. ;)

In the mean time, could we see a screenshot of this presentation ? ;)

Then look at step 4, then you can use it also.
I had to do it like this way,
so users don't need to delete their old entries if using an another mod,
and what was much important to me i had to do this for me to work because of some other reasons.
So this mod is more flexible and 4images conform.

The code i posted in my first post works the way i did,
also with the get_user_table_fields... don't need to make that changes you posted.


But another question , for who have used the User Age V.1  ?  :oops:

we need uninstall all your make some modifications ? or we can install it without any problem ? :|

You has to do deinstall the other mod, but NOT delete the DB Field,
cause you can use the old entries with this mod again,
just follow the last instructions for users have other mods.

Quote
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/blacktra/public_html/test-gallery/birthday_install.php on line 14

Fixed


Coding is a everlasting competition between programmers who tries to write larger, better and idiot-safe programs and the universe producing larger and stupider idiots...
...so far the universe won
bump