diff --git a/upload/ajax.php b/upload/ajax.php index b588a89dc..463292f5d 100644 --- a/upload/ajax.php +++ b/upload/ajax.php @@ -74,6 +74,7 @@ class ajax_common 'view_torrent' => array('guest'), 'user_register' => array('guest'), 'posts' => array('guest'), + 'birthday_list' => array('guest'), ); var $action = null; @@ -364,6 +365,52 @@ class ajax_common else $this->ajax_die($lang['NOT_AUTHORISED']); } + function birthday_list() + { + global $bb_cfg, $lang, $datastore; + + if (!$stats = $datastore->get('stats')) + { + $datastore->update('stats'); + $stats = $datastore->get('stats'); + } + + $mode = (string) $this->request['mode']; + switch($mode) + { + case 'week': + if ($stats['birthday_week_list']) + { + foreach($stats['birthday_week_list'] as $week) + { + $html[] = profile_url($week) .' ('. birthday_age($week['age']) .')'; + } + $html = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday']['check_day'], join(', ', $html)); + } + else $html = sprintf($lang['NOBIRTHDAY_WEEK'], $bb_cfg['birthday']['check_day']); + break; + + case 'today': + if ($stats['birthday_today_list']) + { + foreach($stats['birthday_today_list'] as $today) + { + $html[] = profile_url($today) .' ('. birthday_age($today['age'], 1) .')'; + } + $html = $lang['BIRTHDAY_TODAY'] . join(', ', $html); + } + else $html = $lang['NOBIRTHDAY_TODAY']; + break; + + default: + $html = ''; + break; + } + + $this->response['html'] = $html; + $this->response['mode'] = $mode; + } + function view_post () { require(AJAX_DIR .'view_post.php'); @@ -399,3 +446,4 @@ class ajax_common require(AJAX_DIR .'posts.php'); } } + diff --git a/upload/includes/datastore/build_stats.php b/upload/includes/datastore/build_stats.php index 0bc7c90d3..7ecdd0b78 100644 --- a/upload/includes/datastore/build_stats.php +++ b/upload/includes/datastore/build_stats.php @@ -48,7 +48,7 @@ if ($bb_cfg['gender']) // birthday stat if ($bb_cfg['birthday']['check_day'] && $bb_cfg['birthday']['enabled']) { - $sql = DB()->fetch_rowset("SELECT user_id, username, user_birthday, user_birthday, user_rank FROM ". BB_USERS ." WHERE user_id NOT IN(". EXCLUDED_USERS_CSV .") ORDER BY user_level DESC, username"); + $sql = DB()->fetch_rowset("SELECT user_id, username, user_birthday, user_birthday, user_rank FROM ". BB_USERS ." WHERE user_id NOT IN(". EXCLUDED_USERS_CSV .") AND user_birthday != 0 ORDER BY user_level DESC, username"); $this_year = bb_date(TIMENOW, 'Y', 'false'); $date_today = bb_date(TIMENOW, 'Ymd', 'false'); $date_forward = bb_date(TIMENOW + ($bb_cfg['birthday']['check_day']*86400), 'Ymd', 'false'); diff --git a/upload/includes/functions.php b/upload/includes/functions.php index 09f6e4a08..add2424f8 100644 --- a/upload/includes/functions.php +++ b/upload/includes/functions.php @@ -1565,10 +1565,7 @@ function bb_date ($gmepoch, $format = false, $tz = null) if (is_null($tz)) { $tz = $bb_cfg['board_timezone']; - $replace = true; } - else $replace = false; - if (!$format) { $format = $bb_cfg['default_dateformat']; @@ -1582,7 +1579,7 @@ function bb_date ($gmepoch, $format = false, $tz = null) $thetime = ($bb_cfg['translate_dates']) ? strtr(strtoupper($date), $lang['DATETIME']) : $date; - if($replace) + if(is_numeric($tz)) { $time_format = " H:i"; diff --git a/upload/index.php b/upload/index.php index 02ee60335..6b383de67 100644 --- a/upload/index.php +++ b/upload/index.php @@ -340,25 +340,41 @@ if ($bb_cfg['show_latest_news']) if ($bb_cfg['birthday']['check_day'] && $bb_cfg['birthday']['enabled']) { $week_list = $today_list = array(); + $week_all = $today_all = false; + if ($stats['birthday_week_list']) { - foreach($stats['birthday_week_list'] as $week) + shuffle($stats['birthday_week_list']); + foreach($stats['birthday_week_list'] as $i => $week) { + if($i >= 5) + { + $week_all = true; + continue; + } + $week_list[] = profile_url($week) .' ('. birthday_age($week['age']) .')'; } - $week_list = join(', ', $week_list); - $week_list = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday']['check_day'], $week_list); + $week_all = ($week_all) ? ' ...' : ''; + $week_list = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday']['check_day'], join(', ', $week_list)) . $week_all; } else $week_list = sprintf($lang['NOBIRTHDAY_WEEK'], $bb_cfg['birthday']['check_day']); if ($stats['birthday_today_list']) { - foreach($stats['birthday_today_list'] as $today) + shuffle($stats['birthday_today_list']); + foreach($stats['birthday_today_list'] as $i => $today) { + if($i >= 5) + { + $today_all = true; + continue; + } + $today_list[] = profile_url($today) .' ('. birthday_age($today['age'], 1) .')'; } - $today_list = join(', ', $today_list); - $today_list = $lang['BIRTHDAY_TODAY'] . $today_list; + $today_all = ($today_all) ? ' ...' : ''; + $today_list = $lang['BIRTHDAY_TODAY'] . join(', ', $today_list) . $today_all; } else $today_list = $lang['NOBIRTHDAY_TODAY']; diff --git a/upload/templates/default/index.tpl b/upload/templates/default/index.tpl index 00338745e..05b5bc493 100644 --- a/upload/templates/default/index.tpl +++ b/upload/templates/default/index.tpl @@ -178,9 +178,14 @@
{SPEED_STAT}
+ -{WHOSBIRTHDAY_TODAY}
-{WHOSBIRTHDAY_WEEK}
+{WHOSBIRTHDAY_TODAY}
+{WHOSBIRTHDAY_WEEK}