<? if ( !defined("_INCLUDED_GLOBAL") ) die("Access Denied");		// [Security]Allow_url_fopen = On ?>
<?

function latest_diary($mode, $week_diary_limit, $main_diary_day)
{
	global $G, $G_SYS, $AUTH, $TB, $DEBUG;
	require_once('include/diary_lib.php');

	if ($G_SYS[DB] == 'oracle')
	{
		$db_substr = 'SUBSTR';
	} else
	{
		$db_substr = 'SUBSTRING';
	}	// if()

	// 일정관리 - 공휴일 미출력.  오늘날짜로부터 일주일간 일정만 출력.
		$week_diary_limit;		// 가져올 이번주 일정 수.
		$DEBUG['diary_week']['start'] = getmicrotime();
		// 달력계산
			// [2008-07-01]보여줄 최근 일정의 기간 지정
			if (!$G_SYS['MAIN_DIARY_DAY'])
				$G_SYS['MAIN_DIARY_DAY'] = $main_diary_day;

			$_today = time();

			if ((!$stat_year)&&(!$stat_month))
			{
				$stat_year = date('Y', $_today);
				$stat_month = date('m', $_today);
			} else
			{
				$stat_month = sprintf('%02d', $stat_month);
			}	// if()

			$now_date = date('Y-m-d', $_today);		// 오늘 날짜
			$now_day = date('d', $_today);		// 오늘 일자

			$today = mktime(0, 0, 0, $stat_month, 1, $stat_year);
			$month_last_day = date('t', $today);		// 이번달 마지막 일자
			$today_week = date('w', $today);
			#echo "<HR>today_week - " . $today_week;
			$_month_last_day_v = $month_last_day + $today_week;
			$month_last_day_v = $_month_last_day_v + (7 - ($_month_last_day_v % 7));

			#$startdate = $stat_year . "-" . $stat_month . "-01";
			$startdate = $now_date;
			#echo "<HR>startdate - " . $startdate;
			$enddate = date('Y-m-d', mktime(0, 0, 0, $stat_month, $now_day+($G_SYS['MAIN_DIARY_DAY'] - 1), $stat_year));
			#echo "<HR>enddate - " . $enddate;

			$startdate_lunar = substr(solartolunar($startdate), 5, 5);
			$enddate_lunar = substr(solartolunar($enddate), 5, 5);

			$startdate_md = substr($startdate, 5, 5);
			$enddate_md = substr($enddate, 5, 5);

			// 이번달에서 음력표시부분.
			$thismonth_lunar = db_get_rows("SELECT solar_date, lunar_date FROM " . $TB['DIARY_LUNAR'] . " WHERE solar_date >= '" . $startdate . "' AND solar_date <= '" . $enddate . "' AND $db_substr(lunar_date,9,2) IN ('01','15')");

		// data
			// search
				$q_where = '';
			// db - select
				$DEBUG['db_select']['start'] = getmicrotime();

				// [2008-07-01]메인화면의 이번주 일정의 종류 선택
				/*
				switch ($G_SYS['MAIN_DIARY_TYPE'])
				{
					case 2:		// 개인일정 + 공용일정
						$q_diary_type = " di.m_no='" . $AUTH['auth_m_no'] . "' OR di.d_no='" . $AUTH['auth_d_no'] . "' ";
						break;

					case 1:		// 공용일정
						$q_diary_type = " di.d_no='" . $AUTH['auth_d_no'] . "' ";
						break;

					default:		// 개인일정
						$q_diary_type = " di.m_no='" . $AUTH['auth_m_no'] . "' ";
						break;
				}	// switch()
				*/
				if ($mode == 'P')		// 개인일정
				{
					$q_diary_type = " di.m_no='" . $AUTH['auth_m_no'] . "' ";
					$share = 0;
				} else		// 공용일정
				{
					$q_diary_type = " di.d_no='" . $AUTH['auth_d_no'] . "' ";
					$share = 1;
				}	// if()

				// 매년(음력)되풀이 일정중 12월~1월사이의 일정일때.
				if (substr($startdate_lunar, 0, 2) == '12' && substr($enddate_lunar, 0, 2) == '01')
				{
					$is_lunar_12_1 = true;
					$q_repeat_l = "
									($db_substr(di.di_startdate,6,5) <= '$startdate_lunar' AND $db_substr(di.di_enddate,6,5) >= '$startdate_lunar')
									OR ($db_substr(di.di_startdate,6,5) <= '12-31' AND $db_substr(di.di_enddate,6,5) >= '12-31')
									OR ($db_substr(di.di_startdate,6,5) >= '$startdate_lunar' AND $db_substr(di.di_enddate,6,5) <= '12-31')
									OR ($db_substr(di.di_startdate,6,5) <= '01-01' AND $db_substr(di.di_enddate,6,5) >= '01-01')
									OR ($db_substr(di.di_startdate,6,5) <= '$enddate_lunar' AND $db_substr(di.di_enddate,6,5) >= '$enddate_lunar')
									OR ($db_substr(di.di_startdate,6,5) >= '01-01' AND $db_substr(di.di_enddate,6,5) <= '$enddate_lunar')
						";
				} else
				{
					$is_lunar_12_1 = false;
					$q_repeat_l = "
									($db_substr(di.di_startdate,6,5) <= '$startdate_lunar' AND $db_substr(di.di_enddate,6,5) >= '$startdate_lunar')
									OR ($db_substr(di.di_startdate,6,5) <= '$enddate_lunar' AND $db_substr(di.di_enddate,6,5) >= '$enddate_lunar')
									OR (
										$db_substr(di.di_startdate,6,5) >= '$startdate_lunar' AND $db_substr(di.di_enddate,6,5) <= '$enddate_lunar'
										AND $db_substr(di.di_startdate,6,5) <= $db_substr(di.di_enddate,6,5)
									)
						";
				}	// if()

				// [2012-04-13] 윤달이 포함된 경우 매년(음력) 되풀이 일정이 제대로 보이지 않던 오류 수정.
				$q = "SELECT count(*) FROM " . $TB['DIARY_LUNAR'] . " WHERE solar_date >= '" . $startdate . "' AND solar_date <= '" . $enddate . "' AND yun = '1'";
				$_lunar_cnt = db_get_one($q);
				if ($_lunar_cnt > 0)
				{
					$_lunar = db_get_rows("SELECT $db_substr(lunar_date, 6, 5) md FROM " . $TB['DIARY_LUNAR'] . " WHERE solar_date >= '" . $startdate . "' AND solar_date <= '" . $enddate . "' AND yun = '0'", true);

					if (sizeof($_lunar['md']) > 0)
					{
						$_in = implode("','", $_lunar['md']);
						$q_repeat_l .= " OR $db_substr(di.di_startdate,6,5) IN ('".$_in."') ";
						$q_repeat_l .= " OR $db_substr(di.di_enddate,6,5) IN ('".$_in."') ";
					}	// if()
				}	// if()


				$sql = "
					SELECT
						*
					FROM
						" . $TB['DIARY'] . " di
					WHERE
						(
							(
								(
									(di.di_startdate <= '$startdate' AND di.di_enddate >= '$startdate')
									OR (di.di_startdate <= '$enddate' AND di.di_enddate >= '$enddate')
									OR (di.di_startdate >= '$startdate' AND di.di_enddate <= '$enddate')
								)
								AND di.di_repeat != 'Y'
								AND di.di_repeat != 'L'
							)
							OR
							(
								(
									($db_substr(di.di_startdate,6,5) <= '$startdate_md' AND $db_substr(di.di_enddate,6,5) >= '$startdate_md')
									OR ($db_substr(di.di_startdate,6,5) <= '$enddate_md' AND $db_substr(di.di_enddate,6,5) >= '$enddate_md')
									OR ($db_substr(di.di_startdate,6,5) >= '$startdate_md' AND $db_substr(di.di_enddate,6,5) <= '$enddate_md')
								)
								AND di.di_repeat = 'Y'
							)
							OR
							(
								(
									" . $q_repeat_l . "
								)
								AND di.di_repeat = 'L'
							)
						)
						AND
						(
							" . $q_diary_type . "
						)
						" . $q_where . "
					ORDER BY
						di.di_startdate, di.di_starttime, di.di_enddate, di.di_endtime
					";
				#vd($sql);
				$rows = db_get_rows($sql, true, 0, $week_diary_limit);
				$rows_cnt = getarraycount($rows['di_subject']);
				$DEBUG['db_select']['exec'] += getmicrotime() - $DEBUG['db_select']['start'];

			// set - 일별 예약내역
				$view_day_no = array();
				$view_day = array();
				$view_day_kind = array();
				$view_day_top = array();
				$view_isholiday = array();
				$view_day_time = array();
				$day_cnt = 0;
				for ($i=0; $i<$rows_cnt; $i++)
				{
					#echo "<HR>__" . $rows['di_repeat'][$i] . '/' . $rows['di_startdate'][$i] . '/' . $rows['di_enddate'][$i];
					if ($rows['di_repeat'][$i] == 'L')		// 매년(음력) 되풀이일때 디비에 저장된 음력을 양력으로 변환후 계산함.
					{
						// [2006-12-08]
						$_sd_md = substr($rows['di_startdate'][$i], 5, 5);
						$rows['di_startdate'][$i] = lunartosolar(($stat_year - 1).'-'.$_sd_md);
						if (substr($rows['di_startdate'][$i], 0, 7) != $stat_year.'-'.$stat_month)
							$rows['di_startdate'][$i] = lunartosolar($stat_year.'-'.$_sd_md);

						$_ed_md = substr($rows['di_enddate'][$i], 5, 5);
						$rows['di_enddate'][$i] = lunartosolar(($stat_year - 1).'-'.$_ed_md);
						if (substr($rows['di_enddate'][$i], 0, 7) != $stat_year.'-'.$stat_month)
							$rows['di_enddate'][$i] = lunartosolar($stat_year.'-'.$_ed_md);
						/*
						if ($is_lunar_12_1 && substr($_sd_md, 0, 2) == '12')
						{
							$rows['di_startdate'][$i] = lunartosolar(($stat_year - 1).'-'.$_sd_md);
						} else
						{
							$rows['di_startdate'][$i] = lunartosolar($stat_year.'-'.$_sd_md);
						}	// if()

						if ($is_lunar_12_1 && substr($_ed_md, 0, 2) == '12')
						{
							$rows['di_enddate'][$i] = lunartosolar(($stat_year - 1).'-'.$_ed_md);
						} else
						{
							$rows['di_enddate'][$i] = lunartosolar($stat_year.'-'.$_ed_md);
						}	// if()
						*/
					} else if ($rows['di_repeat'][$i] == 'Y')		// 매년(양력) 되풀이일때 이번연도로 변환후 계산함.
					{
						$rows['di_startdate'][$i] = $stat_year.'-'.substr($rows['di_startdate'][$i], 5, 5);
						$rows['di_enddate'][$i] = $stat_year.'-'.substr($rows['di_enddate'][$i], 5, 5);
					}	// if()
					#echo "<HR>___" . $rows['di_repeat'][$i] . '/' . $rows['di_startdate'][$i] . '/' . $rows['di_enddate'][$i];

					$_sd_sp = split("-", $rows['di_startdate'][$i]);
					$_sd_ts = mktime(0, 0, 0, $_sd_sp[1], $_sd_sp[2], $_sd_sp[0]);

					$_ed_sp = split("-", $rows['di_enddate'][$i]);
					$_ed_ts = mktime(0, 0, 0, $_ed_sp[1], $_ed_sp[2], $_ed_sp[0]);

					// 일정기간
					$diaryday = (($_ed_ts - $_sd_ts) / (3600*24)) + 1;

					for ($j=1; $j<=$diaryday; $j++)
					{
						$_thisdate_ts = mktime(0, 0, 0, $_sd_sp[1], ($_sd_sp[2] + $j - 1), $_sd_sp[0]);
						$thisdate = date("Y-m-d", $_thisdate_ts);
						#$thisday = date("j", $_thisdate_ts);
						$thisday = date("Ymd", $_thisdate_ts);
						#$thisdayofweek = date("w", $_thisdate_ts);

						// 일정기간이 1일 이상일 경우, 선택된 달의 내역만 가져옴.
						if ( $diaryday == 1 ||  (($thisdate >= $startdate)&&($thisdate <= $enddate)) )
						{
							if ($rows['di_kind'][$i] == '0' && ($rows['di_content'][$i] == '공휴일' || $rows['di_content'][$i] == '기념일'))		// 공휴일/기념일일때
							{
								#echo "<HR>공휴일/기념일 : " . $thisday . '/' . $diaryday . '/' . $thisdate . '/' . $rows['di_subject'][$i];
								if ($rows['di_content'][$i] == '공휴일')
								{
									$view_isholiday[$thisday] = true;
								}	// if()
								if ($view_day_top[$thisday] != '')
									$view_day_top[$thisday] .= ' / ';
								$view_day_top[$thisday] .= $rows['di_subject'][$i];
							} else
							{
								$view_day_no[$thisday][] = $rows['di_no'][$i];
								$view_day[$thisday][] = $rows['di_subject'][$i];
								$view_day_kind[$thisday][] = $rows['di_kind'][$i];
								$view_day_time[$thisday][] = ($rows['di_isallday'][$i] == 'Y') ? '하루 종일' : substr($rows['di_starttime'][$i],0,5).'~'.substr($rows['di_endtime'][$i],0,5);
								// 특정 갯수만 가져오기
								$day_cnt++;
								if ($day_cnt >= $week_diary_limit)
								{
									break 2;
								}		// if()
							}	// if()
						}	// if()
					}	// for()
				}	// for()
		$DEBUG['diary_week']['exec'] += getmicrotime() - $DEBUG['diary_week']['start'];


	// view
		?>
		<table width=100% border="0" cellpadding="0" cellspacing="0">
		<?
			$day_cnt = 0;
			$date_prev = '';
			$date_time_prev = '';
			$date_week = array('일', '월', '화', '수', '목', '금', '토');
			for($i=1; $i<=$G_SYS['MAIN_DIARY_DAY']; $i++)
			{
				$day_time = mktime(0, 0, 0, $stat_month, ($now_day + $i - 1), $stat_year);
				$day = date('Ymd', $day_time);
				$date = date('n월 j일', $day_time).' '.$date_week[date('w', $day_time)].'요일';		//  5월 28일 월요일
				//$date = date('m-d', $day_time).'-'.$date_week[date('w', $day_time)];		// 05-28-월
				for($j=0; $j<sizeof($view_day[$day]); $j++)
				{
					$day_cnt++;
					if ($day_cnt > $week_diary_limit)
					{
						break;
					}	// if()
					?>
					<? if ($date != $date_prev || $view_day_time[$day][$j] != $date_time_prev) { ?>
					<tr>
						<td height=3></td>
					</tr>
					<tr>
						<td colspan=2 class=nm_a_link>
							<div style="font-size:8pt; padding-left:0px; color:#313A80">[<b><?= $date ?></b>]<? if ($view_day_time[$day][$j] != '하루 종일') { ?> <?= $view_day_time[$day][$j] ?><? }	// if() ?></div>
						</td>
					</tr>
					<? }	// if() ?>
					<tr>
						<td style="padding:0px 2px 0px 6px"><img src=<?= nskindirroot('webmail') ?>/img/di_kind_<?= $view_day_kind[$day][$j] ?>.gif width=16 height=16 border=0 align=absmiddle alt="<?= $G_SYS['DI_KIND'][$view_day_kind[$day][$j]] ?>"></td>
						<td width=99% class=nm_a_link>
							<div style="HEIGHT:16px; OVERFLOW:hidden;"><a href="JavaScript:diary_modify('<?= $view_day_no[$day][$j] ?>', '<?= $share ?>');"><?= $view_day[$day][$j] ?></a></div>
						</td>
					</tr>
					<tr>
						<td height=3></td>
					</tr>
					<?
					$date_prev = $date;
					$date_time_prev = $view_day_time[$day][$j];
				}	// for()
			}	// for()
		?>
		</table>
		<?

	return sizeof($view_day);

}	// function()


