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

// set
	$CFG['TITLE'] = '<b>메일서버관리</b> >> <b>바이러스 차단 테스트</b>';


$clamav = get_virus_clamav_bin();

$fileData1 = 'WDVPIVAlQEFQWzRcUFpYNTQoUF4pN0NDKTd9JEVJQ0FSL';
$fileData2 = 'VNUQU5EQVJELUFOVElWSVJVUy1URVNULUZJTEUhJEgrSCo=';

$file = $UPLOAD_ROOT.'/config/antivirus_test';


if (file_exists($clamav)) {
	// 파일 생성
	if ( !function_exists('file_put_contents')) {
		$fh = fopen($file, "wb");
		if ($fh !== false) {
			fwrite($fh, base64_decode($fileData1.$fileData2));
			fclose($fh);
		}
	} else {
		file_put_contents($file, base64_decode($fileData1.$fileData2));
	}

	$hdrs = array();
	$recipients = $G_SYS[ADMIN_EMAIL];		// An array or comma seperated string of recipients.
	// [2009-09-16] 일부 메일헤더가 잘못 표시되는 오류 수정
	$hdrs['From'] = '"'.mime_encode($G_SYS[ADMIN_EMAIL_NAME], $G_SYS[CHARSET], 'b').'" <'.$G_SYS[ADMIN_EMAIL].'>';
	$hdrs['To'] = '"'.mime_encode($G_SYS[ADMIN_EMAIL_NAME], $G_SYS[CHARSET], 'b').'" <'.$G_SYS[ADMIN_EMAIL].'>';
	$hdrs["Date"] = date('r');
	$hdrs['Subject'] = mime_encode("[" . $G_SYS[SITE_NAME] . "] 바이러스 차단 테스트용 메일입니다.", $G_SYS[CHARSET], 'b');
	$body = null;
	$body_type = "HTML";
	$attachment_file = array($file);
	$attachment_file_name = array('antivirus_test');
	$host = $G_SYS[SMTP_ADDR];

	require_once('include/mail_send_lib.php');
	$result = mail_smtp($recipients, $hdrs, $body, $body_type, $attachment_file, $attachment_file, $host);

	// 첨부파일 삭제
	if (file_exists($file)) {
		unlink($file);
	}
}

// skin view
	nskinset('sadmin', 'antivirus_test.html');
	include($NSKIN['view_layout']);


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