<?
require_once('include/global.php');
require_once('include/admin_lib.php');

// check
//	if (!$_POST['chk'] || !$_GET['m_no'])
//		msg('올바른 URL로 접근하여 주십시오');

	if ($_POST['chk']) {
		//
	} else if ($_GET['m_no'] && $_GET['email']) {
		$_POST['chk'] = array();
		$_POST['chk'][] = $_GET['email'];
	} else {
		msg('올바른 URL로 접근하여 주십시오');
	}

	$q_where = '';
	if ($_GET['isadmin'])
	{
		auth_limit('admin');
		$_GET['d_no'] = $G['DINFO']['d_no'];
		$q_where = " AND d_no='" . $_GET['d_no'] . "'";
	} else 
	{
		auth_limit('serveradmin');
	}	// if()


// get
	$q = "SELECT m_id, d_no FROM " . $TB['MEMBER'] . " WHERE m_no='" . $_GET['m_no'] . "'".$q_where;
	$mbr = db_get_row($q);
	if (!$mbr)
		msg("존재하지 않는 메일링 주소입니다.");

	if (!$_GET['isadmin'])
	{
		$sql = "SELECT d_name FROM ".$TB['DOMAIN']." WHERE d_no='". $mbr['d_no'] . "' AND d_is_use='Y' ";
		$G_SYS['MAIL_DOMAIN'] = db_get_one($sql);
	}	// if()

	
// data
	for ($i=0; $i<sizeof($_POST['chk']); $i++)
	{
		$sql = "
			DELETE
			FROM
				" . $TB['MAILING_LIST'] . "
			WHERE
				m_no='" . $_GET['m_no'] . "' 
				AND ml_email='" . $_POST['chk'][$i]  . "'
			";
		db_query($sql);

		// 메일엔진에 메일링 유저 삭제
		mluser_del($mbr['m_id'], $_POST['chk'][$i]);
	}	// for()


// end
	#msg("삭제되었습니다.", 0);
	movepage('admin_mailing_addr.php?' . get_qs('chk[]'));


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