/*

	최근 게시물 함수
		1. 게시판 번호 or 전체 게시판(ALL)
		2. 최근 게시물 갯수
		3. 전체게시판일 경우 제외할 게시판번호. array.

*/

function latest_board($ba_no, $new_board_limit, $exclude_ba_no=array(), $bm_no=0)
{
	global $G, $G_SYS, $AUTH, $TB, $DEBUG;

	$DEBUG['latest_board']['start'] = getmicrotime();

	// 게시판 선택
	$q_where = '';
	if ($ba_no == 'ALL')
	{
		if (is_array($exclude_ba_no) && sizeof($exclude_ba_no) > 0)
		{
			$q_where = " AND ba.ba_no NOT IN (".implode($exclude_ba_no, ',').") ";
		}	// if()

		// [2011-01-10] 사용그룹제한 - 권한 있는 게시판만 보여줌.
		$bl = get_board_list();
		if ($bl)
		{
			$_ba_no_in = '';
			for ($i=0; $i<sizeof($bl); $i++)
			{
				if (is_numeric($bl[$i]['ba_no']))
				{
					if ($_ba_no_in != '')
						$_ba_no_in .= ',';
					$_ba_no_in .= $bl[$i]['ba_no'];
				}	// if()
			}	// for()
			if ($_ba_no_in != '')
				$q_where .= " AND ba.ba_no IN (".$_ba_no_in.") ";
		}	// if()

		if ($bm_no > 0)
			$q_where .= " AND ba.bm_no = '".$bm_no."' ";
	} else if (is_numeric($ba_no))
	{
		$q_where = " AND ba.ba_no='".$ba_no."' ";
	} else
	{
		error("latest_board()함수의 첫번째 입력값인 ba_no 는 'ALL'이나 특정 게시판 번호만 입력할 수 있습니다.   입력된 값 : ".$ba_no , $code='INPUT');
	}	// if()

	// [2011-06-02] 제외할 게시판번호 지정시 튜닝
		$q = "SELECT ba.ba_no FROM ".$TB['BOARD_ADMIN']." ba WHERE ba.d_no='".$G['DINFO']['d_no']."' ".$q_where;
		$_ba_no = db_get_rows($q, true);

	// [2006-07-26] 최근 게시물
		/*
		$q = "
			SELECT
				b.ba_no, b.b_no, b.b_name, b.b_subject, b.b_regdate
			FROM
				".$TB['BOARD_ADMIN']." ba,
				".$TB['BOARD']." b
			WHERE
				ba.d_no='".$G['DINFO']['d_no']."'
				".$q_where."
				AND ba.ba_no=b.ba_no
			ORDER BY
				b.b_no DESC
			";
		*/
		if (is_array($_ba_no['ba_no']) && sizeof($_ba_no['ba_no']))
		{
			// [2011-06-02] MySQL 전용 - 1개 이상의 게시판일 때는 옵티마지어보다 PRIMARY KEY 로 강제 지정이 더 빠름.
			$q_use_index = '';
			if ($G_SYS[DB] == 'oracle')
			{
				//
			} else
			{
				if (sizeof($_ba_no['ba_no']) > 1)
					$q_use_index = ' USE INDEX (PRIMARY) ';
			}	// if()

			$q = "
				SELECT
					ba_no, b_no, b_name, b_subject, b_regdate
				FROM
					".$TB['BOARD']."
				".$q_use_index."
				WHERE
					ba_no IN (".implode(',', $_ba_no['ba_no']).")
				ORDER BY
					b_no DESC
				";
			$new_board = db_get_rows($q, 0, $new_board_limit);

		} else 
		{
			$new_board = array();			
		}	// if()
		$new_board_view = $new_board;
		for ($i=0; $i<sizeof($new_board); $i++)
		{
			$new_board_view[$i]['b_subject_view'] = htmlspecialchars_fix($new_board[$i]['b_subject']);
			//$new_board_view[$i]['b_regdate_view'] = substr($new_board[$i]['b_regdate'], 5, 6);
			$new_board_view[$i]['b_regdate_view'] = get_short_date($new_board[$i]['b_regdate']);
		}	// for()

		$DEBUG['latest_board']['exec'] += getmicrotime() - $DEBUG['latest_board']['start'];

		return $new_board_view;
}	// function()

