############################################################## 
## MOD Title: Birthdays
## MOD Author: TerraFrost < terrafrost@phpbb.com > (Jim Wigginton) http://www.frostjedi.com/terra/wordpress/
## MOD Description: Adds a Birthday field to the user profile.
## MOD Version: 3.0.1
##
## Installation Level: moderate
## Installation Time: 60 Minutes
##
## Files To Edit: 24
##      admin/admin_board.php
##      admin/admin_users.php
##      includes/constants.php
##      includes/functions_selects.php
##      includes/page_header.php
##      includes/template.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/admin/board_config_body.tpl
##      templates/subSilver/admin/user_edit_body.tpl
##      templates/subSilver/index_body.tpl
##      templates/subSilver/memberlist_body.tpl
##      templates/subSilver/overall_header.tpl
##      templates/subSilver/profile_add_body.tpl
##      templates/subSilver/profile_view_body.tpl
##      templates/subSilver/viewtopic_body.tpl
##      index.php
##      memberlist.php
##      profile.php
##      privmsg.php
##      viewtopic.php
##
## Included Files: 3
##      templates/subSilver/images/icon_birthday.gif
##      templates/subSilver/birthday_interface.tpl
##      language/lang_english/email/user_birthday.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:
##
##   There is an older "Birthday Hack" by Niels Chr. Denmark that can be found here:
##   http://www.phpbbhacks.com/download/187
##
##   The current Birthday Icon is from Ptirhiik's Profile Control Panel.  The full
##   set of PSDs can be found here (doing a search for "graphics" will yield the exact
##   location):
##   http://rpgnet.clanmckeen.com/demo/download.php
##
##   Here's the direct link:
##   http://rpgnet.clanmckeen.com/mod/mod-profilcp/mod-profilcp%20-%20GIF_src.zip
##
##   The Birthday Icon in the contrib subdirectory is from David Vignoni's LGPL-Licensed
##   Nuvola Icon Theme for KDE 3.x.  The full set of PNGs can be found here (the exact
##   filename / location is nuvola/*/apps/cookie.png):
##   http://icon-king.com/?p=15
##
##   Here's a direct link to the individual PNG:
##   http://en.wikipedia.org/wiki/Image:Nuvola_apps_cookie.png
##
##   Also, a quick comment on how this MOD works.  There are two columns for the birthday.  The first - 
##   user_birthday - preserves backwards compatability with older versions of this MOD and makes it
##   easy to perform searches by date of birth (ie. where January 1, 1970 and January 1, 1971 should
##   both be returned when doing a search for January 1 birthdays; see index.php).  The second column -
##   user_birthday2 - makes it easier to perform searches based on age (as is done in memberlist.php).
##   A more optimal method would probably be to just have three columns - one or the month, one for the
##   day, and one for the year.  Unfortunately, this would break MODs written for older versions of this
##   MOD, hence it will not be done.
##
##   The latest version of this mod can be found here:
##   http://www.frostjedi.com/terra/scripts/phpbb/birthdays.zip
##
##   Some modifications to this MOD can be found here:
##   http://www.frostjedi.com/terra/scripts/phpbb/misc/birthdays_mods.zip
##
##   Some translations to this MOD can be found here:
##   http://www.frostjedi.com/terra/scripts/phpbb/misc/birthdays_translations.zip
##
##   For support / comments / whatever, visit the following URL:
##   http://www.phpbb.com/phpBB/viewtopic.php?t=342028
##
##############################################################
## MOD History:
##
##   2008-xx-xx - Version 3.0.1
##      - fixed a bug whereby birthday greetings, under certain conditions, wouldn't be sent (thanks, Primy!)
##      - fixed a bug whereby the afore mentioned fix would overwrite the $start variable used in (for example)
##           memberlist.php (thanks, Blint Krizsn and RMcGirr83!)
##      - fixed a bug whereby the Birthday Greeting setting wouldn't be preserved if using, for instance, avatar 
##           galleries.
##   2007-05-10 - Version 3.0.0
##      - added the ability to make the board send "happy birthday" messages to people via email or popups
##      - added an age field to viewtopic.php and a date of birth field to memberlist.php
##      - added the ability for users to hide their birthday (thanks, jerx!)
##      - added the ability to hide the birthday panel on index.php from guests (guests can still view
##           birthdays on profile pages; if you want to hide the profile from guests, install another mod)
##      - updated the sorting for "upcoming birthdays" (thanks, fred_41!)
##      - fixed a bug whereby ages in "upcoming birthdays" could be off by a year (thanks, MarieMM!)
##      - fixed a bug that caused dates, under seemingly rare circumstances, to show up a day off (thanks,
##           sammy65!)
##      - replaced the index_body.tpl additions with something that should be easier to adapt to other
##           themes or just modded themes 
##      - a few other small bug fixes (thanks, Parasytic and ErnadoO!)
##   2006-09-21 - Version 2.0.2
##      - rewrote the birthdate validation stuff (fixes a bug found by ycl6 - thanks!)
##      - the user_birthday column in phpbb_users is now defined as an index (thanks, eoinoc333!)
##      - added the ability to use drop-down menus for the year
##      - fixed a bug whereby birthday_interface occasionally duplicated things (thanks, Baltazar!)
##      - birthday_interface should now work better with caching template.php's (thanks, Jhong!)
##      - only active users are shown in index.php's birthday panel (thanks, RMcGirr83!)
##      - users in index.php's birthday panel are now sorted (thanks, saaiberke!)
##   2006-04-20 - Version 2.0.1
##      - revamped the documentation (Acyd Burn's Attachment MOD documentation inspired me)
##      - the birthday interface now displays in a manner dependant upon $lang['DATE_FORMAT'].
##      - 'yyyy' no longer needs to be inputted to reset birthdays.
##      - fixed a bug whereby dates would show up incorrectly (thanks, Eddy Kiprich!)
##   2005-12-30 - Version 2.0.0
##      - added a new birthday icon (thanks, Ptirhiik!)
##      - added the ability to require dates of birth
##      - added the ability to require years
##      - added the ability to make dates of birth "read-only"
##      - added the ability to make the birthday panel on the main index appear all the time
##      - added the ability to display birthdays that are x days away (where x is definable
##           in the ACP)
##      - added the ability to specify valid age ranges
##   2005-12-05 - Version 1.0.1
##      - added a new birthday icon (thanks, cback!)
##      - removed a superfluous rowspan="2" attribute (thanks, tony44!)
##      - fixed a bug whereby certain birthdates wouldn't be accepted in the ACP (thanks, duena!)
##      - fixed a bug whereby birthdates showed up a day early (thanks, 3Di and Scorpiuscat1!)
##      - fixed a bug whereby avatar galleries would reset birthdates (thanks, 3Di!)
##   2005-11-16 - Version 1.0.0
##      - initial release
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
##############################################################

#
#-----[ COPY ]------------------------------------------
#
copy templates/subSilver/images/icon_birthday.gif to templates/subSilver/images/icon_birthday.gif
copy templates/subSilver/birthday_interface.tpl to templates/subSilver/birthday_interface.tpl
copy language/lang_english/email/user_birthday.tpl to language/lang_english/email/user_birthday.tpl
#
#-----[ SQL ]-------------------------------------------
# if you want to change birthday_display's default setting, go to includes/constants.php and
# change the appropriate constant.
#
ALTER TABLE phpbb_users ADD user_birthday int(8) DEFAULT '0' NOT NULL;
ALTER TABLE phpbb_users ADD KEY(user_birthday);
ALTER TABLE phpbb_users ADD user_birthday2 int(8) DEFAULT NULL NULL;
ALTER TABLE phpbb_users ADD KEY(user_birthday2);
ALTER TABLE phpbb_users ADD birthday_display tinyint(1) DEFAULT '0' NOT NULL;
ALTER TABLE phpbb_users ADD birthday_greeting tinyint(1) DEFAULT '0' NOT NULL;
ALTER TABLE phpbb_users ADD user_next_birthday smallint(4) DEFAULT '0' NOT NULL;
INSERT INTO phpbb_config (config_name, config_value) VALUES ('bday_show',1);
INSERT INTO phpbb_config (config_name, config_value) VALUES ('bday_require',0);
INSERT INTO phpbb_config (config_name, config_value) VALUES ('bday_year',0);
INSERT INTO phpbb_config (config_name, config_value) VALUES ('bday_lock',0);
INSERT INTO phpbb_config (config_name, config_value) VALUES ('bday_lookahead',7);
INSERT INTO phpbb_config (config_name, config_value) VALUES ('bday_max',100);
INSERT INTO phpbb_config (config_name, config_value) VALUES ('bday_min',5);
INSERT INTO phpbb_config (config_name, config_value) VALUES ('bday_hide',0);
INSERT INTO phpbb_config (config_name, config_value) VALUES ('bday_greeting',0);
#
#-----[ OPEN ]------------------------------------------
#
admin/admin_board.php
#
#-----[ FIND ]------------------------------------------
#
		if ($config_name == 'cookie_name')
		{
			$new['cookie_name'] = str_replace('.', '_', $new['cookie_name']);
		}
#
#-----[ BEFORE, ADD ]-----------------------------------
#
		if ( $config_name == 'bday_greeting' && isset($HTTP_POST_VARS['submit']) )
		{
			// rather than have three seperate database entries, we have one bitmasked one.
			$bday_email_mask = isset($HTTP_POST_VARS['bday_email_mask']) ? 1<<($HTTP_POST_VARS['bday_email_mask']-1) : 0;
			$bday_pm_mask = isset($HTTP_POST_VARS['bday_pm_mask']) ? 1<<($HTTP_POST_VARS['bday_pm_mask']-1) : 0;
			$bday_popup_mask = isset($HTTP_POST_VARS['bday_popup_mask']) ? 1<<($HTTP_POST_VARS['bday_popup_mask']-1) : 0;
			$new['bday_greeting'] = $bday_email_mask | $bday_pm_mask | $bday_popup_mask;
		}

