############################################################## ## MOD Title: Birthday ## MOD Author: Niels < ncr@db9.dk > (Niels Chr. Rød) http://mods.db9.dk ## MOD Description: This mod will add a birthday field into your ## user's profile and make users age viewable ## to others when viewing posts. ## MOD Version: 1.5.9 ## ## Installation Level: Advanced ## Installation Time: 30 Minutes (1mn by EasyMOD of Nuttzy) ## Files To Edit: ## index.php ## viewtopic.php ## admin/admin_board.php ## admin/admin_users.php ## includes/functions.php ## includes/page_header.php ## includes/usercp_avatar.php ## includes/usercp_register.php ## includes/usercp_viewprofile.php ## language/lang_english/lang_admin.php ## language/lang_english/lang_main.php ## templates/subSilver/index_body.tpl ## templates/subSilver/overall_header.tpl ## templates/subSilver/profile_add_body.tpl ## templates/subSilver/profile_view_body.tpl ## templates/subSilver/viewtopic_body.tpl ## templates/subSilver/admin/board_config_body.tpl ## templates/subSilver/admin/user_edit_body.tpl ## Included Files: ## root/birthday_popup.php ## root/templates/subSilver/greeting_popup.tpl ## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2 ############################################################## ## For security purposes, please check: http://www.phpbb.com/mods/ ## for the latest version of this MOD. Although MODs are checked ## before being allowed in the MODs Database there is no guarantee ## that there are no security problems within the MOD. No support ## will be given for MODs not found within the MODs Database which ## can be found at http://www.phpbb.com/mods/ ############################################################## ## Author Notes: ## ## 1. Full MOD description ## ----------- ## This mod will add a birthday field into your user's profile ## and make users age viewable to others when viewing posts. ## Users who not specify a birthday, the script will default ## to "None Specified." ## At the day of the users birthday (next visit) the board can ## be configured to display a birthday greeting . ## ## 2. EasyMOD ## ----------- ## This MOD is compatible with EasyMOD and can be installed ## by it but is not yet certified EMC (EasyMOD Compliant)! ## http://area51.phpbb.com/phpBB22/viewforum.php?sid=&f=15 ## ## Warning 1! At the minimum, you need EasyMOD beta 1 (0.2.1a) or ## more recent to install this MOD by EM! ## ## Warning 2! At the present time, EM is not able to install ## automatically other languages than English. ## This gap will be solved in future releases but in the meantime, ## if you need to install any other language than English provides ## with this MOD, please proceed manually (cf. comments in ## the DIY action). ## ## 3. Compatibility ## ----------- ## This MOD is phpBB 2.0.20 compliant ## ## 4. Official last version link ## ----------- ## Meanwhile the phpBB group validation and as the MOD is not yet ## in the phpBB MOD database, check this official link for updates... ## http://mods.db9.dk/viewtopic.php?t=6 ## ############################################################## ## MOD History: ## ## 2006-04-16 - Version 1.5.9 ## - Modify a FIND to be phpBB 2.0.20 compliant ## ## 2006-01-12 - Version 1.5.8 ## - phpBB template & EasyMOD compliance enhancement ## - Modify 2 FIND instructions to be phpBB 2.0.18+ compliant ## - Include the sql queries in the MOD and remove the ## birthday_db_update.php file ## - Add DIY instructions to install other languages than English ## - Use the INCREMENT instruction to increment the ## whosonline.gif rowspan ## ## 2004-09-12 - Version 1.5.7 ## - timezone fix, to page_header.php - a typo, made popup happen without timezone applyed ## ## 2004-04-25 - Version 1.5.6 ## - add or update the Dutch, French, Hungarian, Icelandic, ## Romanian, Slovak, polish & Spanish translation in the MOD archive ## - add the 2 zodiac optional features and their available ## translations in the MOD archive ## ## 2004-04-22 - Version 1.5.5 ## - fixed a isue in index.php, witch couse a error if username have special chars ## ## 2003-12-10 - Version 1.5.4 ## - changed the sql into index.php, with a more standart sql ## ## 2003-12-07 - Version 1.5.3 ## - phpBB template & EasyMOD compliance enhancement ## - Chinese Traditional Taiwan, Dutch, Estonian, French, ## German & Thai translations now provide with the MOD ## ## 2003-10-13 - Version 1.5.2 ## - corrected index.php, allowing lookforward set to 0 ## ## 2003-08-27 - Version 1.5.1 ## - Corrected the how-to for Subsilver -> subSilver, ## making it work on *NIX OS ## - corrected the how-to for usercp_viewprofile.php, to ## make it work beter with the ADD-ON's ## ## 2003-08-27 - Version 1.5.0 ## - Now ready for 2.0.6. and EM ## - merged part 1 and part 2, now only one larger "how-to", ## part 3 and 4 will be renamed to "ADD-ON" 1 and 2 ## ## 2003-08-03 - Version 1.4.21 ## - fixed a language isue with the new code in functions.php ## ## 2003-08-02 - Version 1.4.20 ## - corrected the how-to, regarding file functions.php ## ## ????-??-?? - Version 1.4.19 ## - corrected 1.4.18. update (index.php) ## ## ????-??-?? - Version 1.4.18 ## - corrected 1.4.17. update (functions.php/index.php) ## ## ????-??-?? - Version 1.4.17 ## - change some code, witch should respond faster ## ## ????-??-?? - Version 1.4.16 ## - confirmed for 2.0.5. by "kooky" ## ## ????-??-?? - Version 1.4.15 ## - corrected the find tag once again, SECURITY RISK ## ## ????-??-?? - Version 1.4.14 ## - changed a find tag, witch was giving some users truble ## using, if other mods ## ## ????-??-?? - Version 1.4.13 ## - cosmetic changes ## ## ????-??-?? - Version 1.4.12 ## - corrected a misbehaiver, if user was registering and ## a error occoured ## ## ????-??-?? - Version 1.4.11 ## - corrected a typo in the usercp_register, regarding ## popup messages ## ## ????-??-?? - Version 1.4.10 ## - removed a free_result, since mySQL 4.x users did ## have problem with this ## ## ????-??-?? - Version 1.4.9 ## - fixed a problem, if avartar is viewed in user edit, ## and no birthday was selected ## ## ????-??-?? - Version 1.4.8 ## - changed a find tag in usercp_register.php ## ## ????-??-?? - Version 1.4.7 ## - improved page_header.php ## ## ????-??-?? - Version 1.4.6 ## - made it posible to specify user must submit birthday ## ## ????-??-?? - Version 1.4.5 ## - made 2 tags identicall ## ## ????-??-?? - Version 1.4.4 ## - still some typos in the how-to regarding $n / $i in ## viewtopic.php ## ## ????-??-?? - Version 1.4.3 ## - corrected zodiac in viewtopic, so if no birthday, ## no zodiac is showen ## ## ????-??-?? - Version 1.4.2 ## - corrected the viewtopic.php, zodiac should only be ## inserted, if part 3 are installed ## ## ????-??-?? - Version 1.4.1 ## - cosmetic change in viewtopic_body.tpl ## ## ????-??-?? - Version 1.4.0 ## - confirmed for ver 2.0.4, change in usercp_register.php, ## lang_main.php ## ## ????-??-?? - Version 1.3.16 ## - '//' is changed to '//W' in functions.php ## ## ????-??-?? - Version 1.3.15 ## - users birthday was "reset" if other errors occour ## in usercp_register.php ## ## ????-??-?? - Version 1.3.14 ## - a $$ is changed to a $ in index.php ## ## ????-??-?? - Version 1.3.13 ## - fix, date of 1. was showen as last day in previous month ## ## ????-??-?? - Version 1.3.12 ## - if no users in list a "array" was showen, ## this is now corrected ## ## ????-??-?? - Version 1.3.11 ## - usernames on index sepperated by commas ## ## ????-??-?? - Version 1.3.10 ## - missed some language updates for ver 1.3.9 ## ## ????-??-?? - Version 1.3.9 ## - fix, age calculation around year shift ## ## ????-??-?? - Version 1.3.8 ## - code in functions.php improved ## ## ????-??-?? - Version 1.3.7 ## - code in ver 1.3.6. improved ## ## ????-??-?? - Version 1.3.6 ## - improved drop down, thanks to "weaselweb" ## ## ????-??-?? - Version 1.3.5 ## - there was a typo in the how-to regarding page_header.php ## ## ????-??-?? - Version 1.3.4 ## - calculation of dates now correct on 31-12 if leap ## year and date > 1970 ## ## ????-??-?? - Version 1.3.3 ## - corrected some typo's related to user_register.php ## introduced in ver 1.3.0 ## ## ????-??-?? - Version 1.3.2 ## - included the file birthday_popup.php, now changes ## to privmsg.php are not nessesary ## ## ????-??-?? - Version 1.3.1 ## - fix a bug in index.php ## ## ????-??-?? - Version 1.3.0 ## - Now support drop down box as input for birthday in ## users profile ## ## ????-??-?? - Version 1.2.2 ## - $year changed to $birth_year, to avoid complications ## together with other mods ## ## ????-??-?? - Version 1.2.1 ## - have missed to include some changes in the how-to, ## regarding viewtopic.php ## ## ????-??-?? - Version 1.2.0 ## - now confirmed for phpBB2 version 2.0.2 ## ## ????-??-?? - Version 1.1.14 ## - fixed a mistake in index.php, that causes no users ## to have birthday ## ## ????-??-?? - Version 1.1.13 ## - fixed a wrong FIND after the speed improvements ## ## ????-??-?? - Version 1.1.12 ## - speed improvements, I have moved some of the code ## from page_header.php to index.php, it turn out that ## none was using the info on other pages, so no need ## for them there ## ## ????-??-?? - Version 1.1.11 ## - the english language file, have now changed a few ## places thanks to "mr Cru" ## ## ????-??-?? - Version 1.1.10 ## - minor change the lang_main.php, $lang['Birthday_explain'] ## to properly support different birthday formats ## ## ????-??-?? - Version 1.1.9 ## - fix a missing tag in profile_add_body.tpl ## ## ????-??-?? - Version 1.1.8 ## - history started, improved page_header.php ## ## ????-??-?? - Version 1.1.0 ## - initial relese phpBB2 ver 2.0.0. ## ## ????-??-?? - Version 1.0.0 ## - initial release ## ## ????-??-?? - Version 0.9.0 ## - initial BETA release phpBB2 RC-2 ## ############################################################## ## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD ############################################################## # #-----[ SQL ]------------------------------------------------- # ALTER TABLE phpbb_users ADD user_birthday INT DEFAULT '999999' not null; ALTER TABLE phpbb_users ADD user_next_birthday_greeting INT DEFAULT '0' not null; INSERT INTO phpbb_config (config_name, config_value) VALUES ('birthday_required', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('birthday_greeting', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_user_age', '100'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('min_user_age', '5'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('birthday_check_day', '7'); # #-----[ COPY ]------------------------------------------------ # copy root/birthday_popup.php to birthday_popup.php copy root/templates/subSilver/greeting_popup.tpl to templates/subSilver/greeting_popup.tpl # #-----[ 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 += 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'] = '' . $birthdayrow['username'] . ''; $style_color = 'style="color:#' . $theme['fontcolor3'] . '"'; break; case MOD : $birthdayrow['username'] = '' . $birthdayrow['username'] . ''; $style_color = 'style="color:#' . $theme['fontcolor2'] . '"'; break; default: $style_color = ''; } $birthday_week_list .= ' ' . $birthdayrow['username'] . ' ('.$user_age.'),'; } 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'] = '' . $birthdayrow['username'] . ''; $style_color = 'style="color:#' . $theme['fontcolor3'] . '"'; break; case MOD : $birthdayrow['username'] = '' . $birthdayrow['username'] . ''; $style_color = 'style="color:#' . $theme['fontcolor2'] . '"'; break; default: $style_color = ''; } $birthday_today_list .= ' ' . $birthdayrow['username'] . ' ('.$user_age.'),'; } } 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); } # #-----[ FIND ]------------------------------------------------ # 'L_FORUM' => # #-----[ BEFORE, ADD ]----------------------------------------- # // Start add - Birthday MOD 'L_WHOSBIRTHDAY_WEEK' => ($board_config['birthday_check_day'] > 1) ? sprintf( (($birthday_week_list) ? $lang['Birthday_week'] : $lang['Nobirthday_week']), $board_config['birthday_check_day']).$birthday_week_list : '', 'L_WHOSBIRTHDAY_TODAY' => ($board_config['birthday_check_day']) ? ($birthday_today_list) ? $lang['Birthday_today'].$birthday_today_list : $lang['Nobirthday_today'] : '', // End add - Birthday MOD # #-----[ OPEN ]------------------------------------------------ # viewtopic.php # #-----[ FIND ]------------------------------------------------ # $sql = "SELECT u.username, # #-----[ IN-LINE FIND ]---------------------------------------- # , u.user_allowsmile # #-----[ IN-LINE AFTER, ADD ]---------------------------------- # , u.user_birthday, u.user_next_birthday_greeting # #-----[ FIND ]------------------------------------------------ # for($i = 0; $i < $total_posts; $i++) # #-----[ BEFORE, ADD ]----------------------------------------- # // Start add - Birthday MOD $this_year = create_date('Y', time(), $board_config['board_timezone']); $this_date = create_date('md', time(), $board_config['board_timezone']); // End add - Birthday MOD # #-----[ FIND ]------------------------------------------------ # $poster_id = $postrow[$i]['user_id']; $poster = ( $poster_id == ANONYMOUS ) ? $lang['Guest'] : $postrow[$i]['username']; # #-----[ AFTER, ADD ]------------------------------------------ # // Start add - Birthday MOD if ( $postrow[$i]['user_birthday'] != 999999 ) { $poster_birthdate=realdate('md', $postrow[$i]['user_birthday']); $poster_age = $this_year - realdate ('Y',$postrow[$i]['user_birthday']); if ($this_date < $poster_birthdate) $poster_age--; $poster_age = $lang['Age'] . ': ' . $poster_age; } else { $poster_age = ''; } // End add - Birthday MOD # #-----[ FIND ]------------------------------------------------ # if ( $poster_id == ANONYMOUS && $postrow[$i]['post_username'] != '' ) { $poster = $postrow[$i]['post_username']; $poster_rank = $lang['Guest']; # #-----[ AFTER, ADD ]------------------------------------------ # // Start add - Birthday MOD $poster_age = ''; // End add - Birthday MOD # #-----[ FIND ]------------------------------------------------ # 'POSTER_NAME' => # #-----[ AFTER, ADD ]------------------------------------------ # // Start add - Birthday MOD 'POSTER_AGE' => $poster_age, // End add - Birthday MOD # #-----[ OPEN ]------------------------------------------------ # admin/admin_board.php # #-----[ FIND ]------------------------------------------------ # $prune_no = ( !$new['prune_enable'] ) ? "checked=\"checked\"" : ""; # #-----[ AFTER, ADD ]------------------------------------------ # // Start add - Birthday MOD $birthday_greeting_yes = ( $new['birthday_greeting'] ) ? "checked=\"checked\"" : ""; $birthday_greeting_no = ( !$new['birthday_greeting'] ) ? "checked=\"checked\"" : ""; $birthday_required_yes = ( $new['birthday_required'] ) ? "checked=\"checked\"" : ""; $birthday_required_no = ( !$new['birthday_required'] ) ? "checked=\"checked\"" : ""; // End add - Birthday MOD # #-----[ FIND ]------------------------------------------------ # "L_ENABLE_PRUNE" => # #-----[ AFTER, ADD ]------------------------------------------ # // Start add - Birthday MOD "L_ENABLE_BIRTHDAY_GREETING" => $lang['Enable_birthday_greeting'], "L_BIRTHDAY_GREETING_EXPLAIN" => $lang['Birthday_greeting_expain'], "L_BIRTHDAY_REQUIRED" => $lang['Birthday_required'], "L_MAX_USER_AGE" => $lang['Max_user_age'], "L_MIN_USER_AGE" => $lang['Min_user_age'], "L_MIN_USER_AGE_EXPLAIN" => $lang['Min_user_age_explain'], "L_BIRTHDAY_LOOKFORWARD" => $lang['Birthday_lookforward'], "L_BIRTHDAY_LOOKFORWARD_EXPLAIN" => $lang['Birthday_lookforward_explain'], // End add - Birthday MOD # #-----[ FIND ]------------------------------------------------ # "PRUNE_NO" => # #-----[ AFTER, ADD ]------------------------------------------ # // Start add - Birthday MOD "BIRTHDAY_GREETING_YES" => $birthday_greeting_yes, "BIRTHDAY_GREETING_NO" => $birthday_greeting_no, "BIRTHDAY_REQUIRED_YES" => $birthday_required_yes, "BIRTHDAY_REQUIRED_NO" => $birthday_required_no, "MAX_USER_AGE" => $new['max_user_age'], "MIN_USER_AGE" => $new['min_user_age'], "BIRTHDAY_LOOKFORWARD" => $new['birthday_check_day'], // End add - Birthday MOD # #-----[ OPEN ]------------------------------------------------ # admin/admin_users.php # #-----[ FIND ]------------------------------------------------ # $interests = ( !empty($HTTP_POST_VARS['interests']) ) ? trim(strip_tags( $HTTP_POST_VARS['interests'] ) ) : ''; # #-----[ AFTER, ADD ]------------------------------------------ # // Start add - Birthday MOD if (isset($HTTP_POST_VARS['birthday']) ) { $birthday = intval ($HTTP_POST_VARS['birthday']); $b_day = realdate('j',$birthday); $b_md = realdate('n',$birthday); $b_year = realdate('Y',$birthday); } else { $b_day = ( isset($HTTP_POST_VARS['b_day']) ) ? intval ($HTTP_POST_VARS['b_day']) : 0; $b_md = ( isset($HTTP_POST_VARS['b_md']) ) ? intval ($HTTP_POST_VARS['b_md']) : 0; $b_year = ( isset($HTTP_POST_VARS['b_year']) ) ? intval ($HTTP_POST_VARS['b_year']) : 0; $birthday = mkrealdate($b_day,$b_md,$b_year); } $next_birthday_greeting = ( !empty($HTTP_POST_VARS['next_birthday_greeting']) ) ? intval( $HTTP_POST_VARS['next_birthday_greeting'] ) : 0; // End add - Birthday MOD # #-----[ FIND ]------------------------------------------------ # // // Update entry in DB # #-----[ BEFORE, ADD ]----------------------------------------- # // Start add - Birthday MOD // find the birthday values, reflected by the $lang['Submit_date_format'] if ($b_day || $b_md || $b_year) //if a birthday is submited, then validate it { $user_age=(date('md')>=$b_md.(($b_day <= 9) ? '0':'').$b_day) ? date('Y') - $b_year : date('Y') - $b_year - 1 ; // Check date, maximum / minimum user age if (!checkdate($b_md,$b_day,$b_year)) { $error = TRUE; if( isset($error_msg) )$error_msg .= "
"; $error_msg .= $lang['Wrong_birthday_format']; } else if ($user_age>$board_config['max_user_age']) { $error = TRUE; if( isset($error_msg) )$error_msg .= "
"; $error_msg .= sprintf($lang['Birthday_to_high'],$board_config['max_user_age']); } else if ($user_age<$board_config['min_user_age']) { $error = TRUE; if( isset($error_msg) )$error_msg .= "
"; $error_msg .= sprintf($lang['Birthday_to_low'],$board_config['min_user_age']); } else { $birthday = ($error) ? $birthday : mkrealdate($b_day,$b_md,$b_year); } } else $birthday = ($error) ? '' : 999999; // End add - Birthday MOD # #-----[ FIND ]------------------------------------------------ # $sql = "UPDATE " . USERS_TABLE . " SET # #-----[ IN-LINE FIND ]---------------------------------------- # str_replace("\'", "''", $interests) . "' # #-----[ IN-LINE AFTER, ADD ]---------------------------------- # , user_birthday='$birthday', user_next_birthday_greeting=$next_birthday_greeting # #-----[ FIND ]------------------------------------------------ # $interests = htmlspecialchars($this_userdata['user_interests']); # #-----[ AFTER, ADD ]------------------------------------------ # // Start add - Birthday MOD $next_birthday_greeting = $this_userdata['user_next_birthday_greeting']; if ($this_userdata['user_birthday']!=999999) { $birthday = realdate($lang['Submit_date_format'],$this_userdata['user_birthday']); $b_day = realdate('j',$this_userdata['user_birthday']); $b_md = realdate('n',$this_userdata['user_birthday']); $b_year = realdate('Y',$this_userdata['user_birthday']); } else { $b_day = ''; $b_md = ''; $b_year = ''; $birthday = ''; } // End add - Birthday MOD # #-----[ FIND ]------------------------------------------------ # $s_hidden_fields .= ''; # #-----[ AFTER, ADD ]------------------------------------------ # // Start add - Birthday MOD $s_hidden_fields .= ''; $s_hidden_fields .= ''; // End add - Birthday MOD # #-----[ FIND ]------------------------------------------------ # "body" => "admin/user_edit_body.tpl") ); # #-----[ AFTER, ADD ]------------------------------------------ # // Start add - Birthday MOD $s_b_day = '' . $lang['Day'] . '   '; $s_b_md = '' . $lang['Month'] . '   '; $s_b_day= str_replace("value=\"".$b_day."\">", "value=\"".$b_day."\" SELECTED>" ,$s_b_day); $s_b_md = str_replace("value=\"".$b_md."\">", "value=\"".$b_md."\" SELECTED>" ,$s_b_md); $s_b_year = '' . $lang['Year'] . '   '; $i = 0; $s_birthday = ''; for ($i=0;$i<=strlen($lang['Submit_date_format']);$i++) { switch ($lang['Submit_date_format'][$i]) { case d: $s_birthday .=$s_b_day;break; case m: $s_birthday .=$s_b_md;break; case Y: $s_birthday .=$s_b_year;break; } } // End add - Birthday MOD # #-----[ FIND ]------------------------------------------------ # 'INTERESTS' => # #-----[ AFTER, ADD ]------------------------------------------ # // Start add - Birthday MOD 'NEXT_BIRTHDAY_GREETING' => $next_birthday_greeting, 'S_BIRTHDAY' => $s_birthday, // End add - Birthday MOD # #-----[ FIND ]------------------------------------------------ # 'L_INTERESTS' => # #-----[ AFTER, ADD ]------------------------------------------ # // Start add - Birthday MOD 'L_BIRTHDAY' => $lang['Birthday'], 'L_NEXT_BIRTHDAY_GREETING' => $lang['Next_birthday_greeting'], 'L_NEXT_BIRTHDAY_GREETING_EXPLAIN' => $lang['Next_birthday_greeting_expain'], // End add - Birthday MOD # #-----[ OPEN ]------------------------------------------------ # includes/functions.php # #-----[ FIND ]------------------------------------------------ # ?> # #-----[ BEFORE, ADD ]----------------------------------------- # // Add function mkrealdate for Birthday MOD // the originate php "mktime()", does not work proberly on all OS, especially when going back in time // before year 1970 (year 0), this function "mkrealtime()", has a mutch larger valid date range, // from 1901 - 2099. it returns a "like" UNIX timestamp divided by 86400, so // calculation from the originate php date and mktime is easy. // mkrealdate, returns the number of day (with sign) from 1.1.1970. function mkrealdate($day,$month,$birth_year) { // range check months if ($month<1 || $month>12) return "error"; // range check days switch ($month) { case 1: if ($day>31) return "error";break; case 2: if ($day>29) return "error"; $epoch=$epoch+31;break; case 3: if ($day>31) return "error"; $epoch=$epoch+59;break; case 4: if ($day>30) return "error" ; $epoch=$epoch+90;break; case 5: if ($day>31) return "error"; $epoch=$epoch+120;break; case 6: if ($day>30) return "error"; $epoch=$epoch+151;break; case 7: if ($day>31) return "error"; $epoch=$epoch+181;break; case 8: if ($day>31) return "error"; $epoch=$epoch+212;break; case 9: if ($day>30) return "error"; $epoch=$epoch+243;break; case 10: if ($day>31) return "error"; $epoch=$epoch+273;break; case 11: if ($day>30) return "error"; $epoch=$epoch+304;break; case 12: if ($day>31) return "error"; $epoch=$epoch+334;break; } $epoch=$epoch+$day; $epoch_Y=sqrt(($birth_year-1970)*($birth_year-1970)); $leapyear=round((($epoch_Y+2) / 4)-.5); if (($epoch_Y+2)%4==0) {// curent year is leapyear $leapyear--; if ($birth_year >1970 && $month>=3) $epoch=$epoch+1; if ($birth_year <1970 && $month<3) $epoch=$epoch-1; } else if ($month==2 && $day>28) return "error";//only 28 days in feb. //year if ($birth_year>1970) $epoch=$epoch+$epoch_Y*365-1+$leapyear; else $epoch=$epoch-$epoch_Y*365-1-$leapyear; return $epoch; } // Add function realdate for Birthday MOD // the originate php "date()", does not work proberly on all OS, especially when going back in time // before year 1970 (year 0), this function "realdate()", has a mutch larger valid date range, // from 1901 - 2099. it returns a "like" UNIX date format (only date, related letters may be used, due to the fact that // the given date value should already be divided by 86400 - leaving no time information left) // a input like a UNIX timestamp divided by 86400 is expected, so // calculation from the originate php date and mktime is easy. // e.g. realdate ("m d Y", 3) returns the string "1 3 1970" // UNIX users should replace this function with the below code, since this should be faster // //function realdate($date_syntax="Ymd",$date=0) //{ return create_date($date_syntax,$date*86400+1,0); } function realdate($date_syntax="Ymd",$date=0) { global $lang; $i=2; if ($date>=0) { return create_date($date_syntax,$date*86400+1,0); } else { $year= -(date%1461); $days = $date + $year*1461; while ($days<0) { $year--; $days+=365; if ($i++==3) { $i=0; $days++; } } } $leap_year = ($i==0) ? TRUE : FALSE; $months_array = ($i==0) ? array (0,31,60,91,121,152,182,213,244,274,305,335,366) : array (0,31,59,90,120,151,181,212,243,273,304,334,365); for ($month=1;$month<12;$month++) { if ($days<$months_array[$month]) break; } $day=$days-$months_array[$month-1]+1; //you may gain speed performance by remove som of the below entry's if they are not needed/used return strtr ($date_syntax, array( 'a' => '', 'A' => '', '\\d' => 'd', 'd' => ($day>9) ? $day : '0'.$day, '\\D' => 'D', 'D' => $lang['day_short'][($date-3)%7], '\\F' => 'F', 'F' => $lang['month_long'][$month-1], 'g' => '', 'G' => '', 'H' => '', 'h' => '', 'i' => '', 'I' => '', '\\j' => 'j', 'j' => $day, '\\l' => 'l', 'l' => $lang['day_long'][($date-3)%7], '\\L' => 'L', 'L' => $leap_year, '\\m' => 'm', 'm' => ($month>9) ? $month : '0'.$month, '\\M' => 'M', 'M' => $lang['month_short'][$month-1], '\\n' => 'n', 'n' => $month, 'O' => '', 's' => '', 'S' => '', '\\t' => 't', 't' => $months_array[$month]-$months_array[$month-1], 'w' => '', '\\y' => 'y', 'y' => ($year>29) ? $year-30 : $year+70, '\\Y' => 'Y', 'Y' => $year+1970, '\\z' => 'z', 'z' => $days, '\\W' => '', 'W' => '') ); } // End add - Birthday MOD # #-----[ OPEN ]------------------------------------------------ # includes/page_header.php # #-----[ FIND ]------------------------------------------------ # if ( ($userdata['session_logged_in']) && (empty($gen_simple_header)) ) { # #-----[ AFTER, ADD ]------------------------------------------ # // Start add - Birthday MOD // see if user has or have had birthday, also see if greeting are enabled if ( $userdata['user_birthday']!=999999 && $board_config['birthday_greeting'] && create_date('Ymd', time(), $board_config['board_timezone']) >= $userdata['user_next_birthday_greeting'].realdate ('md',$userdata['user_birthday'] ) ) { $sql = "UPDATE " . USERS_TABLE . " SET user_next_birthday_greeting = " . (create_date('Y', time(), $board_config['board_timezone'])+1) . " WHERE user_id = " . $userdata['user_id']; if( !$status = $db->sql_query($sql) ) { message_die(GENERAL_ERROR, "Could not update next_birthday_greeting for user.", "", __LINE__, __FILE__, $sql); } $template->assign_var("GREETING_POPUP", ""); } //Sorry user shall not have a greeting this year // End add - Birthday MOD # #-----[ OPEN ]------------------------------------------------ # includes/usercp_avatar.php # #-----[ FIND ]------------------------------------------------ # function display_avatar_gallery( # #-----[ IN-LINE FIND ]---------------------------------------- # ) # #-----[ IN-LINE BEFORE, ADD ]--------------------------------- # , &$birthday # #-----[ FIND ]------------------------------------------------ # $params = array( # #-----[ IN-LINE FIND ]---------------------------------------- # ); # #-----[ IN-LINE BEFORE, ADD ]--------------------------------- # , 'birthday' # #-----[ OPEN ]------------------------------------------------ # includes/usercp_register.php # #-----[ FIND ]------------------------------------------------ # $signature_bbcode_uid = ''; # #-----[ AFTER, ADD ]------------------------------------------ # // Start add - Birthday MOD if (isset($HTTP_POST_VARS['birthday']) ) { $birthday = intval ($HTTP_POST_VARS['birthday']); if ($birthday!=999999) { $b_day = realdate('j',$birthday); $b_md = realdate('n',$birthday); $b_year = realdate('Y',$birthday); } } else { $b_day = ( isset($HTTP_POST_VARS['b_day']) ) ? intval ($HTTP_POST_VARS['b_day']) : 0; $b_md = ( isset($HTTP_POST_VARS['b_md']) ) ? intval ($HTTP_POST_VARS['b_md']) : 0; $b_year = ( isset($HTTP_POST_VARS['b_year']) ) ? intval ($HTTP_POST_VARS['b_year']) : 0; if ($b_day && $b_md && $b_year) { $birthday = mkrealdate($b_day,$b_md,$b_year); } else { $birthday = 999999; } } // End add - Birthday MOD # #-----[ FIND ]------------------------------------------------ # $avatar_sql = user_avatar_gallery($mode } # #-----[ AFTER, ADD ]------------------------------------------ # // Start add - Birthday MOD // find the birthday values, reflected by the $lang['Submit_date_format'] if ($b_day || $b_md || $b_year) //if a birthday is submited, then validate it { $user_age=(date('md')>=$b_md.(($b_day <= 9) ? '0':'').$b_day) ? date('Y') - $b_year : date('Y') - $b_year - 1 ; // Check date, maximum / minimum user age if (!checkdate($b_md,$b_day,$b_year)) { $error = TRUE; if( isset($error_msg) )$error_msg .= "
"; $error_msg .= $lang['Wrong_birthday_format']; } else if ($user_age>$board_config['max_user_age']) { $error = TRUE; if( isset($error_msg) )$error_msg .= "
"; $error_msg .= sprintf($lang['Birthday_to_high'],$board_config['max_user_age']); } else if ($user_age<$board_config['min_user_age']) { $error = TRUE; if( isset($error_msg) )$error_msg .= "
"; $error_msg .= sprintf($lang['Birthday_to_low'],$board_config['min_user_age']); } else { $birthday = ($error) ? $birthday : mkrealdate($b_day,$b_md,$b_year); $next_birthday_greeting = (date('md')<$b_md.(($b_day <= 9) ? '0':'').$b_day) ? date('Y'):date('Y')+1 ; } } else { if ($board_config['birthday_required']) { $error = TRUE; if( isset($error_msg) )$error_msg .= "
"; $error_msg .= sprintf($lang['Birthday_require']); } $birthday = 999999; } // End add - Birthday MOD # #-----[ FIND ]------------------------------------------------ # $sql = "UPDATE " . USERS_TABLE . " SET # #-----[ IN-LINE FIND ]---------------------------------------- # str_replace("\'", "''", $interests) . "' # #-----[ IN-LINE AFTER, ADD ]---------------------------------- # , user_birthday = '$birthday', user_next_birthday_greeting = '$next_birthday_greeting' # #-----[ FIND ]------------------------------------------------ # # NOTICE - 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 exact, if this fail, then do not run your code on live forum # $sql = "INSERT INTO " . USERS_TABLE . " # #-----[ IN-LINE FIND ]---------------------------------------- # , user_active, user_actkey) # #-----[ IN-LINE BEFORE, ADD ]--------------------------------- # , user_birthday, user_next_birthday_greeting # #-----[ FIND ]------------------------------------------------ # VALUES ($user_id, # #-----[ IN-LINE FIND ]---------------------------------------- # , "; # #-----[ IN-LINE BEFORE, ADD ]--------------------------------- # , '$birthday', '$next_birthday_greeting' # #-----[ FIND ]------------------------------------------------ # $interests = $userdata['user_interests']; # #-----[ AFTER, ADD ]------------------------------------------ # // Start add - Birthday MOD $birthday = $userdata['user_birthday']; // End add - Birthday MOD # #-----[ FIND ]------------------------------------------------ # display_avatar_gallery($mode # #-----[ IN-LINE FIND ]---------------------------------------- # ); # #-----[ IN-LINE BEFORE, ADD ]--------------------------------- # , $birthday # #-----[ FIND ]------------------------------------------------ # if ( $error ) { $template->set_filenames(array( # #-----[ BEFORE, ADD ]----------------------------------------- # // Start add - Birthday MOD if ( $birthday!=999999 ) { $b_day = realdate('j', $birthday); $b_md = realdate('n', $birthday); $b_year = realdate('Y', $birthday); $birthday = realdate($lang['Submit_date_format'], $birthday); } else { $b_day = ''; $b_md = ''; $b_year = ''; $birthday = ''; } // End add - Birthday MOD # #-----[ FIND ]------------------------------------------------ # // // Let's do an overall check for settings/versions which would prevent # #-----[ BEFORE, ADD ]----------------------------------------- # // Start add - Birthday MOD $s_b_day = '' . $lang['Day'] . '   '; $s_b_md = '' . $lang['Month'] . '   '; $s_b_day= str_replace("value=\"".$b_day."\">", "value=\"".$b_day."\" SELECTED>" ,$s_b_day); $s_b_md = str_replace("value=\"".$b_md."\">", "value=\"".$b_md."\" SELECTED>" ,$s_b_md); $s_b_year = '' . $lang['Year'] . '   '; $i = 0; $s_birthday = ''; for ($i=0; $i<=strlen($lang['Submit_date_format']); $i++) { switch ($lang['Submit_date_format'][$i]) { case d: $s_birthday .= $s_b_day;break; case m: $s_birthday .= $s_b_md;break; case Y: $s_birthday .= $s_b_year;break; } } // End add - Birthday MOD # #-----[ FIND ]------------------------------------------------ # 'OCCUPATION' => 'INTERESTS' => # #-----[ AFTER, ADD ]------------------------------------------ # // Start add - Birthday MOD 'S_BIRTHDAY' => $s_birthday, 'BIRTHDAY_REQUIRED' => ($board_config['birthday_required']) ? '*' : '', // End add - Birthday MOD # #-----[ FIND ]------------------------------------------------ # 'L_INTERESTS' => # #-----[ AFTER, ADD ]------------------------------------------ # // Start add - Birthday MOD 'L_BIRTHDAY' => $lang['Birthday'], // End add - Birthday MOD # #-----[ OPEN ]------------------------------------------------ # includes/usercp_viewprofile.php # #-----[ FIND ]------------------------------------------------ # // // Generate page # #-----[ BEFORE, ADD ]----------------------------------------- # // Start add - Birthday MOD if ($profiledata['user_birthday']!=999999) { $user_birthday = realdate($lang['DATE_FORMAT'], $profiledata['user_birthday']); } else { $user_birthday = $lang['No_birthday_specify']; } // End add - Birthday MOD # #-----[ FIND ]------------------------------------------------ # 'INTERESTS' => # #-----[ AFTER, ADD ]------------------------------------------ # // Start add - Birthday MOD 'BIRTHDAY' => $user_birthday, // End add - Birthday MOD # #-----[ FIND ]------------------------------------------------ # 'L_INTERESTS' => # #-----[ AFTER, ADD ]------------------------------------------ # // Start add - Birthday MOD 'L_BIRTHDAY' => $lang['Birthday'], // End add - Birthday MOD # #-----[ OPEN ]------------------------------------------------ # language/lang_english/lang_admin.php # #-----[ FIND ]------------------------------------------------ # ?> # #-----[ BEFORE, ADD ]----------------------------------------- # // Start add - Birthday MOD $lang['Birthday_required'] = 'Force users to submit a birthday'; $lang['Enable_birthday_greeting'] = 'Enable birthday greetings'; $lang['Birthday_greeting_expain'] = 'Users who have submitted a birthday can have a birthday greeting, when thy visit the board'; $lang['Next_birthday_greeting'] = 'Next birthday popup year'; $lang['Next_birthday_greeting_expain'] = 'This field keeps track of the next year the user shall have a birthday greeting'; $lang['Wrong_next_birthday_greeting'] = 'The supplied, next birthday popup year, was not valid, please try again'; $lang['Max_user_age'] = 'Maximum user age'; $lang['Min_user_age'] = 'Minimum user age'; $lang['Birthday_lookforward'] = 'Birthday look forward'; $lang['Birthday_lookforward_explain'] = 'Number of days the script shall look forward for users with a birthday'; // End add - Birthday MOD # #-----[ OPEN ]------------------------------------------------ # language/lang_english/lang_main.php # #-----[ FIND ]------------------------------------------------ # ?> # #-----[ BEFORE, ADD ]----------------------------------------- # // Start add - Birthday MOD $lang['Birthday'] = 'Birthday'; $lang['No_birthday_specify'] = 'None Specified'; $lang['Age'] = 'Age'; $lang['Wrong_birthday_format'] = 'The birthday format was entered incorrectly.'; $lang['Birthday_to_high'] = 'Sorry, this site, does not accept user older than %d years old'; $lang['Birthday_require'] = 'your Birthday are required on this site'; $lang['Birthday_to_low'] = 'Sorry, this site, does not accept user yonger than %d years old'; $lang['Submit_date_format'] = 'd-m-Y'; //php date() format - Note: ONLY d, m and Y may be used and SHALL ALL be used (different seperators are accepted) $lang['Birthday_greeting_today'] = 'We would like to wish you congratulatons on reaching %s years old today.

