<?php

/* 找回密码 */
/* 162100源码 - 162100.com - download.162100.com */

$title = '找回密码';

@ require ('inc/set/set.php');
@ require ('inc/set/set_sql.php');
@ require ('inc/function/confirm_power.php');
//身份验证
define('POWER', confirm_power());

if (POWER >= 1) {
  $userface = user_class(POWER, $session[3]);
} else {
}



if (empty($_GET['type'])) {
  $text = '<h3><a href="?type=question">密保方式重置密码</a></h3> <h3><a href="?type=mail">发送到邮箱方式</a></h3>';
} else {
  if ($_GET['type'] == 'question') {
    $_GET['username'] = strtolower(trim($_GET['username']));
    if (empty($_GET['username'])) {
      $text = '<form name="forpasswordform" id="forpasswordform" action="?" method="get">帐号：<input name="username" class="username" type="text" onpropertychange="chkWord(this)" oninput="chkWord(this)" style="width:200px" /><input name="type" type="hidden" value="question" /> <button type="submit"><b>提交</b></button></form>';
	} elseif ($_GET['username'] == $web['manager']) {
	  $text = '禁止以管理员名义进行此操作！';
	} else {
      if (!isset($sql['db_err'])) {
        db_conn();
      }
      if ($sql['db_err'] != '') {
        die($sql['db_err']);
      }
      $result = @mysql_query('SELECT * FROM `'.$sql['pref'].''.$sql['data']['承载成员档案的表名'].'` WHERE username="'.str_replace('.', '&#46;', $_GET['username']).'" OR email="'.$_GET['username'].'" LIMIT 1', $db);
      if (!$row = mysql_fetch_assoc($result)) {
        $text = '出错！数据库中查无此用户！点此可<a href="javascript:window.history.back();"><u>返回</u></a><form name="forpasswordform" id="forpasswordform" action="?" method="get">请输入用户名：<input name="username" type="text" onpropertychange="chkWord(this)" oninput="chkWord(this)" style="width:200px" /><input name="type" type="hidden" value="question" /> <button type="submit"><b>提交</b></button></form>';

      } else {
        $text = '
          <form id="regform" name="regform" method="post" action="member.php?post=login" onsubmit="return postChk(this)">
            <input type="hidden" name="act" value="foundpassword" />
			<input name="type" type="hidden" value="question" />
            <input name="username" value="'.$_GET['username'].'" type="hidden" />
            <table cellspacing="5" border="0" cellpadding="0" width="100%">
              <tr>
                <td width="150" align="right">帐号：</td>
                <td align="left">'.$_GET['username'].'</td>
              </tr>
              <tr>
                <td width="150" align="right">密码保护问题：</td>
                <td align="left">
                    <select name="password_question">
                      <option value="">请选择</option>
                      <option value="1"'.($row['password_question'] == 1 ? ' selected="selected"' : '').'>您的宠物的名字</option>
                      <option value="2"'.($row['password_question'] == 2 ? ' selected="selected"' : '').'>您就读的第一所学校的名字</option>
                      <option value="3"'.($row['password_question'] == 3 ? ' selected="selected"' : '').'>您最喜欢的休闲运动是什么</option>
                      <option value="4"'.($row['password_question'] == 4 ? ' selected="selected"' : '').'>您最喜欢的运动员是谁</option>
                      <option value="5"'.($row['password_question'] == 5 ? ' selected="selected"' : '').'>您的体重是多少公斤</option>
                      <option value="6"'.($row['password_question'] == 6 ? ' selected="selected"' : '').'>您其中一位老师的名字</option>
                      <option value="7"'.($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" maxlength="200" /></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>
              <tr>
                <td width="150" align="right">&nbsp;</td>
                <td align="left"><button class="large" type="submit"><b>提交</b></button>
                    <button class="large" type="reset"><b>重置</b></button>
                  <a href="login.php">返回登陆</a></td>
              </tr>
            </table>
          </form>
         ';
	  }
      @mysql_free_result($result);
	}
  } elseif ($_GET['type'] == 'mail') {
    $text = '
          <form id="regform" name="regform" method="post" action="member.php?post=login" onsubmit="return postChk(this)">
            <input type="hidden" name="act" value="foundpassword" />
			<input name="type" type="hidden" value="mail" />
            <table cellspacing="5" border="0" cellpadding="0" width="100%">
              <tr>
                <td width="150" align="right">帐号：</td>
                <td align="left"><input class="large username" name="username" type="text" onpropertychange="chkWord(this)" oninput="chkWord(this)" style="width:200px" maxlength="200" /></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>
              <tr>
                <td width="150" align="right">&nbsp;</td>
                <td align="left"><button class="large" type="submit"><b>提交</b></button>
                    <button class="large" type="reset"><b>重置</b></button>
                  <a href="login.php">返回登陆</a></td>
              </tr>
            </table>
          </form>
         ';    
  } else {
    $text = '方式错误！';
  }
}
@ require ('inc/function/add_online.php'); //在线

