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

// check

	if ($_POST['chk'])
	{
		//
	} else if ($_GET['ml_email'])
	{
		$_POST['chk'] = array();
		$_POST['chk'][] = $_GET['ml_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()

// data
	for ($i=0; $i<sizeof($_POST['chk']); $i++)
	{
		$_ex = explode('|', $_POST['chk'][$i]);

		$q = "SELECT m_id, d_no FROM " . $TB['MEMBER'] . " WHERE m_no='" . $_ex[0] . "'".$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()

		$sql = "
			DELETE
			FROM
				" . $TB['MAILING_LIST'] . "
			WHERE
				m_no='" . $_ex[0] . "' 
				AND ml_email='" . $_ex[1]  . "'
			";
		db_query($sql);

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


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


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