##############################################################
## 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: 2.0.1
##
## Installation Level: moderate
## Installation Time: 30 Minutes
##
## Files To Edit: 15
## language/lang_english/lang_main.php
## language/lang_english/lang_admin.php
## includes/functions_selects.php
## includes/template.php
## includes/usercp_register.php
## includes/usercp_avatar.php
## templates/subSilver/profile_add_body.tpl
## admin/admin_users.php
## templates/subSilver/admin/user_edit_body.tpl
## index.php
## templates/subSilver/index_body.tpl
## includes/usercp_viewprofile.php
## templates/subSilver/profile_view_body.tpl
## admin/admin_board.php
## templates/subSilver/admin/board_config_body.tpl
##
## Included Files: 1
## templates/subSilver/images/icon_birthday.gif
## 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:
##
## Although Niels Chr. Denmark's ever-popular Birthday Hack already does that
## which this MOD attempts to do, it does have a number of problems that this
## MOD seeks to remedy.
##
## 1. It isn't validated and hasn't been subjected to a security audit by the
## phpBB MOD Team.
## 2. It saves the birthdate by saving the number of seconds that have elapsed
## since January 1, 1970 to the date in question. This is an inefficient use
## of memory and of storage.
## 3. As a consequence of (2), members *must* specify a birth year, thereby
## effectively telling the world how old they are. This will probably
## disuade some members from using the feature when they might have otherwise
## done so.
##
## Niels MOD 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
##
## LGPL and GPL code can be combined per this:
## http://groups.google.com/group/netscape.public.mozilla.license/msg/7807049753cfbad6
##
## The latest version of this mod can be found here:
## http://www.frostjedi.com/terra/scripts/phpbb/birthdays.zip
##
## For support / comments / whatever, visit the following URL:
## http://www.phpbb.com/phpBB/viewtopic.php?t=342028
##
##############################################################
## MOD History:
##
## XXXX-XX-XX - 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
#
#-----[ SQL ]-------------------------------------------
#
ALTER TABLE phpbb_users ADD user_birthday int(8) 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);
#
#-----[ 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: %s';
$lang['Upcoming_birthdays'] = 'Users with a birthday within the next %d days: %s';
$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 (Optional)';
$lang['Optional'] = '(Optional)';
$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!';
#
#-----[ 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)';
#
#-----[ 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 = '';
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 = '';
return $bday_day_select;
}
#
# start editing the user profile files
#-----[ 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('#(.*?)#', "\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 line is a hack to make this MOD work with the eXtreme Styles MOD. on phpBB's without eXtreme Styles
// installed it doesn't do much of anything
$this->files['bday_interface'] = true;
$this->assign_var_from_handle('BIRTHDAY_INTERFACE','bday_interface');
}
#
#-----[ 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 ]------------------------------------------
#
if ( $signature != '' )
#
#-----[ BEFORE, ADD ]-----------------------------------
#
$empty_day = $bday_day == $lang['Default_Day'] || empty($bday_day);
$empty_year = $bday_year == $lang['Default_Year'] || empty($bday_year);
$temp_month = ( !$board_config['bday_require'] && $bday_month == 0 ) ? 1 : $bday_month;
$temp_day = ( !$board_config['bday_require'] && $empty_day ) ? 1 : $bday_day;
if ( !$board_config['bday_year'] )
{
$temp_year = $empty_year ? 4 : $bday_year;
}
else
{
$temp_year = $bday_year;
if ( !$board_config['bday_require'] && $bday_month == 0 && $empty_year )
{
$temp_year = $empty_year ? 4 : 0;
}
}
if ( !@checkdate( $temp_month, $temp_day, $temp_year ) && (!$board_config['bday_lock'] || $userdata['user_birthday'] == 0) )
{
$error = TRUE;
$error_msg .= ( ( !empty($error_msg) ) ? '
' : '' ) . $lang['Birthday_invalid'];
}
if ( $bday_month != 0 && $bday_day != $lang['Default_Day'] && !$empty_year )
{
$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) ) ? '
' : '' ) . sprintf($lang['Birthday_range'],$board_config['bday_min'],$board_config['bday_max']);
}
}
#
#-----[ FIND ]------------------------------------------
# this is a partial match
#
$sql = "UPDATE " . USERS_TABLE . "
SET " . $username_sql . $passwd_sql
#
#-----[ BEFORE, ADD ]-----------------------------------
#
$user_birthday = ( !$board_config['bday_lock'] || $userdata['user_birthday'] == 0 ) ? sprintf('%02d%02d%04d',$bday_month,$bday_day,$bday_year) : $userdata['user_birthday'];
#
#-----[ IN-LINE FIND ]----------------------------------
#
, user_icq = '" . str_replace("\'", "''", $icq) . "'
#
#-----[ IN-LINE BEFORE, ADD ]---------------------------
#
, user_birthday = " . $user_birthday . "
#
#-----[ 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
#
#-----[ IN-LINE FIND ]----------------------------------
#
, '" . str_replace("\'", "''", $icq) . "'
#
#-----[ IN-LINE BEFORE, ADD ]---------------------------
#
, " . sprintf('%02d%02d%04d',$bday_month,$bday_day,$bday_year) . "
#
#-----[ 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];
#
#-----[ 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,
#
#-----[ 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'],
#
#-----[ 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'),
#
#-----[ 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'],
#
#-----[ 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();
}
#
#-----[ 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,
#
#-----[ FIND ]------------------------------------------
# this is only a partial match
#
$params = array(
#
#-----[ IN-LINE FIND ]----------------------------------
#
'language',
#
#-----[ IN-LINE AFTER, ADD ]----------------------------
#
'bday_month', 'bday_day', 'bday_year',
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/profile_add_body.tpl
#
#-----[ FIND ]------------------------------------------
#
#
#-----[ BEFORE, ADD ]-----------------------------------
#