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


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

	if (strtoupper($G_SYS[CHARSET]) != 'UTF-8')
		$G_SYS['NM_SPAM_WORD_INPUT_MIN_LENGTH'] = $G_SYS['NM_SPAM_WORD_INPUT_MIN_LENGTH']*2;

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

		// 스팸단어가 있을 때.
		if (strlen($_ex[$i]) >= $G_SYS['NM_SPAM_WORD_INPUT_MIN_LENGTH'])
		{
			// 중복여부 체크
			$sql = "SELECT COUNT(*)  FROM " . $TB['SADMIN_SPAM_WORD'] . " WHERE ssw_word='" . $_ex[$i] . "'";
			$sr_cnt = db_get_one($sql);
			if ($sr_cnt > 0)
			{
				if ($msg)
					$msg .= ', ';
				$msg .= stripslashes($_ex[$i]);
			} else
			{
					$_ex[$i] = to_db_str($_ex[$i], 255, false);
					$ssw_memo = to_db_str($_POST['ssw_memo'], 255);
					$_POST['ssw_regdate'] = date('Y-m-d H:i:s');

					// 추가
					$sql = "
						INSERT INTO
							" . $TB['SADMIN_SPAM_WORD'] . "
							(ssw_no, ssw_word, ssw_memo, ssw_regdate)
						VALUES
							(" . db_sqc_next($TB['SADMIN_SPAM_WORD']) . ", '" . $_ex[$i] . "', '" . $ssw_memo . "', '" . $_POST['ssw_regdate'] . "')
						";
					db_query($sql);
			}	// if()
		}	// if()
	}	// for()

// end
	if ($msg)
		msg("이미 추가된 스팸단어는 생략되었습니다.\\n\\n=> ".$msg, 0);
	#msg("추가되었습니다.", 0);
	if ($_GET['is_window_close'])
	{
		?>
			<script language="JavaScript">
			<!--
				window.close();
			//-->
			</script>
		<?
	} else
	{
		movepage('sadmin_spam_word.php?' . get_qs());
	}	// if()


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