#
#-----[ FIND ]------------------------------------------
#
$cookie_secure_yes = ( $new['cookie_secure'] ) ? "checked=\"checked\"" : "";
#
#-----[ BEFORE, ADD ]-----------------------------------
#
$bday_show_yes = ( $new['bday_show'] ) ? "checked=\"checked\"" : "";
$bday_show_no = ( !$new['bday_show'] ) ? "checked=\"checked\"" : "";
$bday_require_yes = ( $new['bday_require'] ) ? "checked=\"checked\"" : "";
$bday_require_no = ( !$new['bday_require'] ) ? "checked=\"checked\"" : "";
$bday_year_yes = ( $new['bday_year'] ) ? "checked=\"checked\"" : "";
$bday_year_no = ( !$new['bday_year'] ) ? "checked=\"checked\"" : "";
$bday_lock_yes = ( $new['bday_lock'] ) ? "checked=\"checked\"" : "";
$bday_lock_no = ( !$new['bday_lock'] ) ? "checked=\"checked\"" : "";
$bday_hide_yes = ( $new['bday_hide'] ) ? "checked=\"checked\"" : "";
$bday_hide_no = ( !$new['bday_hide'] ) ? "checked=\"checked\"" : "";

$bday_email_enabled = ( $new['bday_greeting'] & 1<<(BIRTHDAY_EMAIL-1) ) ? "checked=\"checked\"" : "";
$bday_pm_enabled = ( $new['bday_greeting'] & 1<<(BIRTHDAY_PM-1) ) ? "checked=\"checked\"" : "disabled=\"disabled\"";
$bday_popup_enabled = ( $new['bday_greeting'] & 1<<(BIRTHDAY_POPUP-1) ) ? "checked=\"checked\"" : "";

#
#-----[ FIND ]------------------------------------------
#
	"L_COOKIE_SETTINGS" => $lang['Cookie_settings'], 
#
#-----[ BEFORE, ADD ]-----------------------------------
#
	"L_BIRTHDAYS" => $lang['Birthdays'],
	"L_BDAY_SHOW" => $lang['bday_show'],
	"L_UNCONDITIONAL" => $lang['Unconditional'],
	"L_CONDITIONAL" => $lang['Conditional'],
	"L_BDAY_SHOW_EXPLAIN" => $lang['bday_show_explain'],
	"L_BDAY_REQUIRE" => $lang['bday_require'],
	"L_BDAY_REQUIRE_EXPLAIN" => $lang['bday_require_explain'],
	"L_BDAY_YEAR" => $lang['bday_year'],
	"L_BDAY_YEAR_EXPLAIN" => $lang['bday_year_explain'],
	"L_BDAY_LOCK" => $lang['bday_lock'],
	"L_BDAY_LOCK_EXPLAIN" => $lang['bday_lock_explain'],
	"L_BDAY_LOOKAHEAD" => $lang['bday_lookahead'],
	"L_BDAY_LOOKAHEAD_EXPLAIN" => $lang['bday_lookahead_explain'],
	"L_BDAY_AGE_RANGE" => $lang['bday_age_range'],
	"L_TO" => $lang['To'],
	"L_BDAY_HIDE" => $lang['bday_hide'],
	"L_BDAY_SEND_GREETING" => $lang['bday_send_greeting'],
	"L_BDAY_SEND_GREETING_EXPLAIN" => $lang['bday_send_greeting_admin_explain'],
	"L_EMAIL" => $lang['Email'],
	"L_PM" => $lang['PM'],
	"L_POPUP" => $lang['Popup'],
#
#-----[ FIND ]------------------------------------------
#
	"COOKIE_DOMAIN" => $new['cookie_domain'],
#
#-----[ BEFORE, ADD ]-----------------------------------
#
	"BDAY_SHOW_YES" => $bday_show_yes,
	"BDAY_SHOW_NO" => $bday_show_no,
	"BDAY_REQUIRE_YES" => $bday_require_yes,
	"BDAY_REQUIRE_NO" => $bday_require_no,
	"BDAY_YEAR_YES" => $bday_year_yes,
	"BDAY_YEAR_NO" => $bday_year_no,
	"BDAY_LOCK_YES" => $bday_lock_yes,
	"BDAY_LOCK_NO" => $bday_lock_no,
	"BDAY_LOOKAHEAD" => $new['bday_lookahead'],
	"BDAY_MIN" => $new['bday_min'],
	"BDAY_MAX" => $new['bday_max'],
	"BDAY_HIDE_YES" => $bday_hide_yes,
	"BDAY_HIDE_NO" => $bday_hide_no,
	"BDAY_EMAIL" => BIRTHDAY_EMAIL,
	"BDAY_PM" => BIRTHDAY_PM,
	"BDAY_POPUP" => BIRTHDAY_POPUP,
	"BDAY_EMAIL_ENABLED" => $bday_email_enabled,
	"BDAY_PM_ENABLED" => $bday_pm_enabled,
	"BDAY_POPUP_ENABLED" => $bday_popup_enabled,

#
#-----[ OPEN ]------------------------------------------
#
admin/admin_users.php
#
#-----[ FIND ]------------------------------------------
#
		$icq = ( !empty($HTTP_POST_VARS['icq']) ) ? trim(strip_tags( $HTTP_POST_VARS['icq'] ) ) : '';
#
#-----[ BEFORE, ADD ]-----------------------------------
#
		// casting the following to integers isn't necessary because a later sprintf takes care of that
		$bday_year = ( !empty($HTTP_POST_VARS['bday_year']) ) ? $HTTP_POST_VARS['bday_year'] : 0;
		$bday_month = ( !empty($HTTP_POST_VARS['bday_month']) ) ? $HTTP_POST_VARS['bday_month'] : 0;
		$bday_day = ( !empty($HTTP_POST_VARS['bday_day']) ) ? $HTTP_POST_VARS['bday_day'] : 0;

		$birthday_display = ( isset($HTTP_POST_VARS['birthday_display']) ) ? intval($HTTP_POST_VARS['birthday_display']) : 0;
		$birthday_greeting = ( isset($HTTP_POST_VARS['bday_greeting']) ) ? $HTTP_POST_VARS['bday_greeting'] : 0;

#
#-----[ FIND ]------------------------------------------
#
		if ($signature != '')
#
#-----[ BEFORE, ADD ]-----------------------------------
#
		$empty_month = empty($bday_month) || $bday_month == $lang['Default_Month'];
		$empty_day = empty($bday_day) || $bday_day == $lang['Default_Day'];
		$empty_year = empty($bday_year) || $bday_year == $lang['Default_Year'];

		$temp_month = $empty_month ? 1 : $bday_month;
		$temp_day = $empty_day ? 1 : $bday_day;
		$temp_year = $empty_year ? 4 : $bday_year;

		switch (true)
		{
			case $board_config['bday_year'] && (($empty_month != $empty_day) || ($empty_day != $empty_year)):
			case !$board_config['bday_year'] && (($empty_month != $empty_day) || ($empty_day && !$empty_year)):
			case !@checkdate( $temp_month, $temp_day, $temp_year ) && (!$board_config['bday_lock'] || $userdata['user_birthday'] == 0):
				$error = TRUE;
				$error_msg .= ( ( !empty($error_msg) ) ? '<br />' : '' ) . $lang['Birthday_invalid'];
		}

		$user_birthday = sprintf('%02d%02d%04d',$bday_month,$bday_day,$bday_year);
		$user_birthday2 = ( $birthday_display != BIRTHDAY_DATE && $birthday_display != BIRTHDAY_NONE && !$empty_month && !$empty_day && !$empty_year ) ? sprintf('%04d%02d%02d',$bday_year,$bday_month,$bday_day) : 'NULL';

		if ( $birthday_greeting && !( $board_config['bday_greeting'] & 1<<($birthday_greeting-1) ) )
		{
			$birthday_greeting = 0;
		}

#
#-----[ FIND ]------------------------------------------
# this is a partial match
#
			$sql = "UPDATE " . USERS_TABLE . "
				SET " . $username_sql
#
#-----[ IN-LINE FIND ]----------------------------------
#
, user_icq = '" . str_replace("\'", "''", $icq) . "'
#
#-----[ IN-LINE BEFORE, ADD ]---------------------------
#
, user_birthday = $user_birthday, user_birthday2 = $user_birthday2, birthday_display = $birthday_display, birthday_greeting = $birthday_greeting
#
#-----[ FIND ]------------------------------------------
#
		$icq = $this_userdata['user_icq'];
#
#-----[ BEFORE, ADD ]-----------------------------------
#
		preg_match('/(..)(..)(....)/', sprintf('%08d',$this_userdata['user_birthday']), $bday_parts);
		$bday_month = $bday_parts[1];
		$bday_day = $bday_parts[2];
		$bday_year = $bday_parts[3];

		$birthday_display = $this_userdata['birthday_display'];
		$birthday_greeting = $this_userdata['birthday_greeting'];

#
#-----[ FIND ]------------------------------------------
#
			$s_hidden_fields .= '<input type="hidden" name="icq" value="' . str_replace("\"", "&quot;", $icq) . '" />';
#
#-----[ BEFORE, ADD ]-----------------------------------
#
			$s_hidden_fields .= '<input type="hidden" name="bday_years" value="' . $bday_years . '" />';
			$s_hidden_fields .= '<input type="hidden" name="bday_months" value="' . $bday_months . '" />';
			$s_hidden_fields .= '<input type="hidden" name="bday_days" value="' . $bday_days . '" />';
			$s_hidden_fields .= '<input type="hidden" name="birthday_display" value="' . $birthday_display . '" />';
			$s_hidden_fields .= '<input type="hidden" name="birthday_greeting" value="' . $birthday_greeting . '" />';
#
#-----[ FIND ]------------------------------------------
#
			'WEBSITE' => $website,
