To update from version 0.0.0 to 0.0.1:
File copy
- Copy: ./root/language/en/mods/require_birth_date.php
To: ./language/en/mods/require_birth_date.php
- Copy: ./root/includes/functions_birthdate.php
To: ./includes/functions_birthdate.php
Open: includes/ucp/ucp_profile.php
Find:
Add after:
Code: Select all
//mod: Require Birth Date on Registration -----------------------------------//
/**
* This contains functions for verifying and displaying the birth date.
*/
include($phpbb_root_path . 'includes/functions_birthdate.' . $phpEx);
//end: Require Birth Date on Registration -----------------------------------//
Find:
Add before:
Code: Select all
//mod: Require Birth Date on Registration -----------------------------------//
if (($result = validate_birth_date($data['bday_day'] . '-' . $data['bday_month'] . '-' . $data['bday_year'])) !== false)
{
$user->add_lang('mods/require_birth_date');
if ($result == 'NO_BIRTH_DATE')
{
$result = 'INVALID_BIRTH_DATE';
}
$error[] = $result;
}
//end: Require Birth Date on Registration -----------------------------------//
Open: includes/ucp/ucp_register.php
Find:
Code: Select all
//mod: Require Birth Date on Registration -----------------------------------//
//- - - - - - - - - - - - - - - - - - - - - - - - - //
//This function will return a person's current age. It accepts the date in //
//the form of a string, in the format "day-month-year". //
//- - - - - - - - - - - - - - - - - - - - - - - - - //
function get_age($date_of_birth) //day-month-year
{
$birth = explode("-", $date_of_birth);
$age = date("Y") - $birth[2];
if (($birth[1] > date("m")) || ($birth[1] == date("m") && date("d") < $birth[0]))
{
$age -= 1;
}
return $age;
}
//- - - - - - - - - - - - - - - - - - - - - - - - - //
//This function will validate a birth date. It accepts the date in the form //
//of a string, in the format "day-month-year". //
//- - - - - - - - - - - - - - - - - - - - - - - - - //
function validate_birth_date($date_of_birth) //day-month-year
{
$minimum_age = 4;
$birth = explode("-", $date_of_birth);
if ((!$birth[0] || !$birth[1] || !$birth[2]))
{
return 'NO_BIRTH_DATE';
}
if ($birth[0] < 0 || $birth[0] > 31 || $birth[1] < 0 || $birth[1] > 12 || ($birth[2] < 1901 && $birth[2] > 0) || $birth[2] > gmdate('Y', time()))
{
return 'INVALID_BIRTH_DATE';
}
if (checkdate($birth[1], $birth[0], $birth[2]) === false)
{
return 'INVALID_BIRTH_DATE';
}
if (get_age($date_of_birth) < $minimum_age)
{
return 'TOO_YOUNG';
}
return(false);
}
//end: Require Birth Date on Registration -----------------------------------//
Replace with:
Code: Select all
//mod: Require Birth Date on Registration -----------------------------------//
/**
* This contains functions for verifying and displaying the birth date.
*/
include($phpbb_root_path . 'includes/functions_birthdate.' . $phpEx);
//end: Require Birth Date on Registration -----------------------------------//
Find:
Code: Select all
//mod: Require Birth Date on Registration -----------------------------------//
//- - - - - - - - - - - - - - - - - - - - - - - - - //
//Here we grab submitted birth date information, or initialize it if none //
//exists. Then we create the birth date form fields for display in the //
//templates (much of that code is copied from ucp_profile.php). //
//- - - - - - - - - - - - - - - - - - - - - - - - - //
$bday['month'] = request_var('bday_month', 0);
$bday['day'] = request_var('bday_day', 0);
$bday['year'] = request_var('bday_year', 0);
$bday['date'] = sprintf('%2d-%2d-%4d', $bday['day'], $bday['month'], $bday['year']);
$s_birthday_day_options = '<option value="0"' . ((!$bday['day']) ? ' selected="selected"' : '') . '>' . $user->lang['DAY'] . '</option>';
for ($i = 1; $i < 32; $i++)
{
$selected = ($i == $bday['day']) ? ' selected="selected"' : '';
$s_birthday_day_options .= "<option value=\"$i\"$selected>$i</option>";
}
$s_birthday_month_options = '<option value="0"' . ((!$bday['month']) ? ' selected="selected"' : '') . '>' . $user->lang['MONTH'] . '</option>';
for ($i = 1, $lang_dates = $user->lang['datetime']; $i < 13; $i++)
{
$display_month = strtr(@gmdate('M', strtotime("2000-{$i}-01")), $lang_dates);
$selected = ($i == $bday['month']) ? ' selected="selected"' : '';
$s_birthday_month_options .= "<option value=\"$i\"$selected>{$display_month}</option>";
}
$s_birthday_year_options = '';
$now = getdate();
$s_birthday_year_options = '<option value="0"' . ((!$bday['year']) ? ' selected="selected"' : '') . '>' . $user->lang['YEAR'] . '</option>';
for ($i = $now['year'] - 100; $i < $now['year']; $i++)
{
$selected = ($i == $bday['year']) ? ' selected="selected"' : '';
$s_birthday_year_options .= "<option value=\"$i\"$selected>$i</option>";
}
unset($now);
$template->assign_vars(array(
'S_BIRTHDAY_DAY_OPTIONS' => $s_birthday_day_options,
'S_BIRTHDAY_MONTH_OPTIONS' => $s_birthday_month_options,
'S_BIRTHDAY_YEAR_OPTIONS' => $s_birthday_year_options,)
);
//end: Require Birth Date on Registration -----------------------------------//
Replace with:
Code: Select all
//mod: Require Birth Date on Registration -----------------------------------//
//- - - - - - - - - - - - - - - - - - - - - - - - - //
//We grab submitted birth date information, or initialize it if none exists. //
//Then we create the birth date form fields for display in the templates. //
//- - - - - - - - - - - - - - - - - - - - - - - - - //
$bday['month'] = request_var('bday_month', 0);
$bday['day'] = request_var('bday_day', 0);
$bday['year'] = request_var('bday_year', 0);
$bday['date'] = sprintf('%2d-%2d-%4d', $bday['day'], $bday['month'], $bday['year']);
$bday_options = get_birth_date_options($bday['date']);
$template->assign_vars(array(
'S_BIRTHDAY_DAY_OPTIONS' => $bday_options[0],
'S_BIRTHDAY_MONTH_OPTIONS' => $bday_options[1],
'S_BIRTHDAY_YEAR_OPTIONS' => $bday_options[2],
));
//end: Require Birth Date on Registration -----------------------------------//