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

set_time_limit(1200);


// check


// select
	$DEBUG['db_select']['start'] = getmicrotime();
	$sql = "
		SELECT
			ssa_email, ssa_memo, ssa_regdate
		FROM
			" . $TB['SADMIN_SPAM_ADDR'] . "
		ORDER BY
			ssa_email
		";
	$rows = db_get_rows($sql, true);
	$rows_cnt = getarraycount($rows['ssa_email']);
	$DEBUG['db_select']['exec'] += getmicrotime() - $DEBUG['db_select']['start'];
	if (!$rows)
		msg('스팸주소 데이타가 없습니다.');


// proc
	if ($_GET['excel_down'])
	{
		$excel_down_name = 'NmailSAdminSpamAddr_' . date('Ymd_His') . '.xls';
		header("Content-type: application/vnd.ms-excel; charset=utf-8");
		header("Content-Disposition: attachment; filename=$excel_down_name");
		header("Expires: 0");
		header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
		header("Pragma: public");

		include('sadmin/sadmin_spam_addr_excel.html');

		exit;
	}

	$crlf = "\r\n";
	$data = implode($crlf, $rows['ssa_email']).$crlf;

	file_down_headeronly($data, 'NmailSAdminSpamAddr_'.date('Ymd_His').'.txt');

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