#
#-----[ AFTER, ADD ]------------------------------------
#
			'BDAY_MONTH' => ($bday_month != 0) ? $bday_month : $lang['Default_Month'],
			'BDAY_DAY' => ($bday_day != 0) ? $bday_day : $lang['Default_Day'],
			'BDAY_YEAR' => ($bday_year != 0) ? $bday_year : $lang['Default_Year'],
			'BIRTHDAY_ALL' => BIRTHDAY_ALL,
			'BIRTHDAY_ALL_SELECTED' => ( $birthday_display == BIRTHDAY_ALL ) ? ' selected="selected"' : '',
			'BIRTHDAY_DATE' => BIRTHDAY_DATE,
			'BIRTHDAY_DATE_SELECTED' => ( $birthday_display == BIRTHDAY_DATE ) ? ' selected="selected"' : '',
			'BIRTHDAY_AGE' => BIRTHDAY_AGE,
			'BIRTHDAY_AGE_SELECTED' => ( $birthday_display == BIRTHDAY_AGE ) ? ' selected="selected"' : '',
			'BIRTHDAY_NONE' => BIRTHDAY_NONE,
			'BIRTHDAY_NONE_SELECTED' => ( $birthday_display == BIRTHDAY_NONE ) ? ' selected="selected"' : '',
			'BDAY_NONE_ENABLED' => ( !$birthday_greeting ) ? ' checked="checked"' : '',
			'BDAY_EMAIL' => BIRTHDAY_EMAIL,
			'BDAY_EMAIL_ENABLED' => ( $birthday_greeting == BIRTHDAY_EMAIL ) ? ' checked="checked"' : '',
			'BDAY_PM' => BIRTHDAY_PM,
			'BDAY_PM_ENABLED' => ( $birthday_greeting == BIRTHDAY_PM ) ? ' checked="checked"' : '', 
			'BDAY_POPUP' => BIRTHDAY_POPUP,
			'BDAY_POPUP_ENABLED' => ( $birthday_greeting == BIRTHDAY_POPUP ) ? ' checked="checked"' : '',
#
#-----[ FIND ]------------------------------------------
#
			'LANGUAGE_SELECT' => language_select($user_lang),
#
#-----[ AFTER, ADD ]------------------------------------
#
			'BIRTHMONTH_SELECT' => bday_month_select($bday_month, 'bday_month'),
			'BIRTHDAY_SELECT' => bday_day_select($bday_day, 'bday_day'),
			'BIRTHYEAR_SELECT' => bday_year_select($bday_year, 'bday_year'),
#
#-----[ FIND ]------------------------------------------
#
			'L_ICQ_NUMBER' => $lang['ICQ'],
#
#-----[ BEFORE, ADD ]-----------------------------------
#
			'L_CLEAR' => $lang['Clear'],
			'L_BIRTHDAY' => $lang['Birthday'],
			'L_MONTH' => $lang['Month'],
			'L_DAY' => $lang['Day'],
			'L_YEAR' => ( $board_config['bday_year'] ) ? $lang['Year'] : $lang['Year_Optional'],
			'L_OPTIONAL' => ( $board_config['bday_year'] ) ? '' : $lang['Optional'],
			'L_BIRTHDAY_DISPLAY' => $lang['Birthday_Display'],
			'L_BIRTHDAY_ALL' => $lang['Display_all'],
			'L_BIRTHDAY_YEAR' => $lang['Display_day_and_month'],
			'L_BIRTHDAY_AGE' => $lang['Display_age'],
			'L_BIRTHDAY_NONE' => $lang['Display_nothing'],
			'L_BDAY_SEND_GREETING' => $lang['bday_send_greeting'],
			'L_BDAY_SEND_GREETING_EXPLAIN' => $lang['bday_send_greeting_user_explain'],
			'L_NONE' => $lang['Do_not_send'],
			'L_EMAIL' => $lang['Email'],
			'L_PM' => $lang['PM'],
			'L_POPUP' => $lang['Popup'],
#
#-----[ FIND ]------------------------------------------
#
			'S_PROFILE_ACTION' => append_sid("admin_users.$phpEx"))
		);
#
#-----[ AFTER, ADD ]------------------------------------
#

		$block = ( $board_config['bday_require'] == TRUE ) ? 'birthday_required' : 'birthday_optional';
		$template->assign_block_vars($block, array());
		$template->birthday_interface();

		if ( $board_config['bday_greeting'] != 0 )
		{
			$template->assign_block_vars('birthdays_greeting',array());
			if ($board_config['bday_greeting'] & (1<<(BIRTHDAY_EMAIL-1)))
			{
				$template->assign_block_vars('birthdays_greeting.birthdays_email',array());
			}
			if ($board_config['bday_greeting'] & (1<<(BIRTHDAY_PM-1)))
			{
					$template->assign_block_vars('birthdays_greeting.birthdays_pm',array());
			}
			if ($board_config['bday_greeting'] & (1<<(BIRTHDAY_POPUP-1)))
			{
				$template->assign_block_vars('birthdays_greeting.birthdays_popup',array());
			}
		}
#
#-----[ OPEN ]------------------------------------------
#
includes/constants.php
#
#-----[ FIND ]------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]-----------------------------------
#
// Date of Birth Display Options
define('BIRTHDAY_ALL',0); // display everything
define('BIRTHDAY_DATE',1); // display day and month (but not year)
define('BIRTHDAY_AGE',2); // display age (but not day / month)
define('BIRTHDAY_NONE',3); // do not display anything

// Birthday Greeting Options
// 0 would be BIRTHDAY_NONE were it not hard-coded
define('BIRTHDAY_EMAIL',1);
define('BIRTHDAY_POPUP',2);
define('BIRTHDAY_PM',3);

#
#-----[ OPEN ]------------------------------------------
#
includes/functions_selects.php
#
#-----[ FIND ]------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]-----------------------------------
#
//
// Pick a birthday month
//
function bday_month_select($default, $select_name = 'bday_month')
{
	global $lang;
	static $translate = array();

	if ( empty($translate) )
	{
		$translate = array(
			$lang['Default_Month'],
			$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']
		);
	}

	if ( !isset($default) )
	{
		$default = 0;
	}
	$bday_month_select = '<select name="' . $select_name . '">';

	foreach ($translate as $num => $month)
	{
		$selected = ( $num == $default ) ? ' selected="selected"' : '';
		$bday_month_select .= '<option value="' . $num . '"' . $selected . '>' . $month . '</option>';
	}
	$bday_month_select .= '</select>';

	return $bday_month_select;
}

//
// Pick a birthday day
//
function bday_day_select($default, $select_name = 'bday_day')
{
	global $lang;
	static $options;

	if ( empty($options) )
	{
		$options = array($lang['Default_Day']);
		for ($i=0; $i<31; $i++)
		{
			$options[] = $i + 1;
		}
	}

	if ( !isset($default) )
	{
		$default = 0;
	}
	$bday_day_select = '<select name="' . $select_name . '">';

	foreach ($options as $num => $day)
	{
		$selected = ( $num == $default ) ? ' selected="selected"' : '';
		$bday_day_select .= '<option value="' . $num . '"' . $selected . '>' . $day . '</option>';
	}
	$bday_day_select .= '</select>';

	return $bday_day_select;
}

//
// Pick a birthday year
//
function bday_year_select($default, $select_name = 'bday_year')
{
	global $board_config, $lang;

	if ( !isset($default) )
	{
		$default = 0;
	}
	$bday_year_select = '<select name="' . $select_name . '">';

	$end = gmdate('Y') - $board_config['bday_min'];
	$start = gmdate('Y') - $board_config['bday_max'] - 1;

	$selected = ( !$default ) ? ' selected="selected"' : '';
	$bday_year_select .= '<option value="0"' . $selected . '>' . $lang['Default_Year'] . '</option>';

	for ($i=$end;$i>=$start;$i--)
	{
		$selected = ( $i == $default ) ? ' selected="selected"' : '';
		$bday_year_select .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>';
	}
	$bday_year_select .= '</select>';

	return $bday_year_select;
}

#
#-----[ OPEN ]------------------------------------------
#
includes/page_header.php
#
#-----[ FIND ]------------------------------------------
#
	'U_PRIVATEMSGS_POPUP' => append_sid('privmsg.'.$phpEx.'?mode=newpm'),
#
#-----[ AFTER, ADD ]------------------------------------
#
	'U_BIRTHDAYS_POPUP' => append_sid('profile.'.$phpEx.'?mode=birthday_popup'),
#
#-----[ FIND ]------------------------------------------
#
		$template->assign_block_vars('switch_enable_pm_popup', array());
	}
}
#
#-----[ AFTER, ADD ]------------------------------------
#

$current_time = time() + (3600 * $board_config['board_timezone']);
$start_time = ( $board_config['bday_lookahead'] > 0 ) ? strtotime('-'.$board_config['bday_lookahead'].' day') : $current_time;

// the greeting will be sent up to seven days after the birthday
$start_date = gmdate('md0000',$start_time);
$end_date = gmdate('md9999',$current_time);
$in_range = $start_date > $end_date ?
	$userdata['user_birthday'] >= $start_date || $userdata['user_birthday'] <= $end_date :
	$userdata['user_birthday'] >= $start_date && $userdata['user_birthday'] <= $end_date;
