<?
require_once("include/global.php");
require_once("include/admin_lib.php");
require_once("include/member_lib.php");


###############################################################################




	if (
		ereg("^ADMIN_", $mode)
		|| $mode_admin == 1 && ($mode == 'MODIFY' || $mode == 'OUT')
		)
	{
		$mode_admin = 1;

		// Config
			if ($mode_sadmin)
			{
				$CFG[TITLE] = "<b>메일서버관리</b> >> <b>전체회원관리</b>";
			} else
			{
				$CFG[TITLE] = "<b>관리자메뉴</b> >> <b>회원관리</b>";
			}	// if()
	} else
	{
		//$mode_admin = 0;

		// Config
			$CFG[TITLE] = "<b>환경설정</b>";
	}	// if()


	$q_sadmin = '';
	$q_sadmin_as = '';
	if ($mode_admin) {
		if ($mode_sadmin)
		{
			auth_limit("serveradmin");
			// [2007-05-18] 전체회원관리에서 회원가입양식은 관리자의 도메인 설정을 따르도록 함.
			if ($sa_d_no)
			{
				$q_sadmin = " AND d_no='".$sa_d_no."' ";
				$q_sadmin_as = " AND d.d_no='".$sa_d_no."' ";
				$q_sadmin_mf = " AND d_no='".$sa_d_no."' ";
			} else 
			{
				$q_sadmin_mf = " AND d_no='".$AUTH['auth_d_no']."' ";
			}	// if()
		} else
		{
			auth_limit("admin");
			$q_sadmin = " AND d_no='".$AUTH['auth_d_no']."' ";
			$q_sadmin_as = " AND d.d_no='".$AUTH['auth_d_no']."' ";
			// [2008-01-04] 멀티도메인 사용시 회원목록 필드 보여주기설정이 제대로 안되던 오류 수정.
			$q_sadmin_mf = " AND d_no='".$AUTH['auth_d_no']."' ";
			$sa_d_no = 0;
		}	// if()

		if (!is_numeric($_GET['page_size']) || $_GET['page_size'] > 100)
			$_GET['page_size'] = 20;

		// Query String
			require_once("include/querystring.php");

			$_ar_qs_text = array("mode_admin", "mode_sadmin", "sa_d_no", "s_mg_no", "list_type", "m_no", "reqPage", "s_query", "s_key", "s_key2", "s_kind1", "s_kind2", "s_kind3", "s_kind4", "s_word", "s_word1", "s_word2", "s_word3", "s_word4_1", "s_word4_2", "s_and_or1", "s_and_or2", "s_and_or3", "page_size");
			$_ar_qs_value = array($mode_admin, $mode_sadmin, $sa_d_no, $s_mg_no, $list_type, $m_no, $reqPage, $s_query, $s_key, $s_key2, $s_kind1, $s_kind2, $s_kind3, $s_kind4, $s_word, $s_word1, $s_word2, $s_word3, $s_word4_1, $s_word4_2, $s_and_or1, $s_and_or2, $s_and_or3, $_GET['page_size']);

			$CFG[QS]['DEFAULT'] = querystring($_ar_qs_text, $_ar_qs_value);		// $cfg_qs = "local_id=busan&reqPage=2"
			$CFG[QS]['SEARCH'] = querystring_cut($CFG[QS]['DEFAULT'], "m_no", "reqPage", "s_query", "s_key", "s_key2", "s_kind1", "s_kind2", "s_kind3", "s_kind4", "s_word", "s_word1", "s_word2", "s_word3", "s_word4_1", "s_word4_2", "s_and_or1", "s_and_or2", "s_and_or3");
			$CFG[QS]['SORT'] = querystring_cut($CFG[QS]['DEFAULT'], "m_no", "reqPage", "s_key", "s_key2");
			$CFG[QS]['RESET'] = $CFG[QS]['SEARCH'];
			$CFG[QS]['LIST'] = querystring_cut($CFG[QS]['DEFAULT'], "m_no");
			$CFG[QS]['LIST_PAGE'] = querystring_cut($CFG[QS]['DEFAULT'], "m_no", "reqPage");
	} else
	{
		$mode_sadmin = 0;
	}	// if()


###############################################################################

# Display

