<?
include_once("./_common.php");

// 불법접근을 막도록 토큰생성
$token = md5(uniqid(rand(), true));
set_session("ss_token", $token);

include_once("./_head.php");
include_once("./norobot.inc.php"); // 자동등록방지

$sw_mem		= 1;						//-- 0:비회원 접근 가능, 1:회원만 접근 가능

// 회원아이콘 경로
$mb_icon = "$g4[path]/data/member/".substr($member[mb_id],0,2)."/$member[mb_id].gif";
$member_skin_path = "$g4[path]/".ZM_SKIN_DIR."/member/$config[cf_member_skin]";

//-- 로그인 기록
if($pcd == "log")	{
	$res			= sql_query("select db_recno from zm_login_log where db_id='$member[mb_id]'");
	$total_count	= mysql_num_rows($res);

	$page_rows		= 20;									//-- 한 페이지에 20 줄씩 보임
	$total_page		= ceil($total_count / $page_rows);		//-- 전체 페이지 계산
	if(!$page)		$page = 1;								//-- 페이지가 없으면 첫 페이지 (1 페이지)
	$from_record	= ($page - 1) * $page_rows;				//-- 시작 열을 구함

	$rows			= sql_query("select * from zm_login_log where db_id='$member[mb_id]' order by db_date desc limit $from_record, $page_rows");
	$i				= 0;
	while($res = sql_fetch_array($rows)) {
		$loglist[$i]	= zm_getloglist($res);
		$i++;
	}

	$write_logpage	= get_paging($config[cf_write_pages], $page, $total_page, "./zm.userinfo.php?pcd=log".$qstr."&page=");
}

//-- 비밀번호 변경
if($pcd == "pwmodify") {
	if($is_admin) alert("관리자 정보는 관리자 페이지에서 변경하시기 바랍니다.");
}



//-- 아이디 찾기
if($mode == "idfind") {
	$sw_mem	= 0;

	$res	= sql_fetch("select mb_id, mb_level from $g4[member_table] where mb_name='$mb_name' and mb_email='$mb_email'");

	if($res[mb_id] && ($res[mb_level] < 10)) { 
		$findid		= substr($res[mb_id], 0, strlen($res[mb_id])-2) . "**"; 
		$pcd		= "idfind_res"; 
		zm_write_login($res[mb_id], "$url", "ID 찾기", "성공");
	}else{
		alert("잘 못 된 정보입니다.");
		zm_write_login($res[mb_id], "$url", "ID 찾기", "실패");
	}
}

//-- 비번찾기
if($mode == "findpw") { 
	$sw_mem	= 0;
	include_once("./zm.userinfo_pwfind_res.php"); 
	$pcd	= "pwfind_res"; 
	zm_write_login($mb[mb_id], "$url", "비번찾기", "실행");
}

//-- 탈퇴 회원 재가입
if($mode == "reentry") { 
	$sw_mem	= 0;
	include_once("./zm.userinfo_pwfind_res.php"); 
	$pcd	= "pwfind_res"; 
	zm_write_login($mb[mb_id], "$url", "재가입", "실행");
}

//-- 프로필 보기 선행 처리 ----------------------
if($pcd == "profile") {
	$zipfile	= array();
	$fp			= fopen("./zm.local.db", "r");
	while(!feof($fp)) { $zipfile[] = fgets($fp, 1024); }
	fclose($fp);

	$k			= 0;
	$ar_local	= array();
	$ar_loca2	= array();
	while ($zipcode = each($zipfile)) {
		$tmp			= explode(" ", $zipcode[1]);
		$ar_local[$k]	= $tmp[0];
		if($ar_local[$k] != $ar_local[$k-1]) {
			$ar_local[$k]	= $tmp[0];
			$k++;
		}
	}

	$tmpbirth	= explode("-", $member[mb_birth]);
	$zm_member[birth_y]	= $tmpbirth[0];
	$zm_member[birth_m]	= $tmpbirth[1];
	$zm_member[birth_d]	= $tmpbirth[2];

	$mylocation		= explode(" ", $zm_member[location]);

	if($member[mb_open]) $chk_profile_open = "checked"; else $chk_profile_open = "";

	//-- 프로필 사진
	if($zm_member[profile_pic]) $profilepic		= $g4[path]."/data/zm.exp/profile/" . $zm_member[profile_pic];
	else						$profilepic		= $member_skin_path."/img/img_nopic.gif";

}

//-- 공개 범위 --------------------------------------
if($pcd == "public") {
	//-- 공개 설정 선택 값
	$chk_open_level	= array();							//-- 공계 수준
	$elem_idx		= $zm_member[profile_open_level];
	if(!$elem_idx) $elem_idx	= "1";
	$chk_open_level[$elem_idx]	= "checked";

	$chk_open_condition	= array();						//-- 공개 조건
	$elem_idx		= $zm_member[profile_open_condition];
	if(!$elem_idx || ($member[mb_open] && $elem_idx=="3")) $elem_idx = "1";
	$chk_open_condition[$elem_idx]	= "checked";
}

include_once("$zms[member_path]/head.skin.php");
include_once("$member_skin_path/zm.userinfo_".$pcd.".skin.php");
include_once("$zms[member_path]/tail.skin.php"); 
include_once("./_tail.php");
?>