Просмотр файла module/birthday.php

Размер файла: 3.27Kb
<?php
/*************************************************
 *    apwa.ru       birthday.php
 *                 -------------
 *  [email protected] 2011
 ************************************************/

if ( !defined('IN_PHPBB') )
{
	die("Hacking attempt");
}
if ( isset($HTTP_POST_VARS[POST_USERS_URL]) )
{
	$u = htmlspecialchars($HTTP_POST_VARS[POST_USERS_URL]);
	redirect(append_sid("profile." . $phpEx . "?mode=viewprofile&" . POST_USERS_URL . "=" . $u . "", TRUE));
}
$sql = "SELECT user_id, username, user_birthday, user_nic_color 
        FROM " . USERS_TABLE. " 
        WHERE user_birthday!=999999  
        ORDER BY DATE_FORMAT(from_unixtime(user_birthday*86400+1),'%m%d') asc";
if($result = $db->sql_query($sql)) 
{ 
	if (!empty($result)) 
	{ 
		$time_now = time();
		$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']*2629743), $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_age = ( $this_year.$user_birthday < $date_today ) ? $this_year - realdate ('Y',$birthdayrow['user_birthday'])+1 : $this_year- realdate ('Y',$birthdayrow['user_birthday']); 
				  $birthday_week_list .= '<option value="' . $birthdayrow['user_id'] . '" style="color: ' . $birthdayrow['user_nic_color'] . '">' . $birthdayrow['username'] . ' (' . $user_age . ') - ' . realdate("d.M.Y",$birthdayrow['user_birthday']) . '</option> '; 
			 } 
			 else if ( $user_birthday2 == $date_today ) 
			 { 
				  $user_age = $this_year - realdate ( 'Y',$birthdayrow['user_birthday'] ); 
				  $birthday_today_list .= '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $birthdayrow['user_id']) . '" style="color: ' . $birthdayrow['user_nic_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);
}

$template->set_filenames(array(
	'birthday' => 'module/birthday_body.tpl')
);

if($birthday_week_list)
{
        $birthday_week_list = '<form action="index.php" method="post"><select name="u">' . $birthday_week_list . '</select>';
        $birthday_week_list .= '<input type="submit" class="subbutton" name="submit" value="OK"/></form>';
}
        
$template->assign_block_vars('birthday', array(	
        'WEEK' => sprintf( (($birthday_week_list) ? $lang['Birthday_week'] : $lang['Nobirthday_week']), 30) . $birthday_week_list,
	'TODAY' => ($birthday_today_list) ? $lang['Birthday_today'] . " " . $birthday_today_list . "<br/>" : $lang['Nobirthday_today'])
);

$template->assign_var_from_handle('MODULE_BIRTHDAY', 'birthday');
           
?>