<?
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 ( d.d_name LIKE '%" . $_GET['s_word'] . "%' OR da.da_name LIKE '%" . $_GET['s_word'] . "%' ) ";
			$v_s_word = htmlspecialchars_fix(stripslashes($_GET['s_word']));
		}	// if()


	// sort
		$CFG['ADMIN_MEMBER_FIELD'] = array(
				'da.da_name' => '앨리어스 도메인',
				'd.d_name' => '메일 수신 도메인',
				'da.da_mail_from_select' => '보낸사람 주소로 사용여부',
				'da.da_regdate' => '등록일자'
				);
		$order_set = get_order(array_keys($CFG['ADMIN_MEMBER_FIELD']), 'da.da_no', $_GET['s_key'], $_GET['s_key2']);
		$order_img = get_order_img(array_keys($CFG['ADMIN_MEMBER_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['DOMAIN_ALIAS'] . " da,
				" . $TB['DOMAIN'] . " d
			WHERE 
				da.d_no=d.d_no
				" . $q_where
			);
		$pager_params['perPage'] = 20;

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

		$pager = &new Pager_Sliding($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
				d.d_name, da.*
			FROM
				" . $TB['DOMAIN_ALIAS'] . " da,
				" . $TB['DOMAIN'] . " d
			WHERE
				da.d_no=d.d_no
				" . $q_where . "
			ORDER BY
				" . $order_set['query'] . "
			";
		$rows = db_get_rows($sql, $pager_limit['from'], $pager_limit['count']);
		$DEBUG['db_select']['exec'] += getmicrotime() - $DEBUG['db_select']['start'];

	// process data
		$DEBUG['db_fetch_all']['start'] = getmicrotime();
		for ($i=0; $i<sizeof($rows); $i++)
		{
			//$rows[$i]['da_regdate'] = substr($rows[$i]['da_regdate'], 0, 10);
		}	// for()
		$rows = db_rows_fieldtokey($rows);
		$rows_cnt = getarraycount($rows['da_name']);

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

	// 앨리어스 도메인 관리수
		$sdomain_alias_all_cnt = number_format($pager_params['totalItems']);

// skin view
	nskinset('sadmin', 'sdomain_alias_list.html');		// 컨텐츠
	include($NSKIN['view_layout']);


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