The Management';//%s is substituted with the users age $lang['Birthday_greeting_prev'] = 'We would like to give you a belated congratulatons for becoming %s years old on the %s.

The Management';//%s is substituted with the users age, and birthday $lang['Greeting_Messaging'] = 'Congratulations'; $lang['Birthday_today'] = 'Users with a birthday today:'; $lang['Birthday_week'] = 'Users with a birthday within the next %d days:'; $lang['Nobirthday_week'] = 'No users are having a birthday in the upcoming %d days'; // %d is substitude with the number of days $lang['Nobirthday_today'] = 'No users have a birthday today'; $lang['Year'] = 'Year'; $lang['Month'] = 'Month'; $lang['Day'] = 'Day'; // NOTE: Please do not translate the folowing 4 lines ! // They are automatically translated into your language $lang['day_short'] = array ($lang['datetime']['Sun'],$lang['datetime']['Mon'],$lang['datetime']['Tue'],$lang['datetime']['Wed'],$lang['datetime']['Thu'],$lang['datetime']['Fri'],$lang['datetime']['Sat']); $lang['day_long'] = array ($lang['datetime']['Sunday'],$lang['datetime']['Monday'],$lang['datetime']['Tuesday'],$lang['datetime']['Wednesday'],$lang['datetime']['Thursday'],$lang['datetime']['Friday'],$lang['datetime']['Saturday']); $lang['month_short'] = array ($lang['datetime']['Jan'],$lang['datetime']['Feb'],$lang['datetime']['Mar'],$lang['datetime']['Apr'],$lang['datetime']['May'],$lang['datetime']['Jun'],$lang['datetime']['Jul'],$lang['datetime']['Aug'],$lang['datetime']['Sep'],$lang['datetime']['Oct'],$lang['datetime']['Nov'],$lang['datetime']['Dec']); $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']); // End add - Birthday MOD # #-----[ OPEN ]------------------------------------------------ # # Make sure to edit this file for every theme you use! # templates/subSilver/index_body.tpl # #-----[ FIND ]------------------------------------------------ # whosonline.gif # #-----[ IN-LINE FIND ]---------------------------------------- # rowspan="{%:1}" # #-----[ IN-LINE INCREMENT ]----------------------------------- # %:1 +1 # #-----[ FIND ]------------------------------------------------ # {LOGGED_IN_USER_LIST} # #-----[ AFTER, ADD ]------------------------------------------ # {L_WHOSBIRTHDAY_TODAY}
{L_WHOSBIRTHDAY_WEEK}
# #-----[ OPEN ]------------------------------------------------ # # Make sure to edit this file for every theme you use! # templates/subSilver/overall_header.tpl # #-----[ FIND ]------------------------------------------------ # # #-----[ AFTER, ADD ]------------------------------------------ # {GREETING_POPUP} # #-----[ OPEN ]------------------------------------------------ # # Make sure to edit this file for every theme you use! # templates/subSilver/profile_add_body.tpl # #-----[ FIND ]------------------------------------------------ # {INTERESTS} # #-----[ AFTER, ADD ]------------------------------------------ # {L_BIRTHDAY}:{BIRTHDAY_REQUIRED} {S_BIRTHDAY} # #-----[ OPEN ]------------------------------------------------ # # Make sure to edit this file for every theme you use! # templates/subSilver/profile_view_body.tpl # #-----[ FIND ]------------------------------------------------ # {INTERESTS} # #-----[ AFTER, ADD ]------------------------------------------ # {L_BIRTHDAY}: {BIRTHDAY} # #-----[ OPEN ]------------------------------------------------ # # Make sure to edit this file for every theme you use! # templates/subSilver/viewtopic_body.tpl # #-----[ FIND ]------------------------------------------------ # {postrow.POSTER_AVATAR}

