##############################################################
## MOD Title: B-day Caching Add-on
## MOD Author: easygo <
webmaster@net4seven.de >
## MOD Description: Just another Add-on for the Birthday MOD by Niels
## which is made to improve forum speed on Index / and ezPortal too
##
## MOD Version: 1.07
##
## Installation Level: easy
## Installation Time: 2 minutes
## Files To Edit: 2
## index.php
## includes/functions.php
##
##############################################################
## For security purposes, please check: http://www.net4seven.de/
## for the latest version of this MOD. Downloading this MOD from other
## sites could cause malicious code to enter into your forums.
##############################################################
## Before adding this MOD to your forums, you should back up all files related to this MOD
##############################################################
#
# At first you have to create folders named /cache (if not already exist) and /cache/bday
# Make sure that your server get write access to both (ex: CHMOD 777)
#
#-----[ OPEN ]------------------------------------------------
#
index.php
#
#-----[ FIND ]------------------------------------------------
#
// Birthday Mod, Show users with birthday
#
#-----[ BEFORE, ADD ]-----------------------------------------
#
/*
#
#-----[ FIND ]------------------------------------------------
#
if ($birthday_today_list) $birthday_today_list[ strlen( $birthday_today_list)-1] = ' ';
if ($birthday_week_list) $birthday_week_list[ strlen( $birthday_week_list)-1] = ' ';
}
$db->sql_freeresult($result);
}
#
#-----[ AFTER, ADD ]-----------------------------------------
#
*/
// -- add mod : B-day Caching to show users with birthday on Index / Portal -------------------
$cache_bday_file = $phpbb_root_path . "cache/bday/bday_" . $board_config['board_timezone'] . ".php";
$time_now = time(); // if already present you should remove this line
if ( @file_exists($cache_bday_file) )
{
$last_update_time = @filemtime($cache_bday_file);
$newest_regdate = $newest_userdata['user_regdate'];
if (!isset($newest_userdata['user_regdate']) || $newest_regdate == 0)
{
$sql = "SELECT user_regdate FROM " . USERS_TABLE . "
WHERE user_id <> " . ANONYMOUS . " AND user_active = 1
ORDER BY user_id DESC LIMIT 0,1";
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Could not obtain regdate information', '', __LINE__, __FILE__, $sql);
}
while ($row = $db->sql_fetchrow($result))
{
$newest_regdate = $row['user_regdate'];
}
$db->sql_freeresult($result);
}
$valid = ( ((date('Yz',$time_now) - date('Yz',$last_update_time)) == 0) && (($time_now - $newest_regdate) > ($time_now - $last_update_time)) ) ? true : false;
} else {
$valid = false;
}
if ($valid )
{
include ($cache_bday_file);
$birthday_today_list = stripslashes($birthday_today_list);
$birthday_week_list = stripslashes($birthday_week_list);
} else {
$sql = ($board_config['birthday_check_day']) ? "SELECT user_id, username, user_birthday, user_level FROM " . USERS_TABLE. " WHERE user_birthday <> 999999 AND user_active=1 ORDER BY username" : "";
if($result = $db->sql_query($sql))
{
if (!empty($result))
{
$this_year = create_date('Y', $time_now, $board_config['board_timezone']);
$date_today = create_date('Ymd', $time_now, $board_config['board_timezone']);
$date_forward = create_date('Ymd', $time_now+($board_config['birthday_check_day']*86400), $board_config['board_timezone']);
while ($birthdayrow = $db->sql_fetchrow($result))
{
$user_birthday2 = $this_year.($user_birthday = realdate("md",$birthdayrow['user_birthday'] ));
if ( $user_birthday2 < $date_today )
{
$user_birthday2 += 10000;
}
if ( $user_birthday2 > $date_today && $user_birthday2 <= $date_forward )
{
// user are having birthday within the next days
$user_age = ( $this_year.$user_birthday < $date_today ) ? $this_year - realdate ('Y',$birthdayrow['user_birthday'])+1 : $this_year- realdate ('Y',$birthdayrow['user_birthday']);
$style_color = ( $birthdayrow['user_level'] == ADMIN ) ? 'style="color:#' . $theme['fontcolor3'] . '"' : (( $birthdayrow['user_level'] == MOD ) ? 'style="color:#' . $theme['fontcolor2'] . '"' : '');
$birthday_week_list .= ' <a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $birthdayrow['user_id']) . '"' . $style_color .'>' . $birthdayrow['username'] . ' ('.$user_age.')</a>,';
}
else if ( $user_birthday2 == $date_today )
{
//user have birthday today
$user_age = $this_year - realdate ( 'Y',$birthdayrow['user_birthday'] );
$style_color = ( $birthdayrow['user_level'] == ADMIN ) ? 'style="color:#' . $theme['fontcolor3'] . '"' : (( $birthdayrow['user_level'] == MOD ) ? 'style="color:#' . $theme['fontcolor2'] . '"' : '');
$birthday_today_list .= ' <a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $birthdayrow['user_id']) . '"' . $style_color .'>' . $birthdayrow['username'] . ' ('.$user_age.')</a>,';
}
}
if ($birthday_today_list)
{
$birthday_today_list[strlen($birthday_today_list)-1] = ' ';
}
if ($birthday_week_list)
{
$birthday_week_list[strlen($birthday_week_list)-1] = ' ';
}
}
$db->sql_freeresult($result);
if ($fp = fopen($cache_bday_file, "w"))
{
// stores the data set in a cache file
$bday = "<?php\n";
$bday .='$birthday_today_list = \'' . addslashes($birthday_today_list) . "';\n";
$bday .='$birthday_week_list = \'' . addslashes($birthday_week_list) . "';\n?>";
fwrite($fp, $bday);
fclose($fp);
@chmod($cache_bday_file, 0777);
}
}
}
// -- fin : B-day Caching ---------------------------------------------------------------------
#
#-----[ OPEN ]------------------------------------------------
# (notice: next part is not really needed but useful)
#
includes/functions.php
#
#-----[ FIND ]------------------------------------------------
#
case 'newestuser':
$sql = "SELECT user_id, username
#
#-----[ IN-LINE FIND ]----------------------------------------
#
username
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------
#
, user_regdate
#
#-----[ SAVE/CLOSE ALL FILES ]--------------------------------
#
# EoM