@mysql_close();

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $title, $web['code_author']; ?></title>
<link id="my_style" rel="stylesheet" type="text/css" href="inc/css/<?php echo $web['sitemode']; ?>/style.css">
<style type="text/css">
<!--
.username { background-image:url(inc/images/login_bj.gif); background-position:5px 50%; background-repeat:no-repeat; }
-->
</style>
<script language="javascript" src="inc/js/main.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
<!--
function postChk(theForm){
  if(theForm.password_answer.value.replace(/^(\s+|　+)|(\s+|　+)$/,'')==''){
    alert('密码答案不能留空！');
	theForm.password_answer.focus();
    return false;
  }
  if(theForm.email.value.replace(/^(\s+|　+)|(\s+|　+)$/,'')==''){
    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;
  }
  var pn=theForm.password_new.value;
  if(pn.length>30 || pn.length<3){
    alert('密码长度是3-30字符！');
	theForm.password_new.focus();
    return false;
  }
  if(theForm.password_again.value==''){
    alert('密码重输不能留空！');
	theForm.password_again.focus();
    return false;
  }
  if(pn!=theForm.password_again.value){
    alert('两次密码输得不一样！');
	theForm.password_again.focus();
    return false;
  }
  if(theForm.imcode.value.replace(/^(\s+|　+)|(\s+|　+)$/,'')==''){
    alert('验证码不能留空！');
	theForm.imcode.focus();
    return false;
  }
  if(theForm.imcode.value.replace(/^(\s+|　+)|(\s+|　+)$/,'')!=getCookie('regimcode')){
    alert('验证码不符！');
	theForm.imcode.focus();
    return false;
  }
  return true;
}

//过滤禁止字符
function chkWord(obj){
  if(obj.value.match(/[\s\"\'\\]+/)){
    alert('所填内容不能含 空格 及 \' " \\ ');
    obj.value=obj.value.replace(/[\s\"\'\\]+/g,'');
    obj.focus();
  }
}
-->
</script>
</head>
<body>
<div id="session" class="session">
<button type="button" onclick="window.open('write.php?mode=<?php echo $web['sitemode']; ?>','_blank');" title="发布文章"><b><div class="send_write"></div></b></button>
  &nbsp;
</div>
<?php
if ($web['siteclose'] > 1) {
  @include ('inc/require/siteclose_why.txt');
}
?>
<div id="logo"><a href="<?php echo $web['path']; ?>"><img src="<?php echo $web['sitelogo']; ?>" /></a></div>
<div id="banner"><a href="member.php?get=mess&username=admin">给管理员写信</a></div>
<div class="column">
  <h5><a href="./">首页</a> &gt; 找回密码</h5>
</div>
<div class="body">
  <div class="output"><?php echo $text; ?></div>
</div>
<div id="foot">
  <?php @include ('inc/css/'.$web['sitemode'].'/foot.txt'); ?>
</div>

</body>
</html>