<?
if (!defined("_GNUBOARD_")) exit;
if(!$is_member) alert("회원만 접근 가능합니다.", "./login.php?url=zm.userinfo.php?pcd=profile");

//-- 로그인 돼 있을 때 회원정보 관리 메뉴 포함
if($is_member) include_once($member_skin_path."/zm.userinfo_menu.skin.php");

//-- 스킨 시작 ↓ --------------------------------
?>

<style type="text/css">
<!--
.m_title		{ width:130px; BACKGROUND-COLOR: #F7F7F7; PADDING-LEFT: 15px; PADDING-top: 5px; PADDING-BOTTOM: 5px; }
.m_padding		{ PADDING-LEFT: 15px; PADDING-BOTTOM: 5px; PADDING-TOP: 5px; }
.m_padding2		{ PADDING-LEFT: 0px; PADDING-top: 5px; PADDING-BOTTOM: 0px; }
.m_padding3		{ PADDING-LEFT: 0px; PADDING-top: 5px; PADDING-BOTTOM: 5px; }

.txtmsg			{ font-size:11px; line-height:150%; font-family:돋움; padding:5px 0 0 5px; color:#A0A0A0; }
.picinput		{ width:200px; }
.picout			{ width:200px; height:130px; background-image:url('<?=$member_skin_path?>/img/img_nopic.gif'); background-repeat:no-repeat; background-position:50% 50%; }

#myprofilepic	{ width:110px; height:110px; background-image:url('<?=$profilepic?>'); background-repeat:no-repeat; background-position:50% 50%; }
-->
</style>

<script>
var member_skin_path = "<?=$member_skin_path?>";
</script>
<script type="text/javascript" src="<?=$member_skin_path?>/ajax_register_form.jquery.js"></script>
<script type="text/javascript" src="<?=$g4[path]?>/js/md5.js"></script>
<script type="text/javascript" src="<?=$g4[path]?>/js/sideview.js"></script>

<form id="fregisterform" name=fregisterform method=post onsubmit="return fregisterform_submit(this);" enctype="multipart/form-data" autocomplete="off">
<input type=hidden name=mode             value="profileupdate">
<input type=hidden name=url              value="zm.userinfo.php?pcd=profile">
<input type=hidden name=mb_id_enabled    value="" id="mb_id_enabled">
<input type=hidden name=mb_nick_enabled  value="" id="mb_nick_enabled">
<input type=hidden name=mb_email_enabled value="" id="mb_email_enabled">
<!-- <input type=hidden name=token value="<?=$token?>"> -->

<div style="text-align:center;"><img src="<?=$member_skin_path?>/img/profile_title.gif"></div>

<table width="880" cellspacing="0" cellpadding="0" align="center">
<tr>
    <td bgcolor="#CCCCCC">
        <TABLE cellSpacing=1 cellPadding=0 width=100%>
<? if ($member[mb_nick_date] <= date("Y-m-d", $g4[server_time] - ($config[cf_nick_modify] * 86400))) { // 별명수정일이 지났다면 수정가능
		$strread	= "";
} else { 
		$strread	= "readonly";
?>
        <input type=hidden name="mb_nick_default" value='<?=$member[mb_nick]?>'>
        <input type=hidden name="mb_nick" value="<?=$member[mb_nick]?>">
<? } ?>
        <input type=hidden name=mb_nick_default value='<?=$member[mb_nick]?>'>
        <TR bgcolor="#FFFFFF">
            <TD class=m_title>별명</TD>
            <TD class='m_padding lh'>
                <input class=ed type=text id='reg_mb_nick' name='mb_nick' maxlength=20 value='<?=$member[mb_nick]?>'
                    onblur="reg_mb_nick_check();" <?=$strread?> required>
                <span id='msg_mb_nick'></span>
				<div class="txtmsg">공백없이 한글,영문,숫자만 입력 가능 (한글2자, 영문4자 이상)
                <br>별명을 바꾸시면 앞으로 <?=(int)$config[cf_nick_modify]?>일 이내에는 변경 할 수 없습니다. (마지막 변경일 : <?=$member[mb_nick_date]?>)</div>
            </TD>
        </TR>
<? if ($w=="") { ?>
            <TR bgcolor="#FFFFFF">
                <TD class=m_title>생년월일</TD>
                <TD class=m_padding><select name='mb_birth_y' id='mb_birth_y'>
				<option value=""> 년</option>
<?			for($y = date("Y")-10; $y >= date("Y")-90; $y--) : ?>
				<option value="<?=$y?>" <?=($zm_member[birth_y]==$y)?'selected':''?>><?=$y?></option>
<?			endfor; ?>
				</select>
				<select name='mb_birth_m' id='mb_birth_m'>
				<option value=""> 월</option>
<?			for($m = 1; $m <= 12; $m++) : ?>
				<option value="<?=$m?>" <?=($zm_member[birth_m]==$m)?'selected':''?>><?=zm_paste0($m)?></option>
<?			endfor; ?>
				</select>
				<select name='mb_birth_d' id='mb_birth_d'>
				<option value=""> 일</option>
<?			for($d = 1; $d <= 31; $d++) : ?>
				<option value="<?=$d?>" <?=($zm_member[birth_d]==$d)?'selected':''?>><?=zm_paste0($d)?></option>
<?			endfor; ?>
				</select>
            </TR>
<? } ?>
		<TR bgcolor="#FFFFFF">
                <TD class=m_title>프로필 사진</TD>
                <TD class=m_padding>
				<table>
				<tr>
					<td width="130"><div id="myprofilepic"></div></td>
					<td><input type="file" id=in_profile_pic name=in_profile_pic class="picinput" style="width:300px;">
					<div class="txtmsg">사진이 음란/불법/폭력 및 기타 문제가 있는 경우 <br>삭제 될 수 있습니다. (권장 크기 110px X 110px)</div></td>
				</tr>
				</table>
                </td>
        </TR>
<? if ($member[mb_sex]) { ?>
            <input type=hidden name=mb_sex value='<?=$member[mb_sex]?>'>
<? } else { ?>
        <TR bgcolor="#FFFFFF">
			<TD class=m_title>성별</TD>
            <TD class=m_padding>
<?				$sexchk		= array();
				if($member[mb_sex] == "M") $sexchk[0]	= "checked";
				if($member[mb_sex] == "F") $sexchk[1]	= "checked";
				if($member[mb_sex] == "")  $sexchk[2]	= "checked";
?>
				<input type="radio" id=mb_sex name=mb_sex value='M' <?=$sexchk[0]?>>남자
				<input type="radio" id=mb_sex name=mb_sex value='F' <?=$sexchk[1]?>>여자
				<input type="radio" id=mb_sex name=mb_sex value='' <?=$sexchk[2]?>>비공개
			</td>
        </TR>
<? } ?>
		<TR bgcolor="#FFFFFF">
                <TD class=m_title>혈액형</TD>
                <TD class=m_padding>
                    <input type="text" class=ed name=in_bloodtype size="4" maxlength="4" value="<?=$zm_member[bloodtype]?>"> 형
                </td>
        </TR>
<? if ($config[cf_use_homepage]) { ?>
        <TR bgcolor="#FFFFFF">
            <TD class=m_title>홈페이지</TD>
            <TD class=m_padding><input class=ed type=text name='mb_homepage' size=38 maxlength=255 <?=$config[cf_req_homepage]?'required':'';?> itemname='홈페이지' value='<?=(strlen($member[mb_homepage]) <= 7)?'http://':$member[mb_homepage];?>'></TD>
        </TR>
<? } ?>
<? if($zm_config[mylocal]) : ?>
		<TR bgcolor="#FFFFFF">
            <TD class=m_title>자주 접속하는 지역</TD>
            <TD valign="middle" class=m_padding><select name='in_mylocal2' onChange="loadlocal(this.value)">
			<option value="">선택</option>
<?		for($i = 0; $i < count($ar_local); $i++) : ?>
			<option value='<?=$ar_local[$i]?>' <?=($mylocation[0]==$ar_local[$i])?'selected':''?>><?=$ar_local[$i]?></option>
<?		endfor; ?>
			</select>
			<span id="mylocal">
			<select name='in_mylocal'>
			<option>지역 선택</option>
		<?=($mylocation[1])?"<option selected>$mylocation[1]</option>":""?>
			</select></span></td>
        </TR>
<? endif; ?>
		<TR bgcolor="#FFFFFF">
            <TD class=m_title>소속</TD>
            <TD valign="middle" class=m_padding><input class=ed type=text name='in_belong' size=30 value="<?=$zm_member[belong]?>"></td>
        </TR>
		<TR bgcolor="#FFFFFF">
            <TD class=m_title>학교</TD>
            <TD valign="middle" class=m_padding><input class=ed type=text name='in_school1' size=30 value="<?=$zm_member[school1]?>"> 입학년도 : <select name='in_iphak1'>
<?			for($y = date("Y"); $y >= date("Y")-90; $y--) : ?>
				<option <?=($zm_member[iphak1]==$y)?'selected':''?>><?=$y?></option>
<?			endfor; ?>
				</select><br><input class=ed type=text name='in_school2' size=30 value="<?=$zm_member[school2]?>"> 입학년도 : <select name='in_iphak2'>
<?			for($y = date("Y"); $y >= date("Y")-90; $y--) : ?>
				<option <?=($zm_member[iphak2]==$y)?'selected':''?>><?=$y?></option>
<?			endfor; ?>
				</select><br>
			<input class=ed type=text name='in_school3' size=30 value="<?=$zm_member[school3]?>"> 입학년도 : <select name='in_iphak3'>
<?			for($y = date("Y"); $y >= date("Y")-90; $y--) : ?>
				<option <?=($zm_member[iphak3]==$y)?'selected':''?>><?=$y?></option>
<?			endfor; ?>
				</select></td>
        </TR>
        </TABLE>
    </td>
</tr>
</table>
<p>
<table width="880" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
    <td bgcolor="#CCCCCC">
        <TABLE cellSpacing=1 cellPadding=0 width=100%>
<? if ($config[cf_use_signature]) { ?>
        <TR bgcolor="#FFFFFF">
            <TD class=m_title>서명</TD>
            <TD class=m_padding><input name=mb_signature class=ed style='width:95%;' <?=$config[cf_req_signature]?'required':'';?> itemname='서명' value='<?=$member[mb_signature]?>'></TD>
        </TR>
<? } ?>
<? if ($config[cf_use_profile]) { ?>
        <TR bgcolor="#FFFFFF">
            <TD class=m_title>자기소개</TD>
            <TD class=m_padding><textarea name=mb_profile class=tx rows=3 style='width:95%;' <?=$config[cf_req_profile]?'required':'';?> itemname='자기 소개'><?=$member[mb_profile]?></textarea></TD>
        </TR>
<? } ?>
		<TR bgcolor="#FFFFFF">
            <TD class=m_title>소셜 링크</TD>
            <TD valign="middle" class=m_padding>
			<table cellpadding=0><tr>
				<td><input type="checkbox" name="sns_link1" value="1" <?=($zm_member[sns_link_f])?"checked":""?>></td><td><img src="<?=$member_skin_path?>/img/sns_f.gif"></td>
				<td><input type="checkbox" name="sns_link2" value="1" <?=($zm_member[sns_link_t])?"checked":""?>></td><td><img src="<?=$member_skin_path?>/img/sns_t.gif"></td>
				<td><input type="checkbox" name="sns_link3" value="1" <?=($zm_member[sns_link_y])?"checked":""?>></td><td><img src="<?=$member_skin_path?>/img/sns_y.gif"></td>
				<td><input type="checkbox" name="sns_link4" value="1" <?=($zm_member[sns_link_m])?"checked":""?>></td><td><img src="<?=$member_skin_path?>/img/sns_m.gif"></td>
			</tr></table>
			</td>
        </TR>
<? if ($member[mb_open_date] <= date("Y-m-d", $g4[server_time] - ($config[cf_open_modify] * 86400))) { // 정보공개 수정일이 지났다면 수정가능 ?> 
        <input type=hidden name=mb_open_default value='<?=$member[mb_open]?>'> 
        <TR bgcolor="#FFFFFF"> 
            <TD class=m_title>프로필 공개</TD> 
            <TD class=m_padding><div class="txtmsg"><input type=checkbox name=mb_open value='1' <?=$chk_profile_open?>> 프로필 공개를 하지 않은 회원은 타 회원의 정보를 확인 할 수 없습니다. 프로필 공개를 바꾸시면 <?=(int)$config[cf_open_modify]?>일 후 변경 가능합니다.(마지막 변경일:<?=$member[mb_open_date]?>)</div></td> 
        </TR> 
<? } else { ?> 
        <input type=hidden name="mb_open" value="<?=$member[mb_open]?>"> 
        <TR bgcolor="#FFFFFF"> 
            <TD class=m_title>프로필 공개</TD> 
            <TD class=m_padding><div class="txtmsg">
                정보공개는 수정후 <?=(int)$config[cf_open_modify]?>일 이내, <?=date("Y년 m월 j일", strtotime("$member[mb_open_date] 00:00:00") + ($config[cf_open_modify] * 86400))?> 까지는 변경이 안됩니다.<br>잦은 정보공개 수정으로 인하여 쪽지를 보낸 후 받지 않는 경우를 막기 위해서 입니다.</div></div>
            </td> 
        </tr> 
<? } ?> 
        </TABLE>
    </td>
</tr>
</table>
<p align=center><INPUT type=image src="<?=$member_skin_path?>/img/join_ok_btn.gif" border=0 accesskey='s'></p>
</form>


<script type="text/javascript" src="<?="$g4[path]/js/jquery.kcaptcha.js"?>"></script>
<script type="text/javascript">
// submit 최종 폼체크
function fregisterform_submit(f) 
{
    // 별명 검사
    if ((f.mode.value == "profileupdate") && (f.mb_nick.defaultValue != f.mb_nick.value)) {

        reg_mb_nick_check();

        if (document.getElementById('mb_nick_enabled').value!='000') {
            alert('별명을 입력하지 않았거나 입력에 오류가 있습니다.');
            document.getElementById('reg_mb_nick').select();
            return false;
        }
    }

    if (typeof(f.mb_birth) != 'undefined') {
        if (f.mb_birth.value.length < 1) {
            alert('생일을 입력하여 주십시오.');
            return false;
        }
    }

    if (typeof(f.mb_sex) != 'undefined') {
        if (f.mb_sex.value == '') {
            alert('성별을 선택하여 주십시오.');
            f.mb_sex.focus();
            return false;
        }
    }

    <?
    if ($g4[https_url])
        echo "f.action = '$g4[https_url]/$g4[bbs]/zm.userinfo_update.php';";
    else
        echo "f.action = './zm.userinfo_update.php';";
    ?>

    // 보안인증관련 코드로 반드시 포함되어야 합니다.
    set_cookie("<?=md5($token)?>", "<?=base64_encode($token)?>", 1, "<?=$g4['cookie_domain']?>");

    return true;
}

// 금지 메일 도메인 검사
function prohibit_email_check(email)
{
    email = email.toLowerCase();

    var prohibit_email = "<?=trim(strtolower(preg_replace("/(\r\n|\r|\n)/", ",", $config[cf_prohibit_email])));?>";
    var s = prohibit_email.split(",");
    var tmp = email.split("@");
    var domain = tmp[tmp.length - 1]; // 메일 도메인만 얻는다

    for (i=0; i<s.length; i++) {
        if (s[i] == domain)
            return domain;
    }
    return "";
}

//-- 지역 선택 불러오기
function loadlocal(l) {
	 $.ajax({
            type	: "POST",
            url		: "zm.userinfo_local.php",
			data	: {'local':l},
            success	: function(data){
                $('#mylocal').html(data);
            }
       });
}

</script>
