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


// set
	$CFG['TITLE'] = '<b>메일서버관리</b> >> <b>스팸 주소 관리</b>';

// data
	// search
		$q_where = '';
		if ($_GET['s_word'])
		{
			set_q_search($_GET['s_word']);
			$q_where = " AND (ssa_email LIKE '%" . $_GET['s_word'] . "%' OR ssa_memo LIKE '%" . $_GET['s_word'] . "%') ";
			$v_s_word = htmlspecialchars_fix(stripslashes($_GET['s_word']));
		}	// if()

	// sort
		$CFG['SADMIN_SPAM_ADDR_LIST_FIELD'] = array(
				'ssa_email' => '이메일',
				'ssa_memo' => '메모',
				'ssa_regdate' => '등록일자'
				);
		#if (!$_GET['s_key2'])
		#	$_GET['s_key2'] = 'ASC';
		$order_set = get_order(array_keys($CFG['SADMIN_SPAM_ADDR_LIST_FIELD']), 'ssa_regdate', $_GET['s_key'], $_GET['s_key2']);
		$order_img = get_order_img(array_keys($CFG['SADMIN_SPAM_ADDR_LIST_FIELD']), $_GET['s_key'], $_GET['s_key2'], false, 'common_skin');		// array

	// db - pager
		$DEBUG['db_cnt']['start'] = getmicrotime();
		$pager_params['totalItems'] = db_get_one("
			SELECT 
				COUNT(*) 
			FROM 
				" . $TB['SADMIN_SPAM_ADDR'] . "
			WHERE 
				1=1
				$q_where
			");
		$pager_params['perPage'] = 40;

		$DEBUG['db_cnt']['exec'] += getmicrotime() - $DEBUG['db_cnt']['start'];

		// [2016-01-11] PHP 5버전대에서 Ampersand가 DEPRECATED처리되어 &삭제
		#$pager = &new Pager_Sliding($pager_params);
		// [2016-01-11] Ampersand가 DEPRECATED관련하여 PEAR Pager라이브러리 업그레이드 소스적용  
		#$pager = new Pager_Sliding($pager_params);
		$pager = Pager::factory($pager_params);
		$pager_links = $pager->getLinks();
		$pager_limit = get_pager_limit($pager->getCurrentPageID(), $pager_params['perPage']);

	// db - select
		$DEBUG['db_select']['start'] = getmicrotime();
		$sql = "
			SELECT
				ssa_email, ssa_memo, ssa_regdate
			FROM
				" . $TB['SADMIN_SPAM_ADDR'] . "
			WHERE
				1=1
				$q_where
			ORDER BY
				" . $order_set['query'] . "
			";
		$rows = db_get_rows($sql, $pager_limit['from'], $pager_limit['count'], true);
		$rows_cnt = getarraycount($rows['ssa_email']);
		$DEBUG['db_select']['exec'] += getmicrotime() - $DEBUG['db_select']['start'];

		for ($i=0; $i<$rows_cnt; $i++)
		{
			$rows['ssa_regdate'][$i] = date('y-m-d H:i', strtotime($rows['ssa_regdate'][$i]));			
		}	// for()

	// 스팸주소수
		$sr_all_cnt = number_format($pager_params['totalItems']);

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


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