<?php
require ('authentication_member.php');
?>
<?php

/* 取：我的档案 */
/* 162100源码 - 162100.com */



function get_br($str) {
  return preg_replace('/<br(\s*\/)?>/i', "\n", $str);
}


$mess = 0;
if (!isset($sql['db_err'])) {
  db_conn();
}

if ($sql['db_err'] == '') {

  $result = @mysql_query('SELECT * FROM '.$sql['pref'].''.$sql['data']['承载成员档案的表名'].' WHERE username="'.$session[0].'" LIMIT 1', $db);
  if ($row = @mysql_fetch_assoc($result)) {
    if ($row['check_reg'] == '1') {
	  $err = '帐号注册审核中！';
    } elseif ($row['check_reg'] == '2') {
      $err = '帐号已被移除至<a href="list_member.php?act=punished" target="_blank">黑名单</a>！';
    } else {
      $mess = '<span class="grayword">'.preg_replace('/^\d+/', '<span>$0</span>', $row['mess_num']).'</span>';
    }
    $row = array_map('get_br', $row);
  } else {
    $err = '帐号不存在！';
  }
  @mysql_free_result($result);

  require ('inc/function/add_online.php'); //在线

} else {
  $err .= $sql['db_err'];
}

@mysql_close();

if (empty($err)) {
?>
<script language="javascript" type="text/javascript">
<!--
//提交检测
function postChk(theForm){
  var po=theForm.password.value;
  if(po!='' && (po.length>30 || po.length<3)){
    alert('原密码长度是3-30字符！');
	theForm.password.focus();
    return false;
  }
  var pn=theForm.password_new.value;
  if(pn!='' && (pn.length>30 || pn.length<3)){
    alert('新密码长度是3-30字符！');
	theForm.password_new.focus();
    return false;
  }
  if(pn!='' && pn!=theForm.password_again.value){
    alert('两次密码输得不一样！');
	theForm.password_again.focus();
    return false;
  }
  if(theForm.password_question.value.replace(/^[\s\r\n]+|[\s\r\n]+$/,'')==''){
    alert('密码问题不能留空！');
    return false;
  }
  if(theForm.password_answer.value.replace(/^[\s\r\n]+|[\s\r\n]+$/,'')==''){
    alert('密码答案不能留空！');
	theForm.password_answer.focus();
    return false;
  }
  if(theForm.email.value.replace(/^[\s\r\n]+|[\s\r\n]+$/,'')==''){
    alert('email不能留空！');
	theForm.email.focus();
    return false;
  }
  if(!theForm.email.value.match(/^[\w\.\-]+@[\w\-]+\.[\w\.]+$/)){
    alert('email填：xxx@xxx.xxx(.xx) 格式');
	theForm.email.focus();
    return false;
  }
  if(theForm.imcode.value==''){
    alert('验证码不能留空！');
	theForm.imcode.focus();
    return false;
  }
  if(theForm.imcode.value!=getCookie('regimcode')){
    alert('验证码不符！');
	theForm.imcode.focus();
    return false;
  }
  if(theForm.handtel.value.replace(/^[\s\r\n]+|[\s\r\n]+$/,'')!='' && !theForm.handtel.value.replace(/^[\s\r\n]+|[\s\r\n]+$/,'').match(/^\d{11}$/)){
    alert('移动电话请添11位数字！');
	theForm.handtel.focus();
    return false;
  }
  if(theForm.hometel.value.replace(/^[\s\r\n]+|[\s\r\n]+$/,'')!='' && !theForm.hometel.value.replace(/^[\s\r\n]+|[\s\r\n]+$/,'').match(/^\d{3,5}\-\d{5,8}(\-\d{1,5})?$/)){
    alert('办公电话请添“0000-00000000-0000 区号-数字（-分机可选）”格式！');
	theForm.hometel.focus();
    return false;
  }
  if(theForm.zip.value.replace(/^[\s\r\n]+|[\s\r\n]+$/,'')!='' && !theForm.zip.value.replace(/^[\s\r\n]+|[\s\r\n]+$/,'').match(/^\d{6}$/)){
    alert('邮编请添6位数字！');
	theForm.zip.focus();
    return false;
  }
  if(theForm.qq.value.replace(/^[\s\r\n]+|[\s\r\n]+$/,'')!='' && !theForm.qq.value.replace(/^[\s\r\n]+|[\s\r\n]+$/,'').match(/^\d{3,16}$/)){
    alert('QQ请添16位以内数字！');
	theForm.qq.focus();
    return false;
  }
  if(theForm.m!=null && theForm.m.value==1 && $('sendFrame')!=null){
    theForm.target='sendFrame';
  }else{
    theForm.target='_self';
  }
  addSubmitSafe();
  return true;
}

//过滤禁止字符
function chkWord(obj){
  if(obj.value.match(/[ \"\'\\]+/)){
    alert('所填内容不能含 空格 及 \' " \\ ');
    obj.value=obj.value.replace(/[ \"\'\\]+/g,'');
    obj.focus();
  }
}

-->
</script>
<div class="list_title"><a class="list_title_in">修改/完善我的名片</a></div>
<ul class="manager_menu">
  <a href="user.php?get=card&username=<?php echo urlencode($row['username']); ?>" target="_blank">预览我的名片</a><br />
<?php
      echo '该帐号：';
    if (is_array($web['login_key']) && count($web['login_key']) > 0) {
      foreach ($web['login_key'] as $lv) {
        echo '<img src="inc/images/'.$lv.'.png" title="'.$lv.'" />登录 '.(!empty($row['login_key_'.$lv.'']) ? '已绑定 <a href="?post=login&act=del_tie&bar='.$lv.'" target="_self">解除绑定</a>' : '未绑定').'';
        unset($lv);
      }
    }
    echo '<img src="inc/images/162100.png" title="主站（网址导航）" />登录 '.(!empty($row['login_key_162100']) ? '已绑定 <a href="?post=login&act=del_tie&bar=162100" target="_self">解除绑定</a>' : '未绑定').'';
?></ul>



<form action="?post=reg" method="post" enctype="multipart/form-data" id="regform" onsubmit="return postChk(this)" style="text-align:left;">
  <input type="hidden" name="act" value="regfilemodify" /><input type="hidden" name="m" id="m" value="1" />
  <strong>头像（LOGO）</strong><br />
  <table width="100%" border="0" cellspacing="5" cellpadding="0">
    <tr>
      <td width="150" align="right">我的头像（LOGO）：</td>
      <td><?php
//$web['img_name_b'] = '162100userface_'.urlencode($session[0]);
@ require ('inc/set/set_userface.php');
echo '<a href="member.php" target="_blank" title="点击编辑"><span class="iface_s"><img src="obj.php?title=face-'.urlencode($session[0]).'.'.$web['img_up_format'].'" /></span></a>'; ?>
</td>
    </tr>
  </table>
  <br />
  <strong>基本档案</strong>
  <table width="100%" border="0" cellspacing="5" cellpadding="0">
    <tr>
      <td width="150" align="right">用户名：</td>
      <td align="left"><?php echo $row['username']; ?>&nbsp;</td>
    </tr>
    <tr>
      <td width="150" align="right">原密码：</td>
      <td align="left"><input class="large" name="password" type="password" onpropertychange="chkWord(this)" oninput="chkWord(this)" style="width:200px" value="" maxlength="30" /></td>
    </tr>
    <tr>
      <td width="150" align="right">新密码：</td>
      <td align="left"><input class="large" name="password_new" type="password" onpropertychange="chkWord(this)" oninput="chkWord(this)" style="width:200px" value="" maxlength="30" />
      （不填则默认原密码）</td>
    </tr>
    <tr>
      <td width="150" align="right">重输密码：</td>
      <td align="left"><input class="large" name="password_again" type="password" onpropertychange="chkWord(this)" oninput="chkWord(this)" style="width:200px" maxlength="30" /></td>
    </tr>
    <tr>
      <td width="150" align="right">密码保护问题：</td>
      <td align="left">
                  <select name="password_question">
                    <option value="">请选择</option>
                    <option value="1"<?php echo $row['password_question'] == 1 ? ' selected="selected"' : ''; ?>>您的宠物的名字</option>
                    <option value="2"<?php echo $row['password_question'] == 2 ? ' selected="selected"' : ''; ?>>您就读的第一所学校的名字</option>
                    <option value="3"<?php echo $row['password_question'] == 3 ? ' selected="selected"' : ''; ?>>您最喜欢的休闲运动是什么</option>
                    <option value="4"<?php echo $row['password_question'] == 4 ? ' selected="selected"' : ''; ?>>您最喜欢的运动员是谁</option>
                    <option value="5"<?php echo $row['password_question'] == 5 ? ' selected="selected"' : ''; ?>>您的体重是多少公斤</option>
                    <option value="6"<?php echo $row['password_question'] == 6 ? ' selected="selected"' : ''; ?>>您其中一位老师的名字</option>
                    <option value="7"<?php echo $row['password_question'] == 7 ? ' selected="selected"' : ''; ?>>您的身高是多少CM</option>
                  </select>
      </td>
    </tr>
    <tr>
      <td width="150" align="right">答案：</td>
      <td align="left"><input class="large" name="password_answer" type="text" onpropertychange="chkWord(this)" oninput="chkWord(this)" style="width:200px" value="<?php echo $row['password_answer']; ?>" maxlength="255" /></td>
    </tr>
    <tr>
      <td width="150" align="right">邮箱：</td>
      <td align="left"><input class="large" name="email" type="text" onpropertychange="chkWord(this)" oninput="chkWord(this)" style="width:200px" value="<?php echo $row['email']; ?>" maxlength="255" /></td>
    </tr>
  </table>
  <br />
  <strong id="my_company">联系方式</strong>
  <table width="100%" border="0" cellspacing="5" cellpadding="0">
    <tr>
      <td width="150" align="right">真实姓名：</td>
      <td align="left"><input class="large" name="realname" type="text" onpropertychange="chkWord(this)" oninput="chkWord(this)" style="width:200px" value="<?php echo $row['realname']; ?>" maxlength="64" /></td>
    </tr>
    <tr>
      <td width="150" align="right">性别：</td>
      <td align="left"><table border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="20"><input name="sex" type="radio" class="radio" value="先生" id="man"<?php echo $row['sex'] == '先生' ? ' checked' : ''; ?> /></td>
          <td width="90"><label for="man">先生</label></td>
          <td width="20"><input name="sex" type="radio" class="radio" value="女士" id="woman"<?php echo $row['sex'] == '女士' ? ' checked' : ''; ?> /></td>
          <td width="90"><label for="woman">女士</label></td>
        </tr>
      </table></td>
    </tr>
    <tr>
      <td width="150" align="right">出生日期：</td>
      <td align="left"><input class="large" name="birthday" type="text" onpropertychange="chkWord(this)" oninput="chkWord(this)" style="width:200px" value="<?php echo $row['birthday']; ?>" maxlength="255" />
      请添“2011/01/01”格式</td>
    </tr>
    <tr>
      <td width="150" align="right">移动电话：</td>
      <td align="left"><input class="large" name="handtel" type="text" onpropertychange="chkWord(this)" oninput="chkWord(this)" style="width:200px" value="<?php echo $row['handtel']; ?>" maxlength="16" /></td>
    </tr>
    <tr>
      <td width="150" align="right">办公电话：</td>
      <td align="left"><input class="large" name="hometel" type="text" onpropertychange="chkWord(this)" oninput="chkWord(this)" style="width:200px" value="<?php echo $row['hometel']; ?>" maxlength="20" />
      请添“0000-00000000-0000 区号-数字（-分机可选）”格式</td>
    </tr>
    <tr>
      <td width="150" align="right">ＱＱ：</td>
      <td align="left"><input class="large" name="qq" type="text" onpropertychange="chkWord(this)" oninput="chkWord(this)" style="width:200px" value="<?php echo $row['qq']; ?>" maxlength="16" /></td>
    </tr>
  </table>
  <br />
  <strong>我的商号</strong>
  <table width="100%" border="0" cellspacing="5" cellpadding="0">
    <tr>
      <td width="150" align="right">公司名称：</td>
      <td align="left"><input class="large" name="company" type="text" onpropertychange="chkWord(this)" oninput="chkWord(this)" style="width:200px" value="<?php echo $row['company']; ?>" maxlength="255" /></td>
    </tr>
    <tr>
      <td width="150" align="right">公司简介：</td>
      <td align="left"><textarea name="company_description" onpropertychange="chkWord(this)" oninput="chkWord(this)" cols="30" rows="4" maxlength="500"><?php echo $row['company_description']; ?></textarea></td>
    </tr>
    <tr>
      <td width="150" align="right">地址：</td>
      <td align="left"><input class="large" name="address" type="text" onpropertychange="chkWord(this)" oninput="chkWord(this)" style="width:200px" value="<?php echo $row['address']; ?>" maxlength="255" /></td>
    </tr>
    <tr>
      <td width="150" align="right">邮编：</td>
      <td align="left"><input class="large" name="zip" type="text" onpropertychange="chkWord(this)" oninput="chkWord(this)" style="width:200px" value="<?php echo $row['zip']; ?>" maxlength="6" /></td>
    </tr>
    <tr>
      <td width="150" align="right">网址：</td>
      <td align="left"><input class="large" name="sign" type="text" onpropertychange="chkWord(this)" oninput="chkWord(this)" style="width:200px" value="<?php echo $row['sign']; ?>" maxlength="255" /></td>
    </tr>
    <tr>
      <td width="150" align="right">验证码：</td>
      <td align="left"><table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td style="width:130px"><input class="large" name="imcode" type="text" style="width:120px" maxlength="6" /></td>
    <td><iframe src="inc/js/imcode.html" id="imFrame" name="imFrame" width="95" height="18" frameborder="0" marginwidth="0" marginheight="0" scrolling="No" allowtransparency="true"></iframe></td>
  </tr>
</table></td>
    </tr>
  </table>
<iframe id="sendFrame" name="sendFrame" frameborder="0" style="width:100%;height:30px;display:none;"></iframe>
  <table width="100%" border="0" cellspacing="5" cellpadding="0">
    <tr>
      <td width="150" align="right">&nbsp;</td>
      <td><button class="large" name="submit" type="submit"><b>修改</b></button>
          <button class="large" name="reset" type="reset"><b>重置</b></button></td>
    </tr>
  </table>
</form>
<?php
} else {
  echo $err;
}
?>
