<?

// TODAY birthdays

$ergebnis=safe_query("SELECT nickname, userID, DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW()) - TO_DAYS(birthday)), '%y') 'age' FROM ".PREFIX."user WHERE EXTRACT(day FROM birthday) = EXTRACT(day FROM NOW()) AND EXTRACT(month FROM birthday) = EXTRACT(month FROM NOW())"); $n=0;

while($db=mysql_fetch_array($ergebnis)) {

$n++;

$years=$db['age'];

if($n>1) $birthdays.=', <a href="index.php?site=profile&id='.$db[userID].'"><b>'.$db[nickname].'</b></a> ('.$years.')';

else $birthdays.='<a href="index.php?site=profile&id='.$db[userID].'"><b>'.$db[nickname].'</b></a> ('.$years.')';

}

if(!$n) $birthdays="hat keiner Geburtstag";





// WEEK birthdays


$ergebnis=safe_query("SELECT nickname, userID, birthday, DATE_FORMAT(FROM_DAYS(TO_DAYS(NOW()) - TO_DAYS(birthday)), '%y')+1 'age' FROM ".PREFIX."user WHERE ((DAYOFYEAR(birthday) > DAYOFYEAR(NOW()) AND DAYOFYEAR(birthday)-DAYOFYEAR(NOW()) <= 7) OR (DAYOFYEAR(birthday) < DAYOFYEAR(NOW()) AND 366-DAYOFYEAR(NOW())+DAYOFYEAR(birthday) <= 7)) AND (EXTRACT(day FROM birthday) != EXTRACT(day FROM NOW()) OR EXTRACT(month FROM birthday) != EXTRACT(month FROM NOW())) ORDER BY `birthday` ASC");

$n=0;

while($db=mysql_fetch_array($ergebnis)) {

list($year, $month, $day) = explode('-', $db['birthday']);

$n++;

$years=$db['age'];

if($n>1) $birthweek.= ''.$day.'.'.$month.' <a href="index.php?site=profile&id='.$db[userID].'"><b>'.$db[nickname].'</b></a> ('.$years.')<br>';

else $birthweek.= ''.$day.'.'.$month.' <a href"index.php?site=profile&id='.$db[userID].'"><b>'.$db[nickname].'</b></a> ('.$years.')<br>';

}

if(!$n) $birthweek="es hat keiner in den nächsten 7 Tagen Geburtstag";



eval ("$birthday = "".gettemplate("birthday")."";");

echo $birthday;

?>
