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


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




	if (
		// [2015-04] PHP5.4.x대응 대체함수 적용
		#ereg("^ADMIN_", $mode)
		preg_match("/^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 ($G['DINFO']['d_login_signup'] == 'N') {
				msg("회원가입을 사용할 수 없습니다.\\n\\n관리자에게 문의하여 주십시오.");
			}

			if (!$mode_admin && $G_SYS['SSO_ISUSE'] == 'Y' && $G_SYS['SSO_JOIN_URL'] !== false)		// 외부회원모듈과 연동할 경우.
			{
				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":

			if ($G['DINFO']['d_login_signup'] == 'N') {
				msg("회원가입을 사용할 수 없습니다.\\n\\n관리자에게 문의하여 주십시오.");
			}

			// [2025-12-22] 동의하여 접속한게 아니면 회원가입안내 페이지로 이동
			if (! isset($_COOKIE['nm_terms'])) {
				movepage($nmpath . '/member.php?mode=NOTICE');
			}

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

			if (!$mode_admin && $G_SYS['SSO_ISUSE'] == 'Y' && $G_SYS['SSO_JOIN_URL'] !== false)		// 외부회원모듈과 연동할 경우.
			{
				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":

			if ($G['DINFO']['d_login_profile_edit'] == 'N') {
				msg("개인정보 변경을 사용할 수 없습니다.\\n\\n관리자에게 문의하여 주십시오.");
			}

			auth_limit("user");
			set_db();

			if (!$mode_admin && $G_SYS['SSO_ISUSE'] == 'Y' && $G_SYS['SSO_MODIFY_URL'] !== false)		// 외부회원모듈과 연동할 경우.
			{
				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":
			if ($G['DINFO']['d_login_account_delete'] == 'N') {
				msg("회원탈퇴를 사용할 수 없습니다.\\n\\n관리자에게 문의하여 주십시오.");
			}

			auth_limit("user");
			set_db();

			if (!$mode_admin && $G_SYS['SSO_ISUSE'] == 'Y' && $G_SYS['SSO_OUT_URL'] !== false)		// 외부회원모듈과 연동할 경우.
			{
				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":

			if ($G['DINFO']['d_login_account_recovery'] == 'N') {
				msg("비밀번호 재발급 신청을 사용할 수 없습니다.\\n\\n관리자에게 문의하여 주십시오.");
			}

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

			if (!$mode_admin && $G_SYS['SSO_ISUSE'] == 'Y' && $G_SYS['SSO_PASSWDFIND_URL'] !== false)		// 외부회원모듈과 연동할 경우.
			{
				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();

				if ($mf[m_lostpwd_q][isuse] !== 'Y' || $mf[m_lostpwd_a][isuse] !== 'Y') {
					msg("비밀번호 재발급 질문 또는 답변을 사용하지 않도록 되었습니다.\\n\\n관리자에게 문의하여 주십시오.");
				}

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

			break;


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


		case "LOST2":

			if ($G['DINFO']['d_login_account_recovery'] == 'N') {
				msg("비밀번호 재발급 신청을 사용할 수 없습니다.\\n\\n관리자에게 문의하여 주십시오.");
			}

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

			set_db();

			// get
				$mf = get_member_field();

			// search id
				if ($mf[m_lostpwd_q][isuse] !== 'Y' || $mf[m_lostpwd_a][isuse] !== 'Y') {
					msg("비밀번호 재발급 질문 또는 답변을 사용하지 않도록 되었습니다.\\n\\n관리자에게 문의하여 주십시오.");
				}

				if ($is_search == "Y")
				{
					if ($s_m_email !== '' && $s_m_name !== '') {
						$mbr = member_lost_search($s_m_name, $s_m_jumin1, $s_m_jumin2, $s_m_email);
					} else {
						msg("이름과 보조 E-mail은 필수 입력 항목입니다.\\n\\n관리자에게 문의하여 주십시오.");
					}
				}else
				{
					$query = "m_id='" . $_POST['m_id'] . "'";
					$mbr = member_info_where($query);		// array
				}	// if()

			// view

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

				// [2025-12-22] 비밀번호 재발급 질문이 없을때 사용 불가하도록 제한
				if ($m_lostpwd_q === '' || $m_lostpwd_q === null || $m_lostpwd_a === '' || $m_lostpwd_a === null) {
					msg("비밀번호 재발급 질문 또는 답변이 없으므로 비밀번호를 재발급할 수 없습니다.\\n\\n관리자에게 문의하여 주십시오.");
				}


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

			break;


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

# Process

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


		case "JOIN_OK":

			if ($G['DINFO']['d_login_signup'] == 'N') {
				msg("회원가입을 사용할 수 없습니다.\\n\\n관리자에게 문의하여 주십시오.");
			}

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

					// [2025-09-08] 사번 항목 추가.
					$m_emp_no = to_db_str($m_emp_no, $mf[m_emp_no][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에 저장함.
					// [2015-10-01] upload file 유효성 문제개선
					$m_file1 = $_FILES[m_file1][tmp_name];
					$m_file2 = $_FILES[m_file2][tmp_name];
					$m_file3 = $_FILES[m_file3][tmp_name];
					$m_file4 = $_FILES[m_file4][tmp_name];
					$m_file5 = $_FILES[m_file5][tmp_name];
					$m_file1_dbname = (is_uploaded_file($m_file1)) ? addslashes($_FILES[m_file1][name]) : NULL;
					$m_file2_dbname = (is_uploaded_file($m_file2)) ? addslashes($_FILES[m_file2][name]) : NULL;
					$m_file3_dbname = (is_uploaded_file($m_file3)) ? addslashes($_FILES[m_file3][name]) : NULL;
					$m_file4_dbname = (is_uploaded_file($m_file4)) ? addslashes($_FILES[m_file4][name]) : NULL;
					$m_file5_dbname = (is_uploaded_file($m_file5)) ? addslashes($_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를 사용하여 주십시오.");

					// [2025-12-18] 비밀번호 입력 값 검증 추가 - 비밀번호 일치 여부
					if ($_POST['m_pwd'] !== $_POST['m_pwd2']) {
						msg("비밀번호가 일치하지 않습니다.\\n\\n확인후 다시 입력하여 주십시오.");
					}

					// [2025-12-18] 비밀번호 입력 값 검증 추가 - 안전 레벨에 따른 비밀번호 검증
					$password_security_alert = member_password_security($_POST['m_pwd'], $_POST['m_id']);
					if ($password_security_alert != '')
						msg("입력하신 비밀번호는 사용할 수 없습니다.\\n\\n사유 : ".$password_security_alert);

				// 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($_POST['m_pwd']), stripslashes($m_id));

					$data = array(
						'm_no'              => db_sqc_next($TB['MEMBER'], true),
						'm_id'              => $m_id,
						'm_pwd'             => $m_pwd_enc,
						'm_lostpwd_q'       => $m_lostpwd_q,
						'm_lostpwd_a'       => $m_lostpwd_a,
						'm_level'           => $m_level,
						'm_emp_no'          => $m_emp_no,
						'm_name'            => $m_name,
						'm_last_name'       => $m_last_name,
						'm_email'           => $m_email,
						'm_homepage'        => $m_homepage,
						'm_jumin'           => $m_jumin,
						'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_regdate'         => $m_regdate,
						'm_reghost'         => $m_reghost,
						'm_login_cnt'       => $m_login_cnt,
						'm_last_logindate'  => $m_last_logindate,
						'm_last_loginhost'  => $m_last_loginhost,
						'm_last_modifydate' => $m_last_modifydate,
						'm_last_modifyhost' => $m_last_modifyhost,
						'd_no'              => $dm['d_no'],
						'm_is_use'          => $m_is_use,
						'm_mail_file_group' => $m_mail_file_group,
						'm_quota'           => $m_quota,
						'm_bigfile_quota'   => $m_bigfile_quota,
						'm_webhard_quota'   => $m_webhard_quota,
						'm_last_pwdchgdate' => $m_regdate,
					);

					db_create($TB['MEMBER'], $data);

					$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, $_POST['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":

			if ($G['DINFO']['d_login_profile_edit'] == 'N') {
				msg("개인정보 변경을 사용할 수 없습니다.\\n\\n관리자에게 문의하여 주십시오.");
			}

			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
					$data2 = array();       // 조건에 따라 추가되는 업데이트 데이터

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

					// [2025-09-08] 사번 항목 추가.
					$m_emp_no = to_db_str($m_emp_no, $mf[m_emp_no][length]);

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

                    // [2020-08] KVE 회원정보 변경시 기존 비밀번호 검증
//					$m_pwd_curr = to_db_str($m_pwd_curr, $mf[m_pwd][length]);
//					if ($mbr['m_pwd'] !== pwd_enc(stripslashes($m_pwd_curr), $mbr['m_id'])) {
					// [2025-11-15] 비밀번호 해시 개선
					if ( ! nmail_password_verify(stripslashes($_POST['m_pwd_curr']), $mbr['m_pwd'], $mbr['m_id'], $mbr['m_no'])) {
						msg("입력하신 현재 비밀번호가 일치하지 않습니다.");
					}

					// 새 비밀번호 입력시, 이전 비밀번호 사용 제한
					if ($_POST['m_pwd']) {
						// [2025-12-18] 비밀번호 입력 값 검증 추가 - 비밀번호 일치 여부
						if ($_POST['m_pwd'] !== $_POST['m_pwd2']) {
							msg("비밀번호가 일치하지 않습니다.\\n\\n확인후 다시 입력하여 주십시오.");
						}

						// [2025-12-18] 비밀번호 입력 값 검증 추가 - 안전 레벨에 따른 비밀번호 검증
						$password_security_alert = member_password_security($_POST['m_pwd'], $AUTH['auth_m_id']);
						if ($password_security_alert != '')
							msg("입력하신 비밀번호는 사용할 수 없습니다.\\n\\n사유 : ".$password_security_alert);

						// [2025-11-15] 비밀번호 해시 개선
//						if ($mbr['m_pwd'] !== pwd_enc(stripslashes($m_pwd), $mbr['m_id'])) {
						if (nmail_password_verify(stripslashes($_POST['m_pwd']), $mbr['m_pwd'], $mbr['m_id'], $mbr['m_no'])) {
							msg("현재 비밀번호와 동일할 새 비밀번호는 사용할 수 없습니다.");
						}

						$data2['m_pwd'] = pwd_enc(stripslashes($_POST['m_pwd']), $mbr['m_id']);
						$data2['m_last_pwdchgdate'] = $m_last_modifydate;
					}


				// 업로드 되었을때 새 파일이름을 저장하고, 기존 파일 유지시 기존 파일이름 저장.
					// [2015-10-01] upload file 유효성 문제개선
					$m_file1 = $_FILES[m_file1][tmp_name];
					$m_file2 = $_FILES[m_file2][tmp_name];
					$m_file3 = $_FILES[m_file3][tmp_name];
					$m_file4 = $_FILES[m_file4][tmp_name];
					$m_file5 = $_FILES[m_file5][tmp_name];
					$m_file1_dbname = (is_uploaded_file($m_file1)) ? addslashes($_FILES[m_file1][name]) : $m_file1_old;
					$m_file2_dbname = (is_uploaded_file($m_file2)) ? addslashes($_FILES[m_file2][name]) : $m_file2_old;
					$m_file3_dbname = (is_uploaded_file($m_file3)) ? addslashes($_FILES[m_file3][name]) : $m_file3_old;
					$m_file4_dbname = (is_uploaded_file($m_file4)) ? addslashes($_FILES[m_file4][name]) : $m_file4_old;
					$m_file5_dbname = (is_uploaded_file($m_file5)) ? addslashes($_FILES[m_file5][name]) : $m_file5_old;

					$data = array(
						'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,
					);

					// 사번이 저장되지 않은 경우만, 수정시 입력 가능
					if (($mbr['m_emp_no'] === '' || $mbr['m_emp_no'] === null) && $m_emp_no !== '' && $m_emp_no !== null) {
						$data['m_emp_no'] = $m_emp_no;
					}

					$data = array_merge($data, $data2);

			// proc
				// db update
					db_update($TB[MEMBER], $data, 'm_no = ? AND d_no = ?', array($m_no, $AUTH['auth_d_no']));

				// 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'], $_POST['m_pwd']);

				// [2025-07-29] 메일계정 관리 로그 개선
				mbr_proc_log($mbr['d_no'], $m_no, $mbr['m_id'], 'MODMU');

			// 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":

			if ($G['DINFO']['d_login_account_delete'] == 'N') {
				msg("회원탈퇴를 사용할 수 없습니다.\\n\\n관리자에게 문의하여 주십시오.");
			}

			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("비밀번호가 일치하지 않습니다.");
					// [2025-11-15] 비밀번호 해시 개선
					if ( ! nmail_password_verify(stripslashes($_POST['m_pwd']), $mbr['m_pwd'], $mbr['m_id'], $mbr['m_no'])) {
						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":

			if ($G['DINFO']['d_login_account_recovery'] == 'N') {
				msg("비밀번호 재발급 신청을 사용할 수 없습니다.\\n\\n관리자에게 문의하여 주십시오.");
			}

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

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

			// get
				$mf = get_member_field();

				// [2025-12-22] m_no 대신 m_id 가져오도록 수정
				$query = "m_id='" . $_POST['m_id'] . "'";
				$mbr = member_info_where($query);
//				$mbr = member_info($m_no);		// array

			// check
				if ($mf[m_lostpwd_q][isuse] !== 'Y' || $mf[m_lostpwd_a][isuse] !== 'Y') {
					msg("비밀번호 재발급 질문 또는 답변을 사용하지 않도록 되었습니다.\\n\\n관리자에게 문의하여 주십시오.");
				}

				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관리자에게 문의하여 주십시오.", 0);
					movepage($G_SYS['URL_ROOT'].'/member.php?mode=LOST1');
				}	// if()

				// 비밀번호 재발급 질문 및 답변이 모두 입력된 경우만 일치 여부 검사
				if (
					strlen(trim($mbr[m_lostpwd_q])) === 0
					|| strlen(trim($mbr[m_lostpwd_a])) === 0
					|| strlen(trim($_POST['m_lostpwd_a'])) === 0
					|| strtolower(trim($mbr[m_lostpwd_a])) !== strtolower(trim($_POST['m_lostpwd_a']))
				)
				{
						msg($mf[m_lostpwd_a][text]."이 일치하지 않습니다.", 0);
						movepage($G_SYS['URL_ROOT'].'/member.php?mode=LOST1');
				}

			// [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);

				// [2025-12-22] 비밀번호 재발급 로그
				mbr_proc_log($mbr['d_no'], $mbr['m_no'], $mbr['m_id'], 'LOSTOK');

			// 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;


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

# 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++)
					{
						$mbf_text[$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");
?>