function latest_board_name($ba_no)
{
	global $TB, $G;
	$q = "SELECT ba.ba_name, bm.bm_name FROM ".$TB['BOARD_ADMIN']." ba, ".$TB['BOARD_MENU']." bm WHERE ba.ba_no='".$ba_no."' AND ba.d_no='" . $G['DINFO']['d_no'] ."' AND ba.bm_no=bm.bm_no";
	$row = db_get_row($q);
	if ($row)
	{
		$name = $row['bm_name'].' <span style="font-weight:normal">>></span> '.$row['ba_name'];
	} else 
	{
		$name = "존재하지 않는 게시판 번호입니다. => ".$ba_no;
	}	// if()
	return $name;
}	// function()


function latest_birthday($limit_days, $limit_count=100)
{
	global $G, $G_SYS, $AUTH, $TB, $DEBUG;

	$DEBUG['latest_birthday']['start'] = getmicrotime();

	$_today = time();
	$startdate = date('Y-m-d', $_today);
	$enddate = date('Y-m-d', $_today+(86400*($limit_days - 1)));


	if ($G_SYS[DB] == 'oracle')
	{
		$db_substr = 'SUBSTR';
	} else
	{
		$db_substr = 'SUBSTRING';
	}	// if()

	$_lunar = db_get_rows("SELECT solar_date, lunar_date FROM " . $TB['DIARY_LUNAR'] . " WHERE solar_date >= '" . $startdate . "' AND solar_date <= '" . $enddate . "'");

	$q_solar_date = "";
	for ($i=0; $i<$limit_days; $i++)
	{
		if ($q_solar_date != '')
			$q_solar_date .= ",";
		$q_solar_date .= "'".date('m-d', $_today+(86400*$i))."'";
	}	// for()

	$q_lunar_date = "";
	for ($i=0; $i<sizeof($_lunar); $i++)
	{
		if ($q_lunar_date != '')
			$q_lunar_date .= ",";
		$q_lunar_date .= "'".substr($_lunar[$i]['lunar_date'], 5, 5)."'";
	}	// for()


	$q = "SELECT m_no, m_id, m_name, mc_no, mg_no, m_birthday, m_birthday_east, m_file1 FROM ".$TB['MEMBER']." WHERE
			d_no='".$G['DINFO']['d_no']."'
			AND mg_no > 0
			AND m_usertype IS NULL
			AND m_birthday IS NOT NULL
			AND m_birthday != '0000-00-00'
			AND (
					(m_birthday_east != 'L' AND $db_substr(m_birthday, 6, 5) IN (".$q_solar_date."))
					OR
					(m_birthday_east = 'L' AND $db_substr(m_birthday, 6, 5) IN (".$q_lunar_date."))
				)
		ORDER BY m_birthday";
	$_birthday = db_get_rows($q, 0, $limit_count);

	for ($i=0; $i<sizeof($_birthday); $i++)
	{
		if ($_birthday[$i]['mc_no'] > 0)
		{
			$q = "SELECT mc_name FROM ".$TB['MEMBER_CLASS']." WHERE d_no='" . $G['DINFO']['d_no'] . "' AND mc_no='" . $_birthday[$i]['mc_no'] . "'";
			$_birthday[$i]['mc_name'] = db_get_one($q);
		} else
		{
			$_birthday[$i]['mc_name'] = "";
		}	// if()

		if ($_birthday[$i]['mg_no'] > 0)
		{
			$q = "SELECT mg_name FROM ".$TB['MEMBER_GROUP']." WHERE d_no='" . $G['DINFO']['d_no'] . "' AND mg_no='" . $_birthday[$i]['mg_no'] . "'";
			$_birthday[$i]['mg_name'] = db_get_one($q);
		} else
		{
			$_birthday[$i]['mg_name'] = "";
		}	// if()

		if ($_birthday[$i]['m_birthday_east'] == 'L')
		{
			for ($j=0; $j<sizeof($_lunar); $j++)
			{
				if (substr($_birthday[$i]['m_birthday'], 5, 5) == substr($_lunar[$j]['lunar_date'], 5, 5))
				{
					$_birthday[$i]['date'] = $_lunar[$j]['solar_date'];
					break;
				}	// if()
			}	// for()
		} else
		{
			for ($j=0; $j<sizeof($_lunar); $j++)
			{
				if (substr($_birthday[$i]['m_birthday'], 5, 5) == substr($_lunar[$j]['solar_date'], 5, 5))
				{
					$_birthday[$i]['date'] = $_lunar[$j]['solar_date'];
					break;
				}	// if()
			}	// for()
		}	// if()
	}	// for()

	// 올해 생일 날짜 순서로 정렬
	for ($i=0; $i<sizeof($_birthday)-1; $i++)
	{
		for ($j=$i+1; $j<sizeof($_birthday); $j++)
		{
			if ($_birthday[$i]['date'] > $_birthday[$j]['date'])
			{
				$_sort = $_birthday[$i];
				$_birthday[$i] = $_birthday[$j];
				$_birthday[$j] = $_sort;
			}	// if()
		}	// for()
	}	// for()

	$DEBUG['latest_birthday']['exec'] += getmicrotime() - $DEBUG['latest_birthday']['start'];

	return $_birthday;
}	// function()

?>