<?
require_once('include/global.php');
require_once('include/mail_lib.php');
require_once('conf.inc.php');

// check
	// [2011-03-29] 편지읽기에서 읽지않음 버튼 추가
	if ($_GET['mb_id'] != '' && is_numeric($_GET['mf_no']))
		$_POST['mb_id'] = $_GET['mb_id'];
		$_POST['mf_no'] = $_GET['mf_no'];

	if (!$_GET['mode'] || !$_POST['mb_id'] || (!$_POST['mf_no'] && !$_POST['cmf']))
		msg('올바른 URL로 접근하여 주십시오');


// data
	$mf_no = array();
	if (getarraycount($_POST['cmf']) > 0)
	{
		$mf_no = $_POST['cmf'];
	} else
	{
		$mf_no[] = $_POST['mf_no'];
	}	// if()


// db update
	$q_mf_no = set_array2comma(" (", ") ", $mf_no);

	if ($_GET['mode'] == 'READ')
	{
		$mf_is_read_date = date('Y-m-d H:i:s');
		$sql = "
			UPDATE
				".$AUTH[auth_m_mf_table]."
			SET
				mf_is_read='Y',
				mf_is_read_date='".$mf_is_read_date."'
			WHERE
				mf_no IN ".$q_mf_no."
				AND m_no='" . $AUTH['auth_m_no'] . "'
				AND mb_id='". $_POST['mb_id']. "'
				AND mf_is_read='N'
			";
	} else 
	{
		$sql = "
			UPDATE
				".$AUTH[auth_m_mf_table]."
			SET
				mf_is_read='N',
				mf_is_read_date=NULL
			WHERE
				mf_no IN ".$q_mf_no."
				AND m_no='" . $AUTH['auth_m_no'] . "'
				AND mb_id='". $_POST['mb_id']. "'
				AND mf_is_read='Y'
			";
	}	// if()
	db_query($sql);


// end
	movepage('mail_list.php?mb_id=' . $_POST['mb_id'] . '&' . get_qs('mb_id', 'mf_no', 'sel_mail_box', 'sel_mail_box_2', 'cmd', 'cmd_2', 'mode'));

require_once('include/global_end.php');
?>