# #-----[ IN-LINE FIND ]---------------------------------------- # {postrow.POSTER_AVATAR}

# #-----[ IN-LINE AFTER, ADD ]---------------------------------- # {postrow.POSTER_AGE}
# #-----[ OPEN ]------------------------------------------------ # # Make sure to edit this file for every theme you use! # templates/subSilver/admin/board_config_body.tpl # #-----[ FIND ]------------------------------------------------ # {PRUNE_NO} /> {L_NO} # #-----[ AFTER, ADD ]------------------------------------------ # {L_BIRTHDAY_REQUIRED}
{L_YES}   {L_NO} {L_ENABLE_BIRTHDAY_GREETING}
{L_BIRTHDAY_GREETING_EXPLAIN} {L_YES}   {L_NO} {L_MAX_USER_AGE}
{L_MIN_USER_AGE}
{L_MIN_USER_AGE_EXPLAIN} {L_BIRTHDAY_LOOKFORWARD}
{L_BIRTHDAY_LOOKFORWARD_EXPLAIN} # #-----[ OPEN ]------------------------------------------------ # # Make sure to edit this file for every theme you use! # templates/subSilver/admin/user_edit_body.tpl # #-----[ FIND ]------------------------------------------------ # # #-----[ AFTER, ADD ]------------------------------------------ # {L_BIRTHDAY} {S_BIRTHDAY} {L_NEXT_BIRTHDAY_GREETING}:
{L_NEXT_BIRTHDAY_GREETING_EXPLAIN}
# #-----[ DIY INSTRUCTIONS ]------------------------------------ # Regardless how you've installed this MOD (by EasyMOD or manually), if you want to install other languages than English please use the sub MODs in the /translations/ directory (as for the moment EasyMOD is not able to carry on automatically). # #-----[ SAVE/CLOSE ALL FILES ]-------------------------------- # # EoM