if ( $userdata['birthday_greeting'] != 0 && ( $userdata['user_next_birthday'] < gmdate('Y',$current_time)+1 ) && $in_range )
{
	$sql = "UPDATE ".USERS_TABLE. "
		SET user_next_birthday = ".(gmdate('Y',$current_time)+1)."
		WHERE user_id = ".$userdata['user_id'];

	if ( !$db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Could not update birthday information', '', __LINE__, __FILE__, $sql);
	}

	switch ( $userdata['birthday_greeting'] )
	{
		case BIRTHDAY_EMAIL:
			include($phpbb_root_path . 'includes/emailer.'.$phpEx);
			$emailer = new emailer($board_config['smtp_delivery']);

			$emailer->from($board_config['board_email']);
			$emailer->replyto($board_config['board_email']);

			$emailer->use_template('user_birthday',stripslashes($userdata['user_lang']));
			$emailer->set_subject($lang['View_Birthdays']);
			$emailer->email_address($userdata['user_email']);

			$emailer->assign_vars(array(
				'SITENAME' => $board_config['sitename'],
				'EMAIL_SIG' => (!empty($board_config['board_email_sig'])) ? str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']) : '')
			);

			$emailer->send();
			$emailer->reset();

			break;
		case BIRTHDAY_PM:
			// PM support is not currently enabled.
			break;
		case BIRTHDAY_POPUP:
			$template->assign_block_vars('switch_birthday_popup',array());
	}
}

#
#-----[ OPEN ]------------------------------------------
#
includes/template.php
#
#-----[ FIND ]------------------------------------------
# this is a partial match
#
	/**
	 * Generates a full path+filename for the given filename, which can either
	 * be an absolute name, or a name relative to the rootdir for this Template
	 * object.
	 */
	function make_filename($filename
#
#-----[ BEFORE, ADD ]-----------------------------------
#
	function birthday_interface()
	{
		global $lang;

		// the following was adapted from bbcode.php's load_bbcode_template function.
		$bday_filename = $this->make_filename('birthday_interface.tpl');
		$fp = fopen($bday_filename, 'r');
		$temp = fread($fp, filesize($bday_filename));
		fclose($fp);

		$temp = str_replace('\\', '\\\\', $temp);
		$temp = str_replace('\'', '\\\'', $temp);
		$temp = str_replace("\n", '', $temp);
		$temp = preg_replace('#<!-- BEGIN (.*?) -->(.*?)<!-- END (.*?) -->#', "\n" . '$bday_tpls[\'\\1\'] = \'\\2\';', $temp);

		$bday_tpls = array();

		eval($temp);

		$bday_format = preg_replace('#\\\\.|[^djFmMnYy]#','',$lang['DATE_FORMAT']);
		$bday_format = substr(chunk_split($bday_format,1,'.'),0,-1);

		$bday_template = isset($bday_tpls['bday_start']) ? $bday_tpls['bday_start'] : '';

		$i = '';
		while ( isset($bday_tpls["bday_month$i"]) && isset($bday_tpls["bday_day$i"]) && isset($bday_tpls["bday_year$i"]) )
		{
			if ( !empty($i) )
			{
				$bday_template.= isset($bday_tpls['bday_glue']) ? $bday_tpls['bday_glue'] : '';
			}
			$bday_template.= strtr($bday_format,array(
				'd' => $bday_tpls["bday_day$i"],
				'j' => $bday_tpls["bday_day$i"],
				'F' => $bday_tpls["bday_month$i"],
				'm' => $bday_tpls["bday_month$i"],
				'M' => $bday_tpls["bday_month$i"],
				'n' => $bday_tpls["bday_month$i"],
				'Y' => $bday_tpls["bday_year$i"],
				'y' => $bday_tpls["bday_year$i"],
				'.' => isset($bday_tpls["bday_subglue$i"]) ? $bday_tpls["bday_subglue$i"] : '')
			);
			if ( empty($i) )
			{
				$i = 1;
			}
			$i++;
		}

		$bday_template.= isset($bday_tpls['bday_end']) ? $bday_tpls['bday_end'] : '';

		$this->uncompiled_code['bday_interface'] = trim($bday_template);

		// the following two lines are required for phpBB's that use the eXtreme Styles MOD, cache/template_file_cache.php,
		// or other files bearing some sort of semblance to either of those.  on phpBB's not using those MODs, these lines
		// don't do much of anything.

		// also, if you're using cache/template_file_cache.php and you change $lang['DATE_FORMAT'], you'll need to delete
		// the appropriate *.php file in the birthday_interface directory.

		$this->files['bday_interface'] = $this->make_filename('birthday_interface.tpl');
		$this->filename['bday_interface'] = 'birthday_interface_'.$board_config['default_lang'].'.tpl';

		$this->assign_var_from_handle('BIRTHDAY_INTERFACE','bday_interface');
	}

#
#-----[ OPEN ]------------------------------------------
#
includes/usercp_avatar.php
#
#-----[ FIND ]------------------------------------------
# this is only a partial match
#
function display_avatar_gallery($mode
#
#-----[ IN-LINE FIND ]----------------------------------
#
&$language,
#
#-----[ IN-LINE AFTER, ADD ]----------------------------
#
 &$bday_month, &$bday_day, &$bday_year, &$birthday_display, &$bday_greeting,
#
#-----[ FIND ]------------------------------------------
# this is only a partial match
#
$params = array(
#
#-----[ IN-LINE FIND ]----------------------------------
#
'language',
#
#-----[ IN-LINE AFTER, ADD ]----------------------------
#
 'bday_month', 'bday_day', 'bday_year', 'birthday_display', 'bday_greeting',
#
#-----[ OPEN ]------------------------------------------
#
includes/usercp_register.php
#
#-----[ FIND ]------------------------------------------
# this is a partial match
#
	$strip_var_list = array
#
#-----[ IN-LINE FIND ]----------------------------------
#
, 'icq' => 'icq'
#
#-----[ IN-LINE AFTER, ADD ]----------------------------
#
, 'bday_day' => 'bday_day', 'bday_month' => 'bday_month', 'bday_year' => 'bday_year'
#
#-----[ FIND ]------------------------------------------
#
	$user_style = ( isset($HTTP_POST_VARS['style']) ) ? intval($HTTP_POST_VARS['style']) : $board_config['default_style'];
#
#-----[ BEFORE, ADD ]-----------------------------------
#
	$birthday_display = ( isset($HTTP_POST_VARS['birthday_display']) ) ? intval($HTTP_POST_VARS['birthday_display']) : 0;
	$birthday_greeting = ( isset($HTTP_POST_VARS['bday_greeting']) ) ? intval($HTTP_POST_VARS['bday_greeting']) : 0;
#
#-----[ FIND ]------------------------------------------
#
	if ( $signature != '' )
#
#-----[ BEFORE, ADD ]-----------------------------------
#
	$bday_locked = $board_config['bday_lock'] && $userdata['user_birthday'] != 0;

	if ( !$bday_locked )
	{
		$empty_month = empty($bday_month) || $bday_month == $lang['Default_Month'];
		$empty_day = empty($bday_day) || $bday_day == $lang['Default_Day'];
		$empty_year = empty($bday_year) || $bday_year == $lang['Default_Year'];
	}
	else
	{
		$empty_month = false;
		$empty_day = false;
		$empty_year = false;
		// we set the following to 1 since otherwise we'd be assigning undefined variables to $temp_*
		$bday_month = $bday_day = $bday_year = 1;
	}

	$temp_month = $empty_month ? 1 : $bday_month;
	$temp_day = $empty_day ? 1 : $bday_day;
	$temp_year = $empty_year ? 4 : $bday_year;

	switch (true)
	{
		case $board_config['bday_require'] && $board_config['bday_year'] && ($empty_month || $empty_day || $empty_year):
		case $board_config['bday_require'] && !$board_config['bday_year'] && ($empty_month || $empty_day):
		case !$board_config['bday_require'] && $board_config['bday_year'] && (($empty_month != $empty_day) || ($empty_day != $empty_year)):
		case !$board_config['bday_require'] && !$board_config['bday_year'] && (($empty_month != $empty_day) || ($empty_day && !$empty_year)):
		case !@checkdate( $temp_month, $temp_day, $temp_year ):
			$error = TRUE;
			$error_msg .= ( ( !empty($error_msg) ) ? '<br />' : '' ) . $lang['Birthday_invalid'];
			break;
		case !$empty_month && !$empty_day && !$empty_year && !$bday_locked:
			$age = gmdate('Y') - $bday_year - ( sprintf('%02d%02d',$bday_month,$bday_day) > gmdate('md',time()) );
			if ( $board_config['bday_min'] > $age || $age > $board_config['bday_max'] )
			{
				$error = TRUE;
				$error_msg .= ( ( !empty($error_msg) ) ? '<br />' : '' ) . sprintf($lang['Birthday_range'],$board_config['bday_min'],$board_config['bday_max']);
			}
	}

	$user_birthday = sprintf('%02d%02d%04d',$bday_month,$bday_day,$bday_year);
	$user_birthday2 = ( $birthday_display != BIRTHDAY_DATE && $birthday_display != BIRTHDAY_NONE && !$empty_month && !$empty_day && !$empty_year ) ? sprintf('%04d%02d%02d',$bday_year,$bday_month,$bday_day) : 'NULL';

	if ( $birthday_greeting && !( $board_config['bday_greeting'] & 1<<($birthday_greeting-1) ) )
	{
		$birthday_greeting = 0;
	}

#
#-----[ FIND ]------------------------------------------
# this is a partial match
#
			$sql = "UPDATE " . USERS_TABLE . "
				SET " . $username_sql . $passwd_sql
#
#-----[ BEFORE, ADD ]-----------------------------------
#
			$birthday_sql = '';
			if ( !$board_config['bday_lock'] || $userdata['user_birthday'] == 0 )
			{
				$birthday_sql = "user_birthday = $user_birthday, user_birthday2 = $user_birthday2, ";
			}

#
#-----[ IN-LINE FIND ]----------------------------------
#
, user_icq = '" . str_replace("\'", "''", $icq) . "'
#
#-----[ IN-LINE BEFORE, ADD ]---------------------------
#
, " . $birthday_sql . "birthday_display = $birthday_display, birthday_greeting = $birthday_greeting
#
#-----[ FIND ]------------------------------------------
# this is a partial match
#
			$sql = "INSERT INTO " . USERS_TABLE . "	(user_id, username
				VALUES ($user_id, '" . str_replace("\'", "''", $username)
#
#-----[ IN-LINE FIND ]----------------------------------
#
, user_icq
#
#-----[ IN-LINE BEFORE, ADD ]---------------------------
#
, user_birthday, user_birthday2, birthday_display, birthday_greeting
#
#-----[ IN-LINE FIND ]----------------------------------
#
, '" . str_replace("\'", "''", $icq) . "'
#
#-----[ IN-LINE BEFORE, ADD ]---------------------------
#
, $user_birthday, $user_birthday2, $birthday_display, $birthday_greeting
#
#-----[ FIND ]------------------------------------------
#
	$icq = $userdata['user_icq'];
#
#-----[ BEFORE, ADD ]-----------------------------------
#
	preg_match('/(..)(..)(....)/', sprintf('%08d',$userdata['user_birthday']), $bday_parts);
	$bday_month = $bday_parts[1];
	$bday_day = $bday_parts[2];
	$bday_year = $bday_parts[3];
	$birthday_display = $userdata['birthday_display'];
	$birthday_greeting = $userdata['birthday_greeting'];

#
#-----[ FIND ]------------------------------------------
# this is a partial match
#
	display_avatar_gallery($mode,
#
#-----[ IN-LINE FIND ]----------------------------------
#
$user_lang,
#
#-----[ IN-LINE AFTER, ADD ]----------------------------
#
 $bday_month, $bday_day, $bday_year, $birthday_display, $birthday_greeting,
#
#-----[ FIND ]------------------------------------------
#
		'CONFIRM_IMG' => $confirm_image,
#
#-----[ AFTER, ADD ]------------------------------------
#
		'BDAY_MONTH' => ($bday_month != 0) ? $bday_month : $lang['Default_Month'],
		'BDAY_DAY' => ($bday_day != 0) ? $bday_day : $lang['Default_Day'],
		'BDAY_YEAR' => ($bday_year != 0) ? $bday_year : $lang['Default_Year'],
		'BIRTHDAY_ALL' => BIRTHDAY_ALL,
		'BIRTHDAY_ALL_SELECTED' => ( $birthday_display == BIRTHDAY_ALL ) ? ' selected="selected"' : '',
		'BIRTHDAY_DATE' => BIRTHDAY_DATE,
		'BIRTHDAY_DATE_SELECTED' => ( $birthday_display == BIRTHDAY_DATE ) ? ' selected="selected"' : '',
		'BIRTHDAY_AGE' => BIRTHDAY_AGE,
		'BIRTHDAY_AGE_SELECTED' => ( $birthday_display == BIRTHDAY_AGE ) ? ' selected="selected"' : '',
		'BIRTHDAY_NONE' => BIRTHDAY_NONE,
		'BIRTHDAY_NONE_SELECTED' => ( $birthday_display == BIRTHDAY_NONE ) ? ' selected="selected"' : '',
		'BDAY_NONE_ENABLED' => ( !$birthday_greeting ) ? ' checked="checked"' : '',
		'BDAY_EMAIL' => BIRTHDAY_EMAIL,
		'BDAY_EMAIL_ENABLED' => ( $birthday_greeting == BIRTHDAY_EMAIL ) ? ' checked="checked"' : '',
		'BDAY_PM' => BIRTHDAY_PM,
		'BDAY_PM_ENABLED' => ( $birthday_greeting == BIRTHDAY_PM ) ? ' checked="checked"' : '', 
		'BDAY_POPUP' => BIRTHDAY_POPUP,
		'BDAY_POPUP_ENABLED' => ( $birthday_greeting == BIRTHDAY_POPUP ) ? ' checked="checked"' : '',
#
#-----[ FIND ]------------------------------------------
#
		'LANGUAGE_SELECT' => language_select($user_lang, 'language'),
#
#-----[ AFTER, ADD ]------------------------------------
#
		'BIRTHMONTH_SELECT' => bday_month_select($bday_month, 'bday_month'),
		'BIRTHDAY_SELECT' => bday_day_select($bday_day, 'bday_day'),
		'BIRTHYEAR_SELECT' => bday_year_select($bday_year, 'bday_year'),
#
#-----[ FIND ]------------------------------------------
#
		'L_ICQ_NUMBER' => $lang['ICQ'],
#
#-----[ BEFORE, ADD ]-----------------------------------
#
		'L_CLEAR' => $lang['Clear'],
		'L_BIRTHDAY' => $lang['Birthday'],
		'L_MONTH' => $lang['Month'],
		'L_DAY' => $lang['Day'],
		'L_YEAR' => ( $board_config['bday_year'] ) ? $lang['Year'] : $lang['Year_Optional'],
		'L_OPTIONAL' => ( $board_config['bday_year'] ) ? '' : $lang['Optional'],
		'L_BIRTHDAY_DISPLAY' => $lang['Birthday_Display'],
		'L_BIRTHDAY_ALL' => $lang['Display_all'],
		'L_BIRTHDAY_YEAR' => $lang['Display_day_and_month'],
		'L_BIRTHDAY_AGE' => $lang['Display_age'],
		'L_BIRTHDAY_NONE' => $lang['Display_nothing'],
		'L_BDAY_SEND_GREETING' => $lang['bday_send_greeting'],
		'L_BDAY_SEND_GREETING_EXPLAIN' => $lang['bday_send_greeting_user_explain'],
		'L_NONE' => $lang['Do_not_send'],
		'L_EMAIL' => $lang['Email'],
		'L_PM' => $lang['PM'],
		'L_POPUP' => $lang['Popup'],
#
#-----[ FIND ]------------------------------------------
#
		'S_PROFILE_ACTION' => append_sid("profile.$phpEx"))
	);
#
#-----[ AFTER, ADD ]------------------------------------
#

	if ( !$board_config['bday_lock'] || $userdata['user_birthday'] == 0 )
	{
		$block = ( $board_config['bday_require'] == TRUE ) ? 'birthday_required' : 'birthday_optional';
		$template->assign_block_vars($block, array());
		$template->birthday_interface();
	}

	if ( $board_config['bday_greeting'] != 0 )
	{
		$template->assign_block_vars('birthdays_greeting',array());
		if ($board_config['bday_greeting'] & (1<<(BIRTHDAY_EMAIL-1)))
		{
			$template->assign_block_vars('birthdays_greeting.birthdays_email',array());
		}
		if ($board_config['bday_greeting'] & (1<<(BIRTHDAY_PM-1)))
		{
			$template->assign_block_vars('birthdays_greeting.birthdays_pm',array());
		}
		if ($board_config['bday_greeting'] & (1<<(BIRTHDAY_POPUP-1)))
		{
			$template->assign_block_vars('birthdays_greeting.birthdays_popup',array());
		}
	}
#
#-----[ OPEN ]------------------------------------------
#
includes/usercp_viewprofile.php
#
#-----[ FIND ]------------------------------------------
#
if ( !empty($profiledata['user_icq']) )
#
#-----[ BEFORE, ADD ]-----------------------------------
#
$birthday = '&nbsp;';
if ( !empty($profiledata['user_birthday']) && $profiledata['birthday_display'] != BIRTHDAY_AGE && $profiledata['birthday_display'] != BIRTHDAY_NONE )
{
	preg_match('/(..)(..)(....)/', sprintf('%08d',$profiledata['user_birthday']), $bday_parts);
	$bday_month = $bday_parts[1];
	$bday_day = $bday_parts[2];
	$bday_year = ( $profiledata['birthday_display'] != BIRTHDAY_DATE ) ? $bday_parts[3] : 0;
	// the next line converts $lang['DATE_FORMAT'] to something that'll work with years, as this MOD encodes them.  the preg_replace replaces things like ', Y' with '' when the year isn't
	// specified, to account for date formats that would result in strings like 'October 31, 2005'
	$birthday_format = ($bday_year != 0) ? str_replace(array('y','Y'),array($bday_year % 100,$bday_year),$lang['DATE_FORMAT']) : preg_replace('#[^djFmMnYy]*[Yy]#','',$lang['DATE_FORMAT']);
	$birthday = create_date($birthday_format, gmmktime(12,0,0,$bday_month,$bday_day,2000), 0);
}

#
#-----[ FIND ]------------------------------------------
#
	'LOCATION' => ( $profiledata['user_from'] ) ? $profiledata['user_from'] : '&nbsp;',
#
#-----[ BEFORE, ADD ]-----------------------------------
#
	'BIRTHDAY' => $birthday,
#
#-----[ FIND ]------------------------------------------
#
	'L_LOCATION' => $lang['Location'],
#
#-----[ BEFORE, ADD ]-----------------------------------
#
	'L_BIRTHDAY' => $lang['Birthday'],
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_admin.php
#
#-----[ FIND ]------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]-----------------------------------
#
$lang['Birthdays'] = 'Birthdays';
$lang['bday_show'] = 'Birthday Panel Visibility';
$lang['Unconditional'] = 'Unconditional';
$lang['Conditional'] = 'Conditional';
$lang['bday_show_explain'] = 'Determines whether or not the Birthday Panel on the main Index should be visible in the event that there are no birthdays or upcoming birthdays (unconditional = yes, conditional = no)';
$lang['bday_require'] = 'Require Date of Birth';
$lang['bday_require_explain'] = 'The year of birth will only be required if the "Require Year" option is selected';
$lang['bday_year'] = 'Require Year';
$lang['bday_year_explain'] = 'When this option is selected, users attempting to provide a date of birth will also need to provide a year of birth.';
$lang['bday_lock'] = 'Disallow Date of Birth Changes';
$lang['bday_lock_explain'] = 'Once entered, the date of birth cannot be changed, again.  Atleast when this option is selected.';
$lang['bday_lookahead'] = 'Number of Days to Look Ahead';
$lang['bday_lookahead_explain'] = 'Affects the Birthday Panel on the main Index.  Entering -1 will disable Birthday Lookahead';
$lang['bday_age_range'] = 'Allowable Age Range (in years)';
$lang['bday_hide'] = 'Hide Birthday Panel from Guests';
$lang['bday_send_greeting_admin_explain'] = 'Your members will choose either one or none of the options you enable.';

#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]-----------------------------------
#
$lang['Birthday_range'] = 'Birthdays must yield ages between %d and %d years, inclusive.';
$lang['No_birthdays'] = 'No birthdays today';
$lang['Congratulations'] = 'Congratulations to: <b>%s</b>';
$lang['Upcoming_birthdays'] = 'Users with a birthday within the next %d days: <b>%s</b>';
$lang['No_upcoming'] = 'No users are having a birthday in the upcoming %d days';
$lang['Birthday'] = 'Date of Birth';
$lang['Month'] = 'Month';
$lang['Day'] = 'Day';
$lang['Year'] = 'Year';
$lang['Clear'] = 'Clear';
$lang['Year_Optional'] = 'Year <i>(Optional)</i>';
$lang['Optional'] = '<i>(Optional)</i>';
$lang['Default_Month'] = '[ Select a Month ]';
$lang['Default_Day'] = 'dd';
$lang['Default_Year'] = 'yyyy';
$lang['Birthday_invalid'] = 'You didn\'t specify a valid Birthday.';
$lang['Todays_Birthdays'] = 'Today\'s Birthdays';
$lang['View_Birthdays'] = 'Happy Birthday!';
$lang['Birthday_Display'] = 'Date of Birth Public Display Options';
$lang['Display_all'] = 'Display everything';
$lang['Display_day_and_month'] = 'Display day and month (but not year)';
$lang['Display_age'] = 'Display age (but not day or month)';
$lang['Display_nothing'] = 'Display nothing';
$lang['Age'] = 'Age: %d<br />';
$lang['Sort_Age'] = 'Age';
$lang['PM'] = 'PM';
$lang['Popup'] = 'Popup';
$lang['bday_send_greeting'] = 'Send Birthday Greetings via';
$lang['bday_send_greeting_user_explain'] = 'Determines how you will recieve Birthday Greetings on your birthday.';
$lang['Do_not_send'] = 'Do not send';
$lang['Birthday_popup'] = '%s would like to wish you a very happy birthday!';

#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/admin/board_config_body.tpl
#
#-----[ FIND ]------------------------------------------
#
	<tr>
		<th class="thHead" colspan="2">{L_COOKIE_SETTINGS}</th>
	</tr>
#
#-----[ BEFORE, ADD ]-----------------------------------
#
	<tr>
		<th class="thHead" colspan="2">{L_BIRTHDAYS}</th>
	</tr>
	<tr>
		<td class="row1">{L_BDAY_REQUIRE}<br /><span class="gensmall">{L_BDAY_REQUIRE_EXPLAIN}</span></td>
		<td class="row2"><input type="radio" name="bday_require" value="1" {BDAY_REQUIRE_YES} />{L_YES}&nbsp; &nbsp;<input type="radio" name="bday_require" value="0" {BDAY_REQUIRE_NO} />{L_NO}</td>
	</tr>
	<tr>
		<td class="row1">{L_BDAY_YEAR}<br /><span class="gensmall">{L_BDAY_YEAR_EXPLAIN}</span></td>
		<td class="row2"><input type="radio" name="bday_year" value="1" {BDAY_YEAR_YES} />{L_YES}&nbsp; &nbsp;<input type="radio" name="bday_year" value="0" {BDAY_YEAR_NO} />{L_NO}</td>
	</tr>
	<tr>
		<td class="row1">{L_BDAY_LOCK}<br /><span class="gensmall">{L_BDAY_LOCK_EXPLAIN}</span></td>
		<td class="row2"><input type="radio" name="bday_lock" value="1" {BDAY_LOCK_YES} />{L_YES}&nbsp; &nbsp;<input type="radio" name="bday_lock" value="0" {BDAY_LOCK_NO} />{L_NO}</td>
	</tr>
	<tr>
		<td class="row1">{L_BDAY_LOOKAHEAD}<br /><span class="gensmall">{L_BDAY_LOOKAHEAD_EXPLAIN}</span></td>
		<td class="row2"><input class="post" type="text" size="2" maxlength="2" name="bday_lookahead" value="{BDAY_LOOKAHEAD}" /></td>
	</tr>
	<tr>
		<td class="row1">{L_BDAY_AGE_RANGE}</td>
		<td class="row2"><input class="post" type="text" size="2" maxlength="2" name="bday_min" value="{BDAY_MIN}" /> {L_TO} <input class="post" type="text" size="3" maxlength="3" name="bday_max" value="{BDAY_MAX}" /></td>
	</tr>
	<tr>
		<td class="row1">{L_BDAY_HIDE}</td>
		<td class="row2"><input type="radio" name="bday_hide" value="1" {BDAY_HIDE_YES} />{L_YES}&nbsp; &nbsp;<input type="radio" name="bday_hide" value="0" {BDAY_HIDE_NO} />{L_NO}</td>
	</tr>
	<tr>
		<td class="row1">{L_BDAY_SHOW}<br /><span class="gensmall">{L_BDAY_SHOW_EXPLAIN}</span></td>
		<td class="row2"><input type="radio" name="bday_show" value="1" {BDAY_SHOW_YES} />{L_UNCONDITIONAL}&nbsp; &nbsp;<input type="radio" name="bday_show" value="0" {BDAY_SHOW_NO} />{L_CONDITIONAL}</td>
	</tr>
	<tr>
		<td class="row1">{L_BDAY_SEND_GREETING}<br /><span class="gensmall">{L_BDAY_SEND_GREETING_EXPLAIN}</span></td>
		<td class="row2">
		  <input type="checkbox" name="bday_email_mask" value="{BDAY_EMAIL}" {BDAY_EMAIL_ENABLED} /> {L_EMAIL}&nbsp;&nbsp;
		  <input type="checkbox" name="bday_pm_mask" value="{BDAY_PM}" {BDAY_PM_ENABLED} /> {L_PM}&nbsp;&nbsp;
		  <input type="checkbox" name="bday_popup_mask" value="{BDAY_POPUP}" {BDAY_POPUP_ENABLED} /> {L_POPUP}&nbsp;&nbsp;
		</td>
	</tr>
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/admin/user_edit_body.tpl
#
#-----[ FIND ]------------------------------------------
#
	<tr> 
	  <td class="row1"><span class="gen">{L_NEW_PASSWORD}: *</span><br />
#
#-----[ BEFORE, ADD ]-----------------------------------
#
	<!-- BEGIN birthday_required -->
	  <tr>
	    <td class="row1"><span class="gen">{L_BIRTHDAY}: *</span></td>
	    <td class="row2">{BIRTHDAY_INTERFACE}</td>
	</tr>
	<!-- END birthday_required -->
#
#-----[ FIND ]------------------------------------------
#
	<tr> 
	  <td class="row1"><span class="gen">{L_SIGNATURE}</span><br />
		<span class="gensmall">{L_SIGNATURE_EXPLAIN}<br />
		<br />
		{HTML_STATUS}<br />
		{BBCODE_STATUS}<br />
		{SMILIES_STATUS}</span></td>
	  <td class="row2"> 
		<textarea class="post" name="signature" rows="6" cols="45">{SIGNATURE}</textarea>
	  </td>
	</tr>
#
#-----[ BEFORE, ADD ]-----------------------------------
#
	<!-- BEGIN birthday_optional -->
	  <tr>
	    <td class="row1"><span class="gen">{L_BIRTHDAY}:</span></td>
	    <td class="row2">{BIRTHDAY_INTERFACE}</td>
	</tr>
	<!-- END birthday_optional -->
#
#-----[ FIND ]------------------------------------------
#
	<tr> 
	  <td class="row1"><span class="gen">{L_NOTIFY_ON_REPLY}</span></td>
#
#-----[ BEFORE, ADD ]-----------------------------------
#
	<tr>
	  <td class="row1"><span class="gen">{L_BIRTHDAY_DISPLAY}:</span><br />
	  <td class="row2"><span class="gen">
	    <select name="birthday_display">
	      <option value="{BIRTHDAY_ALL}"{BIRTHDAY_ALL_SELECTED}>{L_BIRTHDAY_ALL}</option>
	      <option value="{BIRTHDAY_DATE}"{BIRTHDAY_DATE_SELECTED}>{L_BIRTHDAY_YEAR}</option>
	      <option value="{BIRTHDAY_AGE}"{BIRTHDAY_AGE_SELECTED}>{L_BIRTHDAY_AGE}</option>
	      <option value="{BIRTHDAY_NONE}"{BIRTHDAY_NONE_SELECTED}>{L_BIRTHDAY_NONE}</option>
	    </select>
	  </td>
	</tr>
	<!-- BEGIN birthdays_greeting -->
	<tr>
	  <td class="row1"><span class="gen">{L_BDAY_SEND_GREETING}:</span><br /><span class="gensmall">{L_BDAY_SEND_GREETING_EXPLAIN}</span></td>
	  <td class="row2"><span class="gen">
		  <input type="radio" name="bday_greeting" value="0" {BDAY_NONE_ENABLED} /> {L_NONE}&nbsp;&nbsp;
		  <!-- BEGIN birthdays_email -->
		  <input type="radio" name="bday_greeting" value="{BDAY_EMAIL}" {BDAY_EMAIL_ENABLED} /> {L_EMAIL}&nbsp;&nbsp;
		  <!-- END birthdays_email -->
		  <!-- BEGIN birthdays_pm -->
		  <input type="radio" name="bday_greeting" value="{BDAY_PM}" {BDAY_PM_ENABLED} /> {L_PM}&nbsp;&nbsp;
		  <!-- END birthdays_pm -->
		  <!-- BEGIN birthdays_popup -->
		  <input type="radio" name="bday_greeting" value="{BDAY_POPUP}" {BDAY_POPUP_ENABLED} /> {L_POPUP}&nbsp;&nbsp;
		  <!-- END birthdays_popup -->
	  </span></td>
	</tr>
	<!-- END birthdays_greeting -->
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/index_body.tpl
#
#-----[ FIND ]------------------------------------------
#
  <tr> 
	<td class="row1" align="left"><span class="gensmall">{TOTAL_USERS_ONLINE} &nbsp; [ {L_WHOSONLINE_ADMIN} ] &nbsp; [ {L_WHOSONLINE_MOD} ]<br />{RECORD_USERS}<br />{LOGGED_IN_USER_LIST}</span></td>
  </tr>
#
#-----[ AFTER, ADD ]------------------------------------
#
  <!-- BEGIN birthdays -->
  <tr>
	<td class="catHead" colspan="2" height="28"><span class="cattitle">{L_TODAYS_BIRTHDAYS}</span></td>
  </tr>
  <tr> 
	<td class="row1" colspan="2"><table cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td align="center" valign="middle" style="padding-right: 3px"><img src="templates/subSilver/images/icon_birthday.gif" alt="{L_VIEW_BIRTHDAYS}" /></td>
			<td align="left" width="100%">
			  <span class="gensmall">{BIRTHDAYS}
			  <!-- BEGIN upcoming -->
			  <br />{UPCOMING}
			  <!-- END upcoming -->
			  </span>
			</td>
	  	</tr>
	</table></td>
  </tr>
  <!-- END birthdays -->
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/memberlist_body.tpl
#
#-----[ FIND ]------------------------------------------
#
	  <th class="thTop" nowrap="nowrap">{L_JOINED}</th>
#
#-----[ BEFORE, ADD ]-----------------------------------
#
	  <th class="thTop" nowrap="nowrap">{L_AGE}</th>
#
#-----[ FIND ]------------------------------------------
#
	  <td class="{memberrow.ROW_CLASS}" align="center" valign="middle"><span class="gensmall">{memberrow.JOINED}</span></td>
#
#-----[ BEFORE, ADD ]-----------------------------------
#
	  <td class="{memberrow.ROW_CLASS}" align="center" valign="middle"><span class="gensmall">{memberrow.AGE}</span></td>
#
#-----[ FIND ]------------------------------------------
#
	  <td class="catBottom" colspan="{%:1}" height="28">&nbsp;</td>
#
#-----[ INCREMENT ]-------------------------------------
#
%:1
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/overall_header.tpl
#
#-----[ FIND ]------------------------------------------
#
<!-- BEGIN switch_enable_pm_popup -->
#
#-----[ BEFORE, ADD ]-----------------------------------
#
<!-- BEGIN switch_birthday_popup -->
<script language="Javascript" type="text/javascript">
<!--
	window.open('{U_BIRTHDAYS_POPUP}', '_phpbbbirthday', 'HEIGHT=225,resizable=yes,WIDTH=400');
//-->
</script>
<!-- END switch_birthday_popup -->
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/profile_add_body.tpl
#
#-----[ FIND ]------------------------------------------
#
	<!-- BEGIN switch_edit_profile -->
#
#-----[ BEFORE, ADD ]-----------------------------------
#
	<!-- BEGIN birthday_required -->
	<tr>
	  <td class="row1"><span class="gen">{L_BIRTHDAY}: *</span></td>
	  <td class="row2">{BIRTHDAY_INTERFACE}</td>
	</tr>
	<!-- END birthday_required -->
#
#-----[ FIND ]------------------------------------------
#
	<tr> 
	  <td class="row1"><span class="gen">{L_SIGNATURE}:</span><br /><span class="gensmall">{L_SIGNATURE_EXPLAIN}<br /><br />{HTML_STATUS}<br />{BBCODE_STATUS}<br />{SMILIES_STATUS}</span></td>
#
#-----[ BEFORE, ADD ]-----------------------------------
#
	<!-- BEGIN birthday_optional -->
	<tr>
	  <td class="row1"><span class="gen">{L_BIRTHDAY}:</span></td>
	  <td class="row2">{BIRTHDAY_INTERFACE}</td>
	</tr>
	<!-- END birthday_optional -->
#
#-----[ FIND ]------------------------------------------
#
	<tr> 
	  <td class="row1"><span class="gen">{L_NOTIFY_ON_REPLY}:</span><br />
#
#-----[ BEFORE, ADD ]-----------------------------------
#
	<tr>
	  <td class="row1"><span class="gen">{L_BIRTHDAY_DISPLAY}:</span></td>
	  <td class="row2"><span class="gen">
	    <select name="birthday_display">
	      <option value="{BIRTHDAY_ALL}"{BIRTHDAY_ALL_SELECTED}>{L_BIRTHDAY_ALL}</option>
	      <option value="{BIRTHDAY_DATE}"{BIRTHDAY_DATE_SELECTED}>{L_BIRTHDAY_YEAR}</option>
	      <option value="{BIRTHDAY_AGE}"{BIRTHDAY_AGE_SELECTED}>{L_BIRTHDAY_AGE}</option>
	      <option value="{BIRTHDAY_NONE}"{BIRTHDAY_NONE_SELECTED}>{L_BIRTHDAY_NONE}</option>
	    </select>
	  </td>
	</tr>
	<!-- BEGIN birthdays_greeting -->
	<tr>
	  <td class="row1"><span class="gen">{L_BDAY_SEND_GREETING}:</span><br /><span class="gensmall">{L_BDAY_SEND_GREETING_EXPLAIN}</span></td>
	  <td class="row2"><span class="gen">
		  <input type="radio" name="bday_greeting" value="0" {BDAY_NONE_ENABLED} /> {L_NONE}&nbsp;&nbsp;
		  <!-- BEGIN birthdays_email -->
		  <input type="radio" name="bday_greeting" value="{BDAY_EMAIL}" {BDAY_EMAIL_ENABLED} /> {L_EMAIL}&nbsp;&nbsp;
		  <!-- END birthdays_email -->
		  <!-- BEGIN birthdays_pm -->
		  <input type="radio" name="bday_greeting" value="{BDAY_PM}" {BDAY_PM_ENABLED} /> {L_PM}&nbsp;&nbsp;
		  <!-- END birthdays_pm -->
		  <!-- BEGIN birthdays_popup -->
		  <input type="radio" name="bday_greeting" value="{BDAY_POPUP}" {BDAY_POPUP_ENABLED} /> {L_POPUP}&nbsp;&nbsp;
		  <!-- END birthdays_popup -->
	  </span></td>
	</tr>
	<!-- END birthdays_greeting -->
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/profile_view_body.tpl
#
#-----[ FIND ]------------------------------------------
#
		<tr> 
		  <td valign="top" align="right" nowrap="nowrap"><span class="gen">{L_INTERESTS}:</span></td>
		  <td> <b><span class="gen">{INTERESTS}</span></b></td>
		</tr>
#
#-----[ AFTER, ADD ]------------------------------------
#
		<tr> 
		  <td valign="top" align="right" nowrap="nowrap"><span class="gen">{L_BIRTHDAY}:</span></td>
		  <td> <b><span class="gen">{BIRTHDAY}</span></b></td>
		</tr>

#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/viewtopic_body.tpl
#
#-----[ FIND ]------------------------------------------
#
<td width="150" align="left" valign="top" class="{postrow.ROW_CLASS}"><span class="name"><a name="{postrow.U_POST_ID}"></a>
#
#-----[ IN-LINE FIND ]----------------------------------
#
{postrow.POSTER_JOINED}<br />
#
#-----[ IN-LINE AFTER, ADD ]----------------------------
#
{postrow.POSTER_AGE}
#
#-----[ OPEN ]------------------------------------------
#
index.php
#
#-----[ FIND ]------------------------------------------
#
	while( $row = $db->sql_fetchrow($result) )
	{
		$forum_moderators[$row['forum_id']][] = '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $row['group_id']) . '">' . $row['group_name'] . '</a>';
	}
	$db->sql_freeresult($result);
#
#-----[ AFTER, ADD ]------------------------------------
#

	if ( !$board_config['bday_hide'] || $userdata['session_logged_in'] )
	{
		// if birthday_display is set to "Display age (but not day or month)" (eg. BIRTHDAY_AGE), we don't display it here,
		// since this code would make it trivially easy to extrapolate that information.
		$sql = "SELECT user_id, username, user_birthday, birthday_display, user_level 
			FROM " . USERS_TABLE . " 
			WHERE user_birthday >= " . gmdate('md0000',time() + (3600 * $board_config['board_timezone'])) . " 
				AND user_birthday <= " . gmdate('md9999',time() + (3600 * $board_config['board_timezone']))." 
				AND user_active = 1 
				AND birthday_display <> " . BIRTHDAY_NONE . " 
				AND birthday_display <> " . BIRTHDAY_AGE . " 
			ORDER BY username DESC";
		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Could not query members birthday information', '', __LINE__, __FILE__, $sql);
		}

		$user_birthdays = array();
		while ( $row = $db->sql_fetchrow($result) )
		{
			// if birthday_display is set to "Display day and month (but not year)" (eg. BIRTHDAY_DATE), set the year
			// to 0.
			$bday_year = ( $row['birthday_display'] != BIRTHDAY_DATE ) ? $row['user_birthday'] % 10000 : 0;
			$age = ( $bday_year ) ? ' ('.(gmdate('Y')-$bday_year).')' : '';
			$color = '';
			if ( $row['user_level'] == ADMIN )
			{
				$color = ' style="color:#' . $theme['fontcolor3'] . '"';
			}
			else if ( $row['user_level'] == MOD )
			{
				$color = ' style="color:#' . $theme['fontcolor2'] . '"';
			}
			$user_birthdays[] = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $color . '>' . $row['username'] . '</a>' . $age;
		}
		$db->sql_freeresult($result);

		$birthdays = (!empty($user_birthdays)) ?
			sprintf($lang['Congratulations'],implode(', ',$user_birthdays)) :
			$lang['No_birthdays'];

		if ( $board_config['bday_lookahead'] != -1 )
		{
			$start = gmdate('md9999',strtotime('+'.$board_config['bday_lookahead'].' day') + (3600 * $board_config['board_timezone']));
			$end = gmdate('md0000',strtotime('+1 day') + (3600 * $board_config['board_timezone']));
			$operator = ($start > $end) ? 'AND' : 'OR';
			$sql = "SELECT user_id, username, user_birthday, birthday_display, user_level 
				FROM " . USERS_TABLE . " 
				WHERE (user_birthday <= $start 
					$operator user_birthday >= $end)
					AND user_birthday <> 0 
					AND user_active = 1 
					AND birthday_display <> " . BIRTHDAY_NONE . " 
					AND birthday_display <> " . BIRTHDAY_AGE . " 
				ORDER BY user_birthday ASC, username DESC";
			if ( !($result = $db->sql_query($sql)) )
			{
				message_die(GENERAL_ERROR, 'Could not query upcoming birthday information', '', __LINE__, __FILE__, $sql);
			}
			$upcoming_birthdays = array();
			while ( $row = $db->sql_fetchrow($result) )
			{
				$bday_month_day = floor($row['user_birthday'] / 10000);
				$bday_year_age = ( $row['birthday_display'] != BIRTHDAY_DATE ) ? $row['user_birthday'] - 10000*$bday_month_day : 0;
				$fudge = ( gmdate('md') < $bday_month_day ) ? 0 : 1;
				$age = ( $bday_year_age ) ? ' ('.(gmdate('Y')-$bday_year_age+$fudge).')' : '';
				$color = '';
				if ( $row['user_level'] == ADMIN )
				{
					$color = ' style="color:#' . $theme['fontcolor3'] . '"';
				}
				else if ( $row['user_level'] == MOD )
				{
					$color = ' style="color:#' . $theme['fontcolor2'] . '"';
				}
				$upcoming_birthdays[] = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '"' . $color . '>' . $row['username'] . '</a>' . $age;
			}

			$upcoming = (!empty($upcoming_birthdays)) ?
				sprintf($lang['Upcoming_birthdays'],$board_config['bday_lookahead'],implode(', ',$upcoming_birthdays)) :
				sprintf($lang['No_upcoming'],$board_config['bday_lookahead']);
		}

		if ( !empty($user_birthdays) || !empty($upcoming_birthdays) || $board_config['bday_show'] )
		{
			$template->assign_block_vars('birthdays',array());
			if ( !empty($upcoming_birthdays) || $board_config['bday_show'] )
			{
				$template->assign_block_vars('birthdays.upcoming',array());
			}
		}
	}
#
#-----[ FIND ]------------------------------------------
#
		'NEWEST_USER' => sprintf($lang['Newest_user'], '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$newest_uid") . '">', $newest_user, '</a>'), 
#
#-----[ AFTER, ADD ]------------------------------------
#
		'BIRTHDAYS' => $birthdays,
		'UPCOMING' => $upcoming,
#
#-----[ FIND ]------------------------------------------
#
		'L_FORUM' => $lang['Forum'],
#
#-----[ BEFORE, ADD ]-----------------------------------
#
		'L_TODAYS_BIRTHDAYS' => $lang['Todays_Birthdays'],
		'L_VIEW_BIRTHDAYS' => $lang['View_Birthdays'],

#
#-----[ OPEN ]------------------------------------------
#
memberlist.php
#
#-----[ FIND ]------------------------------------------
#
$mode_types_text = array(
#
#-----[ IN-LINE FIND ]----------------------------------
#
 $lang['Sort_Posts'],
#
#-----[ IN-LINE AFTER, ADD ]----------------------------
#
 $lang['Sort_Age'],
#
#-----[ FIND ]------------------------------------------
#
$mode_types = array(
#
#-----[ IN-LINE FIND ]----------------------------------
#
 'posts',
#
#-----[ IN-LINE AFTER, ADD ]----------------------------
#
 'age',
#
#-----[ FIND ]------------------------------------------
#
	'L_JOINED' => $lang['Joined'],
#
#-----[ AFTER, ADD ]------------------------------------
#
	'L_AGE' => $lang['Sort_Age'],
#
#-----[ FIND ]------------------------------------------
#
	case 'posts':
		$order_by = "user_posts $sort_order LIMIT $start, " . $board_config['topics_per_page'];
		break;
#
#-----[ AFTER, ADD ]------------------------------------
#
	case 'age':
		$age_order = $sort_order == 'ASC' ? 'DESC' : 'ASC';
		$order_by = 'coalesce(user_birthday2,';
		$order_by.= ($age_order == 'ASC') ? '99999999' : '0';
		$order_by.= ") $age_order LIMIT $start, " . $board_config['topics_per_page'];
		break;
#
#-----[ FIND ]------------------------------------------
#
$sql = "SELECT username, user_id, user_viewemail, user_posts,
#
#-----[ IN-LINE FIND ]----------------------------------
#
 user_posts,
#
#-----[ IN-LINE AFTER, ADD ]----------------------------
#
 user_birthday, birthday_display,
#
#-----[ FIND ]------------------------------------------
#
		$posts = ( $row['user_posts'] ) ? $row['user_posts'] : 0;
#
#-----[ AFTER, ADD ]------------------------------------
#

		$bday_month_day = floor($row['user_birthday'] / 10000);
		$bday_year_age = ( $row['birthday_display'] != BIRTHDAY_NONE && $row['birthday_display'] != BIRTHDAY_DATE ) ? $row['user_birthday'] - 10000*$bday_month_day : 0;
		$fudge = ( gmdate('md') < $bday_month_day ) ? 1 : 0;
		$age = ( $bday_year_age ) ? gmdate('Y')-$bday_year_age-$fudge : false;
#
#-----[ FIND ]------------------------------------------
#
			'JOINED' => $joined,
#
#-----[ AFTER, ADD ]------------------------------------
#
			'AGE' => $age,
#
#-----[ OPEN ]------------------------------------------
#
profile.php
#
#-----[ FIND ]------------------------------------------
#
	else if ( $mode == 'email' )
	{
		include($phpbb_root_path . 'includes/usercp_email.'.$phpEx);
		exit;
	}
#
#-----[ AFTER, ADD ]------------------------------------
#
	else if ( $mode == 'birthday_popup' )
	{
		$gen_simple_header = TRUE;

		$page_title = $lang['View_Birthdays'];
		include($phpbb_root_path . 'includes/page_header.'.$phpEx);

		// reuse the pm popup box template
		$template->set_filenames(array(
			'body' => 'privmsgs_popup.tpl')
		);

		$template->assign_vars(array(
			'L_CLOSE_WINDOW' => $lang['Close_window'],
			'L_MESSAGE' => sprintf($lang['Birthday_popup'],$board_config['sitename']))
		);

		$template->pparse('body');

		include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
		exit;
	}
#
#-----[ OPEN ]------------------------------------------
#
privmsg.php
#
#-----[ FIND ]------------------------------------------
# this is a partial match
#
	$sql = "SELECT u.username AS username_1,
#
#-----[ IN-LINE FIND ]----------------------------------
#
 u.user_website,
#
#-----[ IN-LINE AFTER, ADD ]----------------------------
#
 u.user_birthday, u.birthday_display,
#
#-----[ FIND ]------------------------------------------
# this is partial match
#
	$www = ( $privmsg['user_website'] ) ?
#
#-----[ AFTER, ADD ]------------------------------------
#

	$bday_month_day = floor($privmsg['user_birthday'] / 10000);
	$bday_year_age = ( $privmsg['birthday_display'] != BIRTHDAY_NONE && $privmsg['birthday_display'] != BIRTHDAY_DATE ) ? $privmsg['user_birthday'] - 10000*$bday_month_day : 0;
	$fudge = ( gmdate('md') < $bday_month_day ) ? 1 : 0;
	$age = ( $bday_year_age ) ? gmdate('Y')-$bday_year_age-$fudge : false;
#
#-----[ FIND ]------------------------------------------
#
		'POSTER_JOINED' => $poster_joined,
#
#-----[ AFTER, ADD ]------------------------------------
#
		'POSTER_AGE' => ( $age !== false ) ? sprintf($lang['Age'], $age) : '',
#
#-----[ OPEN ]------------------------------------------
#
viewtopic.php
#
#-----[ FIND ]------------------------------------------
# this is partial match
#
$sql = "SELECT u.username, u.user_id,
#
#-----[ IN-LINE FIND ]----------------------------------
#
 u.user_website,
#
#-----[ IN-LINE AFTER, ADD ]----------------------------
#
 u.user_birthday, u.birthday_display,
#
#-----[ FIND ]------------------------------------------
# this is partial match
#
		$www = ( $postrow[$i]['user_website'] ) ?
#
#-----[ AFTER, ADD ]------------------------------------
#

		$bday_month_day = floor($postrow[$i]['user_birthday'] / 10000);
		$bday_year_age = ( $postrow[$i]['birthday_display'] != BIRTHDAY_NONE && $postrow[$i]['birthday_display'] != BIRTHDAY_DATE ) ? $postrow[$i]['user_birthday'] - 10000*$bday_month_day : 0;
		$fudge = ( gmdate('md') < $bday_month_day ) ? 1 : 0;
		$age = ( $bday_year_age ) ? gmdate('Y')-$bday_year_age-$fudge : false;
#
#-----[ FIND ]------------------------------------------
#
		$www = '';
#
#-----[ AFTER, ADD ]------------------------------------
#
		$age = false;
#
#-----[ FIND ]------------------------------------------
#
		'POSTER_JOINED' => $poster_joined,
#
#-----[ AFTER, ADD ]------------------------------------
#
		'POSTER_AGE' => ( $age !== false ) ? sprintf($lang['Age'], $age) : '',
#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------
#
# EoM