###############################################################################

	switch($mode)
	{
		case "ID_CHECK":

			auth_limit("guest");

			$CFG[TITLE] = "<b>ID 중복확인</b>";

			// check
				set_db();
				$m_id = strtolower($m_id);
				$q = "SELECT count(*) AS cnt FROM $TB[MEMBER] WHERE m_id = '$m_id' AND d_no='" . get_d_no($G_SYS['MAIL_DOMAIN']) . "'";
				$id_check_cnt = db_get_one($q);

				// 회원가입시 제한할 ID
				$_as = array_search(stripslashes($m_id), $G_SYS[MBR_ID_DENY]);
				$is_mbr_id_deny = ($id_check_cnt < 1 && $_as !== false && $_as !== NULL) ? true : false;

			// skin view
				nskinset('member', 'id_check.html', 'window_open');
				include($NSKIN['view_layout']);
			break;


###############################################################################


		case "ZIPCODE_SEARCH":

			auth_limit("guest");

			$CFG[TITLE] = "<b>우편번호 찾기</b>";

			// get
				if ($s_dong == true)
				{
					set_q_search($s_dong);

					set_db();
					$q = "SELECT * FROM $TB[ZIPCODE] WHERE dong like '%$s_dong%' OR gugun like '%$s_dong%' ORDER BY zip1,gugun,dong,bunji";
					$r_zip = db_get_rows($q, 0, 100);
				}	// if()


			// view
				$v_from = input_value($from,1);
				$v_s_dong = input_value($s_dong,1);

			// skin view
				nskinset('member', 'zipcode_search.html', 'window_open');
				include($NSKIN['view_layout']);

			break;


###############################################################################


		case "NOTICE":

			auth_limit("guest");

			if (!$mode_admin && $G_SYS['SSO_ISUSE'] == 'Y')		// 외부회원모듈과 연동할 경우.
			{
				if ($G_SYS['SSO_JOIN_URL'])
				{
					// [2007-01-18] 프레임으로 연동한 경우를 고려
					//movepage($G_SYS['SSO_JOIN_URL']);
					movepage($G_SYS['SSO_JOIN_URL'], 0, $G_SYS['SSO_JOIN_URL_TARGET']);
				} else
				{
					msg($G_SYS['SSO_NOT_URL_MSG']);
				}	// if()
			}	// if()

			$CFG[TITLE] = "<b>회원가입안내</b>";

			// 메일용량 할당량, 메일계정 할당수 제한
				require_once('include/admin_lib.php');
				mbr_add_limit();								

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

			break;


###############################################################################


		case "JOIN":

			//auth_limit("guest", "REVERSE");
			set_db();

			if (!$mode_admin && $G_SYS['SSO_ISUSE'] == 'Y')		// 외부회원모듈과 연동할 경우.
			{
				if ($G_SYS['SSO_JOIN_URL'])
				{
					// [2007-01-18] 프레임으로 연동한 경우를 고려
					//movepage($G_SYS['SSO_JOIN_URL']);
					movepage($G_SYS['SSO_JOIN_URL'], 0, $G_SYS['SSO_JOIN_URL_TARGET']);
				} else
				{
					msg($G_SYS['SSO_NOT_URL_MSG']);
				}	// if()
			}	// if()

			$CFG[TITLE] = "<b>회원가입신청</b>";

			// check
				// 메일용량 할당량, 메일계정 할당수 제한
					require_once('include/admin_lib.php');
					mbr_add_limit();
				
				// [2006-03-08] 메일서버가 동작중인지 확인
					mail_server_check_limit();		

			// get
				$mf = get_member_field();
				$mbr_form = set_form_mbr();		// array


			// view
				$mode_proc = "JOIN_OK";
				$mode_name = "회원가입";
				$mail_domain_view = $G_SYS['MAIL_DOMAIN'];


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

			break;


###############################################################################


		case "MODIFY":

			auth_limit("user");
			set_db();

			if (!$mode_admin && $G_SYS['SSO_ISUSE'] == 'Y')		// 외부회원모듈과 연동할 경우.
			{
				if ($G_SYS['SSO_MODIFY_URL'])
				{
					// [2007-01-18] 프레임으로 연동한 경우를 고려
					//movepage($G_SYS['SSO_MODIFY_URL']);
					movepage($G_SYS['SSO_MODIFY_URL'], 0, $G_SYS['SSO_MODIFY_URL_TARGET']);
				} else
				{
					msg($G_SYS['SSO_NOT_URL_MSG']);
				}	// if()
			}	// if()

			// [2006-03-08] 메일서버가 동작중인지 확인
				require_once('include/admin_lib.php');
				mail_server_check_limit();		

			$CFG[TITLE] = $CFG[TITLE] . " >> <b>개인정보 변경</b>";

			$m_no = ($mode_admin) ? $m_no : $AUTH[auth_m_no];


			// get
				$mf = get_member_field();
				$mbr = member_info($m_no);		// array
				$mbr_form = set_form_mbr($mbr);		// array


			// [2006-11-02] 관리자모드일때, 관리자는 서버관리자의 정보를 변경할 수 없도록함.
				if ($mbr['m_level'] > $AUTH['auth_m_level'])
					msg("자신보다 높은 [".$G['LEVEL_NAME'][$G['LEVEL']['serveradmin']]."]레벨의 계정은 수정/삭제가 불가능합니다.");


			// view
				$mode_proc = "MODIFY_OK";
				$mode_name = "개인정보수정";
				$modify_disabled = ($mode_admin) ? NULL : " disabled";
				$m_id_modify_disabled = " disabled";
				if ($mode_sadmin)
				{
					$sql = "SELECT d_name FROM ".$TB['DOMAIN']." WHERE d_no='". $mbr['d_no'] . "'";
					$mail_domain_view = db_get_one($sql);
					$d_no_view = $mbr['d_no'];
				} else
				{
					$mail_domain_view = $G_SYS['MAIL_DOMAIN'];
					$d_no_view = $AUTH['auth_d_no'];
				}	// if()

			// [2006-02-21] 회원조직
				/*
				if ($mode_admin)
				{
					$q = "SELECT * FROM ".$TB['MEMBER_GROUP']." WHERE d_no='".$d_no_view."' ORDER BY mg_no";
					$mbr_group = db_get_rows($q, true);
					$mbr_form[mg_no] = select_list_value($mbr[mg_no], $mbr_group['mg_name'], $mbr_group['mg_no'], NULL, 1, 1);
				}	// if()
				*/


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

			break;



###############################################################################


		case "OUT":

			auth_limit("user");
			set_db();

			if (!$mode_admin && $G_SYS['SSO_ISUSE'] == 'Y')		// 외부회원모듈과 연동할 경우.
			{
				if ($G_SYS['SSO_OUT_URL'])
				{
					// [2007-01-18] 프레임으로 연동한 경우를 고려
					// movepage($G_SYS['SSO_OUT_URL']);
					movepage($G_SYS['SSO_OUT_URL'], 0, $G_SYS['SSO_OUT_URL_TARGET']);
				} else
				{
					msg($G_SYS['SSO_NOT_URL_MSG']);
				}	// if()
			}	// if()

			// [2006-03-08] 메일서버가 동작중인지 확인
				require_once('include/admin_lib.php');
				mail_server_check_limit();		

			$CFG[TITLE] = $CFG[TITLE] . " >> <b>회원탈퇴</b>";


			// get
				$mf = get_member_field();
				$m_no = ($mode_admin) ? $m_no : $AUTH[auth_m_no];
				$mbr = member_info($m_no);		// array

			// view

				$m_id = $mbr[m_id];
				$m_name = $mbr[m_name];

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

			break;


###############################################################################


		case "LOST1":

			//auth_limit("guest", "REVERSE");
			$CFG[TITLE] = "<b>비밀번호 재발급 신청</b>";

			if (!$mode_admin && $G_SYS['SSO_ISUSE'] == 'Y')		// 외부회원모듈과 연동할 경우.
			{
				if ($G_SYS['SSO_PASSWDFIND_URL'])
				{
					// [2007-01-18] 프레임으로 연동한 경우를 고려
					//movepage($G_SYS['SSO_PASSWDFIND_URL']);
					movepage($G_SYS['SSO_PASSWDFIND_URL'], 0, $G_SYS['SSO_PASSWDFIND_URL_TARGET']);
				} else
				{
					msg($G_SYS['SSO_NOT_URL_MSG']);
				}	// if()
			}	// if()


			// get
				$mf = get_member_field();

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

			break;


###############################################################################


		case "LOST2":

			//auth_limit("guest", "REVERSE");
			$CFG[TITLE] = "<b>비밀번호 재발급 확인</b>";

			set_db();

			// get
				$mf = get_member_field();

			// search id

				if ($is_search == "Y")
				{
					$mbr = member_lost_search($s_m_name, $s_m_jumin1, $s_m_jumin2, $s_m_email);
				}else
				{
					$mbr = member_info_where("m_id='$m_id'");		// array
				}	// if()


			// view

				$v_m_no = input_value($mbr[m_no],1);
				$m_id = $mbr[m_id];
				$m_lostpwd_q = $mbr[m_lostpwd_q];


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

			break;


###############################################################################

# Process

###############################################################################


		case "JOIN_OK":

			require_once("include/file.php");

			//auth_limit("guest", "REVERSE");
			set_db();


			// check
			if (!$m_id || !$m_pwd || !$m_name)
				msg("올바른 URL로 접근하여 주십시오.");

			// 메일용량 할당량, 메일계정 할당수 제한
				require_once('include/admin_lib.php');
				mbr_add_limit();

			// [2006-03-08] 메일서버가 동작중인지 확인
				mail_server_check_limit();		

			// get
				$mf = get_member_field();


			// set
				// data
					$m_id = strtolower($m_id);		// 소문자만 허용
					$m_jumin = $m_jumin_1 . "-" . $m_jumin_2;
					$m_birthday = $m_birthday_1 . "-" . sprintf("%02d", $m_birthday_2) . "-" . sprintf("%02d", $m_birthday_3);
					$m_mobile = $m_mobile_1 . "-" . $m_mobile_2 . "-" . $m_mobile_3;
					$m_home_tel = $m_home_tel_1 . "-" . $m_home_tel_2 . "-" . $m_home_tel_3;
					$m_home_zipcode = $m_home_zipcode_1 . "-" . $m_home_zipcode_2;
					$m_office_tel = $m_office_tel_1 . "-" . $m_office_tel_2 . "-" . $m_office_tel_3;
					$m_office_fax = $m_office_fax_1 . "-" . $m_office_fax_2 . "-" . $m_office_fax_3;
					$m_office_zipcode = $m_office_zipcode_1 . "-" . $m_office_zipcode_2;
					$m_marrydate = $m_marrydate_1 . "-" . sprintf("%02d", $m_marrydate_2) . "-" . sprintf("%02d", $m_marrydate_3);
					if (trim($m_homepage) == "http://" ) $m_homepage = NULL;

					$m_date1 = $m_date1_1 . "-" . sprintf("%02d", $m_date1_2) . "-" . sprintf("%02d", $m_date1_3);
					$m_date2 = $m_date2_1 . "-" . sprintf("%02d", $m_date2_2) . "-" . sprintf("%02d", $m_date2_3);
					$m_date3 = $m_date3_1 . "-" . sprintf("%02d", $m_date3_2) . "-" . sprintf("%02d", $m_date3_3);
					$m_date4 = $m_date4_1 . "-" . sprintf("%02d", $m_date4_2) . "-" . sprintf("%02d", $m_date4_3);
					$m_date5 = $m_date5_1 . "-" . sprintf("%02d", $m_date5_2) . "-" . sprintf("%02d", $m_date5_3);


				// query
					to_db_str(&$m_id, $mf[m_id][length], "STRIP_TAGS");
					to_db_str(&$m_pwd, $mf[m_pwd][length]);
					to_db_str(&$m_lostpwd_q, $mf[m_lostpwd_q][length]);
					to_db_str(&$m_lostpwd_a, $mf[m_lostpwd_a][length]);
					to_db_str(&$m_name, $mf[m_name][length], "STRIP_TAGS");
					to_db_str(&$m_last_name, $mf[m_last_name][length], "STRIP_TAGS");
					to_db_str(&$m_email, $mf[m_email][length], "STRIP_TAGS");
					to_db_str(&$m_homepage, $mf[m_homepage][length], "STRIP_TAGS");
					to_db_str(&$m_jumin, 14);
					to_db_str(&$m_mobile, $mf[m_mobile][length]);
					to_db_str(&$m_home_tel, $mf[m_home_tel][length]);
					to_db_str(&$m_home_zipcode, $mf[m_home_zipcode][length]);
					to_db_str(&$m_home_addr1, $mf[m_home_addr1][length]);
					to_db_str(&$m_home_addr2, $mf[m_home_addr2][length]);
					to_db_str(&$m_office, $mf[m_office][length]);
					to_db_str(&$m_office_subject, $mf[m_office_subject][length]);
					to_db_str(&$m_office_tel, $mf[m_office_tel][length]);
					to_db_str(&$m_office_zipcode, $mf[m_office_zipcode][length]);
					to_db_str(&$m_office_addr1, $mf[m_office_addr1][length]);
					to_db_str(&$m_office_addr2, $mf[m_office_addr2][length]);
					to_db_str(&$m_memo, $mf[m_memo][length]);
					to_db_str(&$m_etc1, $mf[m_etc1][length]);
					to_db_str(&$m_etc2, $mf[m_etc2][length]);
					to_db_str(&$m_etc3, $mf[m_etc3][length]);
					to_db_str(&$m_etc4, $mf[m_etc4][length]);
					to_db_str(&$m_etc5, $mf[m_etc5][length]);
					to_db_str(&$m_date1, $mf[m_date1][length]);
					to_db_str(&$m_date2, $mf[m_date2][length]);
					to_db_str(&$m_date3, $mf[m_date3][length]);
					to_db_str(&$m_date4, $mf[m_date4][length]);
					to_db_str(&$m_date5, $mf[m_date5][length]);


				// default
					$m_level = $G_MB[DEFAULT_JOIN_LEVEL];
					$m_regdate = date("Y-m-d H:i:s");
					$m_reghost = $_SERVER[REMOTE_ADDR];
					$m_login_cnt = 1;
					$m_last_logindate = $m_regdate;
					$m_last_loginhost = $m_reghost;
					if (!$m_isremail)
						$m_isremail = 'Y';


				// 업로드되었을때만 파일이름을 DB에 저장함.
					$m_file1_dbname = (is_uploaded_file($m_file1)) ? $_FILES[m_file1][name] : NULL;
					$m_file2_dbname = (is_uploaded_file($m_file2)) ? $_FILES[m_file2][name] : NULL;
					$m_file3_dbname = (is_uploaded_file($m_file3)) ? $_FILES[m_file3][name] : NULL;
					$m_file4_dbname = (is_uploaded_file($m_file4)) ? $_FILES[m_file4][name] : NULL;
					$m_file5_dbname = (is_uploaded_file($m_file5)) ? $_FILES[m_file5][name] : NULL;

			// check
				$dm = get_domain($G_SYS['MAIL_DOMAIN']);

				// m_id
					$q = "SELECT count(*) AS cnt FROM $TB[MEMBER] WHERE m_id='$m_id' AND d_no='" . $dm['d_no'] . "'";
					$id_check_cnt = db_get_one($q);
					if($id_check_cnt > 0) msg($m_id."는 이미 가입된 ID입니다.\\n\\n다른 ID를 사용하여 주십시오.");

					// 회원가입시 제한할 ID
					$_as = array_search(stripslashes($m_id), $G_SYS[MBR_ID_DENY]);
					if ($id_check_cnt < 1 && $_as !== false && $_as !== NULL)
						msg($m_id."는 사용이 제한된 ID입니다.\\n\\n다른 ID를 사용하여 주십시오.");

				// m_jumin
					if ($G_MB[ISCHECK_JUMIN_DUPLICATE])
					{
						$q = "SELECT count(*) AS cnt FROM $TB[MEMBER] WHERE m_jumin='$m_jumin' AND d_no='" . $dm['d_no'] . "'";
						$chk_m_jumin = db_get_row($q);
						if($chk_m_jumin[cnt] > 0) msg("이미 사용된 주민등록번호입니다.\\n\\n기존에 가입된 회원인지 확인하여 주십시오.\\n\\n만약 가입한적이 없다면 관리자에게 문의하시기 바랍니다.");
					}	// if()

			// proc
				// db insert
					$m_is_use = 'Y';
					$m_mail_file_group = get_mail_file_group_now($dm['d_no']);
					$m_quota = $dm['d_quota_mbr_default'];

					// [2008-02-20] 대용량첨부, 웹하드 용량 추가
					$m_bigfile_quota = $dm['d_bigfile_quota_default'];
					$m_webhard_quota = $dm['d_webhard_quota_default'];

					$m_pwd_enc = pwd_enc(stripslashes($m_pwd), stripslashes($m_id));

					$q = "
						INSERT INTO
							$TB[MEMBER]
							(m_no, m_id, m_pwd, m_lostpwd_q, m_lostpwd_a, m_level, m_name, m_last_name, m_email, m_homepage, m_jumin, m_sex, m_birthday, m_birthday_east, m_mobile, m_home_tel, m_home_zipcode, m_home_addr1, m_home_addr2, m_job, m_office, m_office_subject, m_office_tel, m_office_fax, m_office_zipcode, m_office_addr1, m_office_addr2, m_ismarry, m_marrydate, m_isremail, m_memo, m_etc1, m_etc2, m_etc3, m_etc4, m_etc5, m_date1, m_date2, m_date3, m_date4, m_date5, m_file1, m_file2, m_file3, m_file4, m_file5, m_regdate, m_reghost, m_login_cnt, m_last_logindate, m_last_loginhost, m_last_modifydate, m_last_modifyhost, d_no, m_is_use, m_mail_file_group, m_quota, m_bigfile_quota, m_webhard_quota)
						VALUES
							(".db_sqc_next($TB['MEMBER']).", '$m_id', '$m_pwd_enc', '$m_lostpwd_q', '$m_lostpwd_a', '$m_level', '$m_name', '$m_last_name', '$m_email', '$m_homepage', '$m_jumin', '$m_sex', '$m_birthday', '$m_birthday_east', '$m_mobile', '$m_home_tel', '$m_home_zipcode', '$m_home_addr1', '$m_home_addr2', '$m_job', '$m_office', '$m_office_subject', '$m_office_tel', '$m_office_fax', '$m_office_zipcode', '$m_office_addr1', '$m_office_addr2', '$m_ismarry', '$m_marrydate', '$m_isremail', '$m_memo', '$m_etc1', '$m_etc2', '$m_etc3', '$m_etc4', '$m_etc5', '$m_date1', '$m_date2', '$m_date3', '$m_date4', '$m_date5', '$m_file1_dbname', '$m_file2_dbname', '$m_file3_dbname', '$m_file4_dbname', '$m_file5_dbname', '$m_regdate', '$m_reghost', '$m_login_cnt', '$m_last_logindate', '$m_last_loginhost', '$m_last_modifydate', '$m_last_modifyhost', '".$dm['d_no']."', '$m_is_use', '$m_mail_file_group', '$m_quota', '$m_bigfile_quota', '$m_webhard_quota')
						";
					//echo "<HR>" . $q;
					db_query($q);

					$curr_m_no = db_sqc_curr($TB['MEMBER']);		// 삽입된 데이타 키


				// upload
					require_once("include/file.php");
					$errorMsg = NULL;
					$errorMsg .= file_up($m_file1, $_FILES[m_file1][name], $_FILES[m_file1][size], $UPLOAD_DIR[MEMBER], $curr_m_no, "ALL");
					$errorMsg .= file_up($m_file2, $_FILES[m_file2][name], $_FILES[m_file2][size], $UPLOAD_DIR[MEMBER], $curr_m_no, "ALL");
					$errorMsg .= file_up($m_file3, $_FILES[m_file3][name], $_FILES[m_file3][size], $UPLOAD_DIR[MEMBER], $curr_m_no, "ALL");
					$errorMsg .= file_up($m_file4, $_FILES[m_file4][name], $_FILES[m_file4][size], $UPLOAD_DIR[MEMBER], $curr_m_no, "ALL");
					$errorMsg .= file_up($m_file5, $_FILES[m_file5][name], $_FILES[m_file5][size], $UPLOAD_DIR[MEMBER], $curr_m_no, "ALL");


				/*
				// body make
					$m = array();
					$m[m_name] = $m_name;
					$m[m_id] = $m_id;

					// body
						$body = file_read("../main/header_mail.inc.html");
						$body .= file_read("member_skin/join_mail.html");
						$body .= file_read("../main/footer_mail.inc.html");
						//echo "<hr><xmp>" . $body . "</xmp>";

						$body = set_text_fetch($body);
						$body = text_fetch("m", $m, $body);
						//echo "<hr><xmp>" . $body . "</xmp>";
						//echo "<hr>" . $body;


				// mail send
					require_once('include/mail_send_lib.php');

					$recipients = $m_email;		// An array or comma seperated string of recipients.
					$to = "\"" . $m_name . "\"<" . $m_email . ">";
					$from = "\"" . $G_SYS[ADMIN_EMAIL_NAME] . "\"<" . $G_SYS[ADMIN_EMAIL] . ">";		// 한글사용시 큰따옴표로 묶어줘야함.  ex) "테스터"<test@test.com>
					$subject = "[" . $G_SYS[SITE_NAME] . "]" . $m_name . "(" . $m_id . ")님의 가입을 축하드립니다!";
					$body;
					$body_type = "HTML";
					$file = NULL;
					$file_name = NULL;
					$host = $G_SYS[SMTP_ADDR];

					//echo "<hr><xmp>" . $subject . "</xmp>";
					//echo "<hr>" . $body . "";

					mail_smtp($recipients, $to, $from, $subject, $body, $body_type, $file, $file_name, $host);
				*/


				// 웹메일용 처리.
					#require_once('include/admin_lib.php');
					mbr_add($curr_m_no, $m_id, $m_pwd, $m_quota, $m_mail_file_group);


				// login
					if ($m_level == $G[LEVEL][wait])
					{
						$msg = "회원가입신청이 완료되었습니다.\\n\\n관리자의 승인후 정상적인 사용이 가능합니다.";
					} else
					{
						$msg = "회원가입이 완료되었습니다.";
						$_POST['m_id'] = $m_id;
						$_POST['m_pwd'] = $m_pwd;
						auth_proc("LOGIN");
					}	// if()


			// view
				#msg("$m_name($m_id)님은 $G_SYS[SITE_NAME] 회원으로 가입되었습니다.\\n\\n이제 $G_SYS[SITE_NAME] 회원으로써의 모든 자격과 권리가 있습니다.", 0);
				msg($msg, 0);
				movepage($G_SYS['URL_ROOT'].'/index.php');

			break;


###############################################################################


		case "MODIFY_OK":

			auth_limit("user");
			set_db();

			$m_no = ($mode_admin) ? $m_no : $AUTH[auth_m_no];

			$mbr = member_info($m_no);		// array


			// [2006-11-02] 관리자모드일때, 관리자는 서버관리자의 정보를 변경할 수 없도록함.
				if ($mbr['m_level'] > $AUTH['auth_m_level'])
					msg("자신보다 높은 [".$G['LEVEL_NAME'][$G['LEVEL']['serveradmin']]."]레벨의 계정은 수정/삭제가 불가능합니다.");


			// [2006-03-08] 메일서버가 동작중인지 확인
				require_once('include/admin_lib.php');
				mail_server_check_limit();		


			// get
				$mf = get_member_field();


			// set
				// data
					#$m_id = strtolower($m_id);		// 소문자만 허용
					$m_jumin = $m_jumin_1 . "-" . $m_jumin_2;
					$m_birthday = $m_birthday_1 . "-" . sprintf("%02d", $m_birthday_2) . "-" . sprintf("%02d", $m_birthday_3);
					$m_mobile = $m_mobile_1 . "-" . $m_mobile_2 . "-" . $m_mobile_3;
					$m_home_tel = $m_home_tel_1 . "-" . $m_home_tel_2 . "-" . $m_home_tel_3;
					$m_home_zipcode = $m_home_zipcode_1 . "-" . $m_home_zipcode_2;
					$m_office_tel = $m_office_tel_1 . "-" . $m_office_tel_2 . "-" . $m_office_tel_3;
					$m_office_fax = $m_office_fax_1 . "-" . $m_office_fax_2 . "-" . $m_office_fax_3;
					$m_office_zipcode = $m_office_zipcode_1 . "-" . $m_office_zipcode_2;
					$m_marrydate = $m_marrydate_1 . "-" . sprintf("%02d", $m_marrydate_2) . "-" . sprintf("%02d", $m_marrydate_3);
					if (trim($m_homepage) == "http://" ) $m_homepage = NULL;

					$m_date1 = $m_date1_1 . "-" . sprintf("%02d", $m_date1_2) . "-" . sprintf("%02d", $m_date1_3);
					$m_date2 = $m_date2_1 . "-" . sprintf("%02d", $m_date2_2) . "-" . sprintf("%02d", $m_date2_3);
					$m_date3 = $m_date3_1 . "-" . sprintf("%02d", $m_date3_2) . "-" . sprintf("%02d", $m_date3_3);
					$m_date4 = $m_date4_1 . "-" . sprintf("%02d", $m_date4_2) . "-" . sprintf("%02d", $m_date4_3);
					$m_date5 = $m_date5_1 . "-" . sprintf("%02d", $m_date5_2) . "-" . sprintf("%02d", $m_date5_3);


				// query
					#to_db_str(&$m_id, $mf[m_id][length], "STRIP_TAGS");
					to_db_str(&$m_pwd, $mf[m_pwd][length]);
					to_db_str(&$m_lostpwd_q, $mf[m_lostpwd_q][length]);
					to_db_str(&$m_lostpwd_a, $mf[m_lostpwd_a][length]);
					to_db_str(&$m_name, $mf[m_name][length], "STRIP_TAGS");
					to_db_str(&$m_last_name, $mf[m_last_name][length], "STRIP_TAGS");
					to_db_str(&$m_email, $mf[m_email][length], "STRIP_TAGS");
					to_db_str(&$m_homepage, $mf[m_homepage][length], "STRIP_TAGS");
					to_db_str(&$m_jumin, 14);
					to_db_str(&$m_mobile, $mf[m_mobile][length]);
					to_db_str(&$m_home_tel, $mf[m_home_tel][length]);
					to_db_str(&$m_home_zipcode, $mf[m_home_zipcode][length]);
					to_db_str(&$m_home_addr1, $mf[m_home_addr1][length]);
					to_db_str(&$m_home_addr2, $mf[m_home_addr2][length]);
					to_db_str(&$m_office, $mf[m_office][length]);
					to_db_str(&$m_office_subject, $mf[m_office_subject][length]);
					to_db_str(&$m_office_tel, $mf[m_office_tel][length]);
					to_db_str(&$m_office_zipcode, $mf[m_office_zipcode][length]);
					to_db_str(&$m_office_addr1, $mf[m_office_addr1][length]);
					to_db_str(&$m_office_addr2, $mf[m_office_addr2][length]);
					to_db_str(&$m_memo, $mf[m_memo][length]);
					to_db_str(&$m_etc1, $mf[m_etc1][length]);
					to_db_str(&$m_etc2, $mf[m_etc2][length]);
					to_db_str(&$m_etc3, $mf[m_etc3][length]);
					to_db_str(&$m_etc4, $mf[m_etc4][length]);
					to_db_str(&$m_etc5, $mf[m_etc5][length]);
					to_db_str(&$m_date1, $mf[m_date1][length]);
					to_db_str(&$m_date2, $mf[m_date2][length]);
					to_db_str(&$m_date3, $mf[m_date3][length]);
					to_db_str(&$m_date4, $mf[m_date4][length]);
					to_db_str(&$m_date5, $mf[m_date5][length]);

					$q_pwd = ($m_pwd) ? " m_pwd = '".pwd_enc(stripslashes($m_pwd), $mbr['m_id'])."', " : "";

					// admin
					$q_m_level = '';
					$q_m_name = '';
					$q_m_jumin = '';
					$q_mg_no = '';
					if ($mode_admin)		// 관리자메뉴 - 회원정보수정
					{
						// 관리자모드일때, 관리자의 서버관리자의 정보를 변경할 수 없도록함.
							if ($mbr['m_level'] > $AUTH['auth_m_level'] || $m_level > $AUTH['auth_m_level'])
							{
								msg("[".$G['LEVEL_NAME'][$G['LEVEL']['serveradmin']]."]의 경우 레벨 항목은 수정되지 않습니다.", 0);
							} else
							{
								$q_m_level = ($m_level) ? " m_level = '$m_level', " : "";
							}	// if()
						#$q_m_id = ($m_id) ? " m_id = '$m_id', " : "";
						$q_m_name = ($m_name) ? " m_name = '$m_name', " : "";
						$q_m_jumin = ($m_jumin) ? " m_jumin = '$m_jumin', " : "";
						$q_mg_no = ($mg_no) ? " mg_no = '$mg_no', " : "";
					}	// if()


				// default
					$m_last_modifydate = date("Y-m-d H:i:s");
					$m_last_modifyhost = $_SERVER[REMOTE_ADDR];


				// 업로드 되었을때 새 파일이름을 저장하고, 기존 파일 유지시 기존 파일이름 저장.
					$m_file1_dbname = (is_uploaded_file($m_file1)) ? $_FILES[m_file1][name] : $m_file1_old;
					$m_file2_dbname = (is_uploaded_file($m_file2)) ? $_FILES[m_file2][name] : $m_file2_old;
					$m_file3_dbname = (is_uploaded_file($m_file3)) ? $_FILES[m_file3][name] : $m_file3_old;
					$m_file4_dbname = (is_uploaded_file($m_file4)) ? $_FILES[m_file4][name] : $m_file4_old;
					$m_file5_dbname = (is_uploaded_file($m_file5)) ? $_FILES[m_file5][name] : $m_file5_old;


			// proc
				// db update
					$q = "UPDATE $TB[MEMBER] SET
						$q_pwd
						$q_m_level
						$q_m_name
						$q_m_jumin
						$q_mg_no
						m_lostpwd_q='$m_lostpwd_q',
						m_lostpwd_a='$m_lostpwd_a',
						m_last_name='$m_last_name',
						m_email='$m_email',
						m_homepage='$m_homepage',
						m_sex='$m_sex',
						m_birthday='$m_birthday',
						m_birthday_east='$m_birthday_east',
						m_mobile='$m_mobile',
						m_home_tel='$m_home_tel',
						m_home_zipcode='$m_home_zipcode',
						m_home_addr1='$m_home_addr1',
						m_home_addr2='$m_home_addr2',
						m_job='$m_job',
						m_office='$m_office',
						m_office_subject='$m_office_subject',
						m_office_tel='$m_office_tel',
						m_office_fax='$m_office_fax',
						m_office_zipcode='$m_office_zipcode',
						m_office_addr1='$m_office_addr1',
						m_office_addr2='$m_office_addr2',
						m_ismarry='$m_ismarry',
						m_marrydate='$m_marrydate',
						m_isremail='$m_isremail',
						m_memo='$m_memo',
						m_etc1='$m_etc1',
						m_etc2='$m_etc2',
						m_etc3='$m_etc3',
						m_etc4='$m_etc4',
						m_etc5='$m_etc5',
						m_date1='$m_date1',
						m_date2='$m_date2',
						m_date3='$m_date3',
						m_date4='$m_date4',
						m_date5='$m_date5',
						m_file1='$m_file1_dbname',
						m_file2='$m_file2_dbname',
						m_file3='$m_file3_dbname',
						m_file4='$m_file4_dbname',
						m_file5='$m_file5_dbname',
						m_last_modifydate='$m_last_modifydate',
						m_last_modifyhost='$m_last_modifyhost'
						WHERE
							m_no='" . $m_no . "'
							$q_sadmin
						";
					//echo "<HR>" . $q;
					db_query($q);


				// old file delete
					require_once("include/file.php");
					$errorMsg = NULL;

					// 새파일이 업로드되었을때 기존파일 삭제
					if ( is_uploaded_file($m_file1) ) $errorMsg .= file_del($m_file1_old, $m_no, $UPLOAD_DIR[MEMBER]);
					if ( is_uploaded_file($m_file2) ) $errorMsg .= file_del($m_file2_old, $m_no, $UPLOAD_DIR[MEMBER]);
					if ( is_uploaded_file($m_file3) ) $errorMsg .= file_del($m_file3_old, $m_no, $UPLOAD_DIR[MEMBER]);
					if ( is_uploaded_file($m_file4) ) $errorMsg .= file_del($m_file4_old, $m_no, $UPLOAD_DIR[MEMBER]);
					if ( is_uploaded_file($m_file5) ) $errorMsg .= file_del($m_file5_old, $m_no, $UPLOAD_DIR[MEMBER]);


				// file upload
					$errorMsg .= file_up($m_file1, $_FILES[m_file1][name], $_FILES[m_file1][size], $UPLOAD_DIR[MEMBER], $m_no, "ALL");
					$errorMsg .= file_up($m_file2, $_FILES[m_file2][name], $_FILES[m_file2][size], $UPLOAD_DIR[MEMBER], $m_no, "ALL");
					$errorMsg .= file_up($m_file3, $_FILES[m_file3][name], $_FILES[m_file3][size], $UPLOAD_DIR[MEMBER], $m_no, "ALL");
					$errorMsg .= file_up($m_file4, $_FILES[m_file4][name], $_FILES[m_file4][size], $UPLOAD_DIR[MEMBER], $m_no, "ALL");
					$errorMsg .= file_up($m_file5, $_FILES[m_file5][name], $_FILES[m_file5][size], $UPLOAD_DIR[MEMBER], $m_no, "ALL");


				// 웹메일용 처리 - 비밀번호만 변경.
					require_once('include/admin_lib.php');
					if ($mode_sadmin)
					{
						$sql = "SELECT d_name FROM ".$TB['DOMAIN']." WHERE d_no='". $mbr['d_no'] . "'";
						$G_SYS['MAIL_DOMAIN'] = db_get_one($sql);
					}	// if()
					mbr_mod($mbr['m_id'], $m_pwd);

			// view
				msg("개인정보를 수정하였습니다." . $errorMsg, 0);
				if ($mode_admin)
				{
					movepage('admin_mbr_list.php?'.$CFG[QS]['LIST']);
				} else 
				{
					movepage('mail_config.php');
				}	// if()

			break;


###############################################################################


		case "OUT_OK":

			auth_limit("user");
			set_db();

			// [2006-03-08] 메일서버가 동작중인지 확인
				require_once('include/admin_lib.php');
				mail_server_check_limit();		

			$m_no = ($mode_admin) ? $m_no : $AUTH[auth_m_no];
			$mbr = member_info($m_no);		// array
			$mf = get_member_field();


			// check
				if (!$mode_admin) {
					if(strcmp($mbr[m_pwd], pwd_enc(stripslashes($m_pwd), $mbr['m_id'], $mbr[m_pwd]))) msg("비밀번호가 일치하지 않습니다.");
					if ($mf[m_jumin][isuse] == "Y" && strlen($mbr[m_jumin]) == 14)
					{
						$m_jumin = $m_jumin_1 . "-" . $m_jumin_2;
						if(strcmp($mbr[m_jumin], $m_jumin)) msg("주민등록번호가 일치하지 않습니다.");
					}	// if()
				}	// if()


			// set


			// proc
					$q = "
						UPDATE
							$TB[MEMBER]
						SET
							m_level='" . $G[LEVEL][out] . "'
						WHERE
							m_no='" . $m_no . "'
							$q_sadmin
						";
					//echo "<HR>" . $q;
					db_query($q);

					// [2006-08-08] 사용자 상태 갱신
					mbr_stats_update($m_no);

					/** 삭제하지 않는 필드

						m_no=NULL,
						m_id=NULL,
						m_name=NULL,
						m_last_name=NULL,
						m_regdate=NULL,
						m_reghost=NULL,
						m_login_cnt=NULL,
						m_last_logindate=NULL,
						m_last_loginhost=NULL,
						m_last_modifydate=NULL,
						m_last_modifyhost=NULL,
						m_expiredate=NULL,

					*/


				// file delete
					/*
					require_once("include/file.php");
					$errorMsg = NULL;

					// 새파일이 업로드되었을때 기존파일 삭제
					$errorMsg .= file_del($mbr[m_file1], $m_no, $UPLOAD_DIR[MEMBER]);
					$errorMsg .= file_del($mbr[m_file2], $m_no, $UPLOAD_DIR[MEMBER]);
					$errorMsg .= file_del($mbr[m_file3], $m_no, $UPLOAD_DIR[MEMBER]);
					$errorMsg .= file_del($mbr[m_file4], $m_no, $UPLOAD_DIR[MEMBER]);
					$errorMsg .= file_del($mbr[m_file5], $m_no, $UPLOAD_DIR[MEMBER]);
					*/


				// logout
					if (!$mode_admin) {
						auth_proc("LOGOUT");
					}	// if()


			// view
				$view_name = $mbr[m_name] . "(" . $mbr[m_id] . ")";

				if (!$mode_admin) {
					msg("회원탈퇴를 하였습니다.\\n\\n이용해주셔서 감사합니다.", 0);
					movepage($G_SYS['URL_ROOT'].'/index.php');
				}else {
					msg("회원탈퇴를 하였습니다." . $errorMsg, 0);
					movepage('admin_mbr_list.php?'.$CFG[QS]['LIST']);
				}	// if()

			break;


###############################################################################


		case "LOST_OK":

			require_once("include/mail_lib.php");
			require_once("include/file.php");

			//auth_limit("guest", "REVERSE");
			set_db();

			// get
				$mf = get_member_field();
				$mbr = member_info($m_no);		// array

			// check
				if (!$mbr[m_email])
				{
					msg($mf[m_email][text]."이 입력되지 않아 재발급이 불가능합니다.\\n\\n관리자에게 문의하여 주십시오.", 0);
					movepage($G_SYS['URL_ROOT'].'/member.php?mode=LOST1');
				} else if (!isemail($mbr[m_email]))
				{
					msg($mf[m_email][text]."의 메일주소가 잘못되어서 재발급이 불가능합니다.\\n\\n관리자에게 문의하여 주십시오.\\n\\n메일주소 : ".$mbr[m_email], 0);
					movepage($G_SYS['URL_ROOT'].'/member.php?mode=LOST1');
				}	// if()

				if ($mf[m_jumin][isuse] == "Y" && strlen($mbr[m_jumin]) == 14)
				{
					$m_jumin = $m_jumin_1 . "-" . $m_jumin_2;
					if(strcmp($mbr[m_jumin], $m_jumin)) 
					{
						msg($mf[m_jumin][text]."가 일치하지 않습니다.", 0);
						movepage($G_SYS['URL_ROOT'].'/member.php?mode=LOST1');
					}
				}	// if()

				if ($mf[m_lostpwd_q][isuse] == "Y" && strlen($mbr[m_lostpwd_a]) > 0)
				{
					if(strcmp(strtolower(trim($mbr[m_lostpwd_a])), strtolower(trim($m_lostpwd_a))))
					{
						msg($mf[m_lostpwd_a][text]."이 일치하지 않습니다.", 0);
						movepage($G_SYS['URL_ROOT'].'/member.php?mode=LOST1');
					}
				}	// if()

				if ($mf[m_jumin][isuse] != "Y" && $mf[m_lostpwd_q][isuse] != "Y")
				{
					if(strcmp($mbr[m_email], $m_email))
					{
						msg($mf[m_email][text]."가 일치하지 않습니다.", 0);
						movepage($G_SYS['URL_ROOT'].'/member.php?mode=LOST1');
					}
				}	// if()

			// [2006-03-08] 메일서버가 동작중인지 확인
				require_once('include/admin_lib.php');
				mail_server_check_limit();		

			// new password
				$new_pwd = member_new_password($mbr[m_no], $mbr[m_id]);

				// 웹메일용 처리 - 비밀번호만 변경.
					require_once('include/admin_lib.php');
					mbr_mod($mbr['m_id'], $new_pwd);

			// body make
				$mbr[new_date] = date("Y-m-d H:i:s");
				$mbr[new_host] = $_SERVER[REMOTE_ADDR];
				$mbr[new_pwd] = $new_pwd;


				// body
					#$body = file_read("../main/header_mail.inc.html");
					$body = file_read(nskindir('member')."/lost_mail.html");
					#$body .= file_read("../main/footer_mail.inc.html");
					//echo "<hr><xmp>" . $body . "</xmp>";

					// [2009-09-16]메일발송시 본문내에 일부 PHP코드가 보이는 문제 수정
					$body = str_replace('<? if ( !defined("_INCLUDED_GLOBAL") ) exit;		// [Security]Allow_url_fopen = On ?>', '', $body);

					$body = set_text_fetch($body);
					$body = text_fetch("mbr", $mbr, $body);
					//echo "<hr><xmp>" . $body . "</xmp>";
					//echo "<hr>" . $body;


			// mail send
				$hdrs = array();
				$recipients = $mbr[m_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($mbr[m_name], $G_SYS[CHARSET], 'b').'" <'.$mbr[m_email].'>';
				$hdrs["Date"] = date('r');
				$hdrs['Subject'] = mime_encode("[" . $G_SYS[SITE_NAME] . "]" . $mbr[m_name] . "(" . $mbr[m_id] . ")님의 비밀번호 재발급내역입니다.", $G_SYS[CHARSET], 'b');
				$body;
				$body_type = "HTML";
				$file = NULL;
				$file_name = NULL;
				$host = $G_SYS[SMTP_ADDR];
				#echo "<hr><xmp>" . $subject . "</xmp>";
				#echo "<hr>" . $body . "";

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

			// view
				if ($result['issend'])		// 발송 성공 - 보낸편지함에 저장
				{
					msg("비밀번호재발급이 완료되었습니다.\\n\\n아래 메일계정에서 재발급된 비밀번호를 확인하세요.\\n\\n메일주소 :  ". $mbr[m_email], 0);
					movepage($G_SYS['URL_ROOT'].'/index.php');
				} else		// 발송 실패 - 임시 보관함에 저장
				{
					msg("메일발송이 실패하였습니다.\\n\\n관리자에게 문의하여 주십시오.\\n\\n메일주소 : ". $mbr[m_email] . "\\n\\n실패원인 : \\n" . str_replace("'", "", strip_tags($result['error'])), 0);
					movepage($G_SYS['URL_ROOT'].'/index.php');
				}	// if()
			break;


###############################################################################


		case "LOGIN_LIST":
		case "ADMIN_LOGIN_LIST":

			auth_limit("user");
			set_db();


			$CFG[TITLE] = $CFG[TITLE] . " >> <b>로그인내역</b>";


			if ($mode_admin)
			{
				// filed
					$CFG[LIST_FIELD] = array(
							"mll.mll_no" => "번호",
							"m.m_id" => "아이디",
							"m.m_name" => "이름",
							"m.m_email" => "이메일",
							"mll.mll_date" => "로그인일자",
							"mll.mll_host" => "로그인호스트"
							);

					$CFG[SEARCH_FIELD] = $CFG[LIST_FIELD];

				// query
					$q_where = NULL;


			} else
			{
				// filed
					$CFG[LIST_FIELD] = array(
							"mll.mll_no" => "번호",
							"mll.mll_date" => "로그인일자",
							"mll.mll_host" => "로그인호스트"
							);

					$CFG[SEARCH_FIELD] = $CFG[LIST_FIELD];

				// query
					$q_where = " AND mll.m_no='" . $AUTH[auth_m_no] . "' ";

			}	// if()


			// search
				if ($s_word == true)		// search mode
				{
					set_q_search($s_word);

					$q_where .= " AND " . $s_kind . " like '%" . $s_word . "%' ";
					$null_msg = "검색된 내용이 없습니다.";
					$count_msg = "검색된 내용";
				}else		// normal mode
				{
					$null_msg = "등록된 내용이 없습니다.";
					$count_msg = "등록된 내용";
				}	// if()


			// search - default field
				if (!$s_kind) $s_kind = "mll.mll_date";


			// sort
				$q_order = ($s_key) ? " $s_key " : " mll.mll_no ";
				if($s_key2)
				{
					$q_order .=  " $s_key2 ";
					if($s_key2 == "ASC")
					{
						$s_key2_set = "DESC";
					}else
					{
						$s_key2_set = "ASC";
					}
				}else
				{
					$q_order .=  " DESC ";
					$s_key2_set = "ASC";
				}

				$order_field = array_keys($CFG[LIST_FIELD]);
				$order_img = get_order_img($order_field, $s_key, $s_key2);		// array


			// list
				$list_field = array_keys($CFG[LIST_FIELD]);
				$list_text = array_values($CFG[LIST_FIELD]);


			// paging
				require_once("include/page.php");

				$q_count = "
					SELECT
						COUNT(*)
					FROM
						$TB[MEMBER_LOGIN_LOG] mll,
						$TB[MEMBER] d
					WHERE
						1=1
						" . $q_where . "
						AND mll.m_no=d.m_no
						$q_sadmin_as
					";
				$strTrans = "&mode=$mode&" . $b_qs["ADMIN_PAGE"];
				disPgProc($q_count, 20, $strTrans, "DESC");


			// get
				$q = "
					SELECT
						mll.*, m.m_id, m.m_name, m.m_email
					FROM
						$TB[MEMBER_LOGIN_LOG] mll,
						$TB[MEMBER] d
					WHERE
						1=1
						" . $q_where . "
						AND mll.m_no=d.m_no
						$q_sadmin_as
					ORDER BY
						$q_order
					";
				//echo "<HR>" . $q;
				$mll = db_get_rows($q, $limitOffset, $limitRows);


			// set
				$mll_list = $mll;

				if ($mll)
				{
					for($i=0; $i<sizeof($mll); $i++)
					{
						if (!$mode_admin)
						{
							$mll_list[$i][mll_no] = $pageMaxNo - $i;
						}	// if()
						$mll_list[$i][m_email] = get_mailto_url($mll[$i][m_email]);
					}	// for()
				}	// if()

				$v_s_kind = select_list_value($s_kind, array_values($CFG[SEARCH_FIELD]), array_keys($CFG[SEARCH_FIELD]), NULL, 0, 1);
				$v_s_word = input_value($s_word,1);
				$v_rowCount = number_format($rowCount);
				$page_view = disPgCount($whlPgCount, $reqPage, $strTrans, 3, 1);


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

			break;


###############################################################################

# Admin

###############################################################################


		case "ADMIN_LIST":
			// [2008-07-26] 소스 위치 변경
			movepage('admin_mbr_list.php?'.get_qs());
			break;


###############################################################################


		case "ADMIN_DEL_OK":

			auth_limit("admin");
			set_db();

			// [2006-03-08] 메일서버가 동작중인지 확인
				require_once('include/admin_lib.php');
				mail_server_check_limit();		

			if ($mode2 == 'CHK')
			{
				$chk_m_no;
			} else
			{
				$chk_m_no = array();
				$chk_m_no[] = $m_no;
			}	// if()

			for ($i=0; $i<sizeof($chk_m_no); $i++)
			{
				$mbr = member_info($chk_m_no[$i]);		// array

				// [2006-11-02] 관리자모드일때, 관리자는 서버관리자의 정보를 변경할 수 없도록함.
					if ($mbr['m_level'] > $AUTH['auth_m_level'])
						msg("자신보다 높은 [".$G['LEVEL_NAME'][$G['LEVEL']['serveradmin']]."]레벨의 계정은 수정/삭제가 불가능합니다.");

				if ($_GET['mode_sadmin'])
				{
					auth_limit("serveradmin");

					$sql = "SELECT d_name FROM ".$TB['DOMAIN']." WHERE d_no='". $mbr['d_no'] . "'";
					$G_SYS['MAIL_DOMAIN'] = db_get_one($sql);

					$q_sadmin = " AND d_no='".$mbr['d_no']."' ";
				} else
				{
					if ($mbr['d_no'] != $AUTH['auth_d_no'])
						msg("삭제할 수 없는 계정입니다.");
					$q_sadmin = " AND d_no='".$AUTH['auth_d_no']."' ";
				}	// if()

				// proc
					// 웹메일용 처리
						require_once('include/admin_lib.php');
						$mail_file_table = $G_SYS[PRE_FIX] . 'mail_file_' . $mbr['d_no'] . '_' . $mbr['m_mail_file_group'];
						mbr_del($chk_m_no[$i], $mbr['m_id'], $mail_file_table);

					// file delete
						require_once("include/file.php");
						$errorMsg = NULL;
						// 새파일이 업로드되었을때 기존파일 삭제
						$errorMsg .= file_del($mbr[m_file1], $chk_m_no[$i], $UPLOAD_DIR[MEMBER]);
						$errorMsg .= file_del($mbr[m_file2], $chk_m_no[$i], $UPLOAD_DIR[MEMBER]);
						$errorMsg .= file_del($mbr[m_file3], $chk_m_no[$i], $UPLOAD_DIR[MEMBER]);
						$errorMsg .= file_del($mbr[m_file4], $chk_m_no[$i], $UPLOAD_DIR[MEMBER]);
						$errorMsg .= file_del($mbr[m_file5], $chk_m_no[$i], $UPLOAD_DIR[MEMBER]);

					// member
						$q = "DELETE FROM " . $TB['MEMBER'] . " WHERE m_no='" . $chk_m_no[$i] . "'".$q_sadmin;
						db_query($q);
			}	// for()

			// view
				if ($mode2 == 'CHK')
				{
					msg("선택된 메일계정들의 모든 데이타를 삭제하였습니다.", 0);
				} else
				{
					msg("[" . $mbr['m_id'] . "]님의 모든 데이타를 삭제하였습니다.", 0);
				}	// if()
				movepage('admin_mbr_list.php?'.$CFG[QS]['LIST']);

			break;


################################################################################


		case "ADMIN_FIELD":

			auth_limit("admin");

			$CFG[TITLE] = $CFG[TITLE] . " >> <b>가입항목관리</b>";

			// get
				$q = "
					SELECT
						mf.*
					FROM
						$TB[MEMBER_FIELD] mf
					WHERE
						1=1
						AND d_no='".$AUTH['auth_d_no']."'
					ORDER BY
						mf.mbf_step, mf.mbf_no
					";
				//echo "<HR>" . $q;
				$mf = db_get_rows($q);

				if($mf)
				{
					$mbf_view = $mf;
					for($i=0; $i<sizeof($mbf_view); $i++)
					{
						$mbf_view[$i][mbf_text] =  htmlspecialchars_fix($mbf_view[$i][mbf_text]);

						if ($mbf_view[$i][mbf_maxlength] == 0) {
							$mbf_view[$i][mbf_length] = "--<input type='hidden' name='mbf_length[]' value='" . $mbf_view[$i][mbf_length] . "'>";
							$mbf_view[$i][mbf_maxlength] = "--";
						}else {
							$mbf_view[$i][mbf_length] = "<input type='text' name='mbf_length[]' value='" . $mbf_view[$i][mbf_length] . "' size='3' maxlength='5'>";
							$mbf_view[$i][mbf_maxlength];
						}	// if()

						if ($mbf_view[$i][mbf_issystem] == "Y") {
							$mbf_view[$i][mbf_isnotnull] = "--<input type='hidden' name='mbf_isnotnull[]' value='" . $mbf_view[$i][mbf_isnotnull] . "'>";
							$mbf_view[$i][mbf_isuse] = "--<input type='hidden' name='mbf_isuse[]' value='" . $mbf_view[$i][mbf_isuse] . "'>";
						}else {
							$mbf_view[$i][mbf_isnotnull] = "<select name='mbf_isnotnull[]'>" . select_list_value($mbf_view[$i][mbf_isnotnull], array_values($G[ISNOTNULL]), array_keys($G[ISNOTNULL]), NULL, 0, 1) . "</select>";
							$mbf_view[$i][mbf_isuse] = "<select name='mbf_isuse[]'>" . select_list_value($mbf_view[$i][mbf_isuse], array_values($G[ISUSE]), array_keys($G[ISUSE]), NULL, 0, 1) . "</select>";
						}	// if()

						$mbf_view[$i][mbf_islist] = "<select name='mbf_islist[]'>" . select_list_value($mbf_view[$i][mbf_islist], array_values($G[ISLIST]), array_keys($G[ISLIST]), NULL, 0, 1) . "</select>";
						$mbf_view[$i][mbf_issystem] = $G[ISSYSTEM][$mbf_view[$i][mbf_issystem]];

					}	// for()
				}	// if()


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

			break;


###############################################################################


		case "ADMIN_FIELD_OK":

			auth_limit("admin");
			set_db();


			// set
				// query
					for ($i=0; $i<sizeof($mbf_no); $i++)
					{
						to_db_str(&$mbf_text[$i], 255);
					}	// for()


			// proc
				// db update
					for ($i=0; $i<sizeof($mbf_no); $i++)
					{
						$mbf_step[$i] = 0;
						$q = "
							UPDATE
								$TB[MEMBER_FIELD]
							SET
								mbf_step='$mbf_step[$i]',
								mbf_text='$mbf_text[$i]',
								mbf_length='$mbf_length[$i]',
								mbf_isnotnull='$mbf_isnotnull[$i]',
								mbf_isuse='$mbf_isuse[$i]',
								mbf_islist='$mbf_islist[$i]'
							WHERE
								mbf_no='$mbf_no[$i]'
								AND d_no='".$AUTH['auth_d_no']."'
							";
						//echo "<HR>" . $q;
						db_query($q);
					}	// for()


			// view
				msg("회원항목정보가 갱신되었습니다.", 0);
				movepage("member.php?mode=ADMIN_FIELD");


###############################################################################

# Test

###############################################################################


		case "LOST_MAIL_PREVIEW":		// 테스트작업용

			auth_limit("admin");

			// select - member
				$new_pwd = "새비밀번호";


			// view

				$m_id = "admin";
				$m_name = "관리자";
				$new_date = date("Y-m-d H:i:s");
				$new_host = $_SERVER[REMOTE_ADDR];
				$new_pwd = $lost_pwd;

				#include('../main/header_mail.inc.html');
				#include(nskindir('member').'/lost_mail.html');
				#include('../main/footer_mail.inc.html');

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

			break;


###############################################################################


		case "JOIN_MAIL_PREVIEW":		// 테스트작업용

			auth_limit("admin");

			// view
				$m = array();
				$m[m_id] = "admin";
				$m[m_name] = "관리자";

				#include('../main/header_mail.inc.html');
				#include(nskindir('member').'/join_mail.html');
				#include('../main/footer_mail.inc.html');

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

			break;

	}	// switch()


###############################################################################

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