aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/index.php')
-rw-r--r--phpBB/index.php19
1 files changed, 15 insertions, 4 deletions
diff --git a/phpBB/index.php b/phpBB/index.php
index 419b66cfdb..182efbc7e0 100644
--- a/phpBB/index.php
+++ b/phpBB/index.php
@@ -82,15 +82,23 @@ $legend = implode(', ', $legend);
// Generate birthday list if required ...
$birthday_list = array();
-if ($config['load_birthdays'] && $config['allow_birthdays'])
+if ($config['load_birthdays'] && $config['allow_birthdays'] && $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel'))
{
$now = phpbb_gmgetdate(time() + $user->timezone + $user->dst);
+
+ // Display birthdays of 29th february on 28th february in non-leap-years
+ $leap_year_birthdays = '';
+ if ($now['mday'] == 28 && $now['mon'] == 2 && !$user->format_date(time(), 'L'))
+ {
+ $leap_year_birthdays = " OR user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', 29, 2)) . "%'";
+ }
+
$sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday
FROM ' . USERS_TABLE . ' u
LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)
WHERE (b.ban_id IS NULL
OR b.ban_exclude = 1)
- AND u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%'
+ AND (u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' $leap_year_birthdays)
AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
$result = $db->sql_query($sql);
@@ -98,7 +106,7 @@ if ($config['load_birthdays'] && $config['allow_birthdays'])
{
$birthday_username = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
$birthday_year = (int) substr($row['user_birthday'], -4);
- $birthday_age = ($birthday_year) ? $now['year'] - $birthday_year : '';
+ $birthday_age = ($birthday_year) ? max(0, $now['year'] - $birthday_year) : '';
$template->assign_block_vars('birthdays', array(
'USERNAME' => $birthday_username,
@@ -106,7 +114,10 @@ if ($config['load_birthdays'] && $config['allow_birthdays'])
));
// For 3.0 compatibility
- $birthday_list[] = $birthday_username . (($birthday_year) ? ' (' . $birthday_age . ')' : '');
+ if ($age = (int) substr($row['user_birthday'], -4))
+ {
+ $birthday_list[] = $birthday_username . (($birthday_year) ? ' (' . $birthday_age . ')' : '');
+ }
}
$db->sql_freeresult($result);
}