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


// set
	$CFG = array();
	$CFG['TITLE'] = '<b>편지쓰기</b> >> <b>미리보기</b>';


// data
	// process data
		$view = array();

		$view['mf_subject'] = htmlspecialchars_fix(stripslashes($_POST['mf_subject']));
		// [2005-07-12] 보낸날짜가 없을때는 도착날짜를 사용함.
		$view['mf_send_date'] = date('Y-m-d H:i:s');

		// [2013-01-28] 보낸사람 선택기능 (앨리어스 도메인/주소 연동)
		if ($_POST['mf_from_select'] != '' && $_POST['mf_from_select'] != $AUTH['auth_m_email'])
		{
			$_ex = explode('@', $_POST['mf_from_select']);
			$q = "SELECT m_cfg_from_name name FROM " . $TB['MEMBER'] . " WHERE d_no='" . $G['DINFO']['d_no'] . "' AND m_usertype='A' AND m_name='" . $AUTH['auth_m_id'] . "' AND m_id='" . $_ex[0] . "'";
			$mf_from_name = db_get_one($q);
			$view['mf_from'] = htmlspecialchars_fix('"' . $mf_from_name . '" <' . $_POST['mf_from_select'] . '>');
		} else 
		{
			$view['mf_from'] = htmlspecialchars_fix('"' . $AUTH['auth_m_name'] . '" <' . $AUTH['auth_m_email'] . '>');
		}	// if()

		$view['mf_to'] = htmlspecialchars_fix(stripslashes($_POST['mf_to']));
		$view['mf_cc'] = htmlspecialchars_fix(stripslashes($_POST['mf_cc']));
		//$view['mf_bcc'] = htmlspecialchars_fix(stripslashes($_POST['mf_bcc']));

		// 서명 붙여넣기
		$sg_content = '';
		if ($_POST['sg_no'])
		{
			$sg_content = db_get_one("SELECT sg_content FROM " . $TB['SIGN'] . " WHERE sg_no='" . $_POST['sg_no'] . "' AND m_no='" . $AUTH['auth_m_no'] . "'");
		}	// if()
		if ($_POST['mf_content_type'] == 'H')
		{
			$view['mf_body'] = '<style><!-- P, UL, LI { margin-top: 0px; margin-bottom: 0px; } --></style>'."\n".stripslashes($_POST['mf_body_html']);
			if ($sg_content)
				$view['mf_body'] .= '<br>' . get_sg_content($sg_content, $_POST['mf_content_type']);

			// [2009-02-09] 편지지
			if ($_POST['mf_body_letter'] != '' && is_numeric($_POST['mf_body_letter']))
			{
				$q = "SELECT * FROM ".$TB['LETTER']." WHERE l_no='".$_POST['mf_body_letter']."' AND l_isuse='Y'";
				$letter = db_get_row($q);
				if ($letter)
				{
					$letter_layout = 'letter/layout.inc.html';
					$letter['body'] = $view['mf_body'];
					ob_start();
					include($letter_layout);
					$view['mf_body'] = ob_get_contents();
					ob_end_clean();
				}	// if()
			}	// if()
		} else
		{
			$view['mf_body'] = stripslashes($_POST['mf_body_text']);
			if ($sg_content)
				$view['mf_body'] .= "\n" . get_sg_content($sg_content, $_POST['mf_content_type']);
			$view['mf_body'] = nl2br(htmlspecialchars_fix($view['mf_body']));
		}	// if()


// skin view
	nskinset('webmail', 'mail_write_preview.html', 'window_open');
	include($NSKIN['view_layout']);


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