<?php
/**
 * @version        Somao_Search X1.0 9:23 2012-1-1 Somao $
 * @package        Somao_Search.Site
 * @copyright      Copyright (c) 2009 - 2012, Somao, Inc.
 * @license        http://www.somao123.com/
 * @link           http://www.somao.cc/
 */
require_once("global.php");
is_login();
$action=trim(HtmlReplace($_REQUEST["action"]));
switch($action)
{
     case "saveinfo":
	       $email=HtmlReplace(trim($_POST["email"]));
		   $question=HtmlReplace(trim($_POST["question"]));
		   $answer=HtmlReplace(trim($_POST["answer"]));
		   if(empty($answer))
		   {
		        $array=array('email'=>$email,'question'=>$question);
		   }
		   else
		   {
		        $array=array('email'=>$email,'question'=>$question,'answer'=>md5($answer));
		   }
		   $db->update("ve123_member",$array,"user_name='".$user["user_name"]."'");
		   header("location:user.php?msg=".urlencode("修改信息成功"));
	 break;
	 case "saveepw":
	       $oldpassword=trim(HtmlReplace($_POST["oldpassword"]));
		   $newpassword=trim(HtmlReplace($_POST["newpassword"]));
		   $array=array('email'=>$email);
		   if(md5($oldpassword)!=$user["password"])
		   {
		        header("location:user.php?action=epw&msg=".urlencode("旧密码不正确，请确认再输入!"));
		   }
		   else
		   {
		      $array=array('password'=>md5($newpassword));
		      $db->update("ve123_member",$array,"user_name='".$user["user_name"]."'");
			   header("location:user.php?action=epw&msg=".urlencode("更新密码成功!"));
		   }
	 break;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
		<title>首页--<?php echo $pagetitle;?></title>
       <link href="/css/union.css" rel="stylesheet" type="text/css" />
	</head>
<body>
<?php
if($action=="")
{
?>
<div id="body">
<form name="form1" method="post" action="user.php">
<input type="hidden" name="action" value="saveinfo">
<table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#39867B">
  <tr>
    <td class="title">修改注册信息</td>
  </tr>
  <tr>
    <td valign="top" bgcolor="#EFEFEF">
     <table width="80%" border="0" align="center" cellpadding="0" cellspacing="0" class="table">
      <tr>
        <td width="11%">&nbsp;</td>
        <td width="89%">&nbsp;</td>
      </tr>
      <tr>
       <td><div align="right">用户名：</div></td>
       <td><?php echo $user["user_name"];?></td>
      </tr>
      <tr>
          <td><div align="right">真实姓名：</div></td>
          <td><?php echo $user["real_name"];?></td>
      </tr>

      <tr>
        <td><div align="right">联系QQ：</div></td>
        <td>
            <input name="qq" type="text" value="<?php echo $user["qq"];?>" id="qq" class="input" />
          </td>
      </tr>
      <tr>
        <td><div align="right">联系邮箱：</div></td>
        <td>
            <input type="text" name="email" value="<?php echo $user["email"];?>">
          </td>
      </tr>
      <tr>
         <td><div align="right">找回密码问题：</div></td>
         <td><input name="question" type="text" size="60"  value="<?php echo $user["question"];?>"/></td>
      </tr>
      <tr>
        <td><div align="right">找回密码答案：</div></td>
        <td><input name="answer" type="text" size="60" />(如不修改试表留空)</td>
      </tr>
      <tr>
        <td height="32">&nbsp;</td>
        <td>
            <input type="submit" name="Button1" value=" 确 定 " id="Button1" class="button" />
          </td>
      </tr>
    </table></td>
  </tr>
</table>
<div>
<?php
}
elseif($action=="epw")
{
?>
<form id="form2" name="form2" method="post" action="user.php">
<input type="hidden" name="action" value="saveepw" />
<div id="body">
<table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#39867B">
  <tr>
    <td class="title">修改密码</td>
  </tr>
  <tr>
    <td valign="top" bgcolor="#EFEFEF"><table width="80%" border="0" align="center" cellpadding="0" cellspacing="0" class="table">
      <tr>
        <td width="11%">&nbsp;</td>
        <td width="89%">&nbsp;</td>
      </tr>
      <tr>
          <td><div align="right">原密码：</div></td>
          <td><input type="text" name="oldpassword" /></td>
      </tr>
      <tr>
          <td><div align="right">新密码：</div></td>
          <td><input type="text" name="newpassword" /></td>
      </tr>
      <tr>
          <td><div align="right">确定新密码：</div></td>
          <td><input type="text" name="newpassword2" /></td>
      </tr>
      <tr>
        <td height="32">&nbsp;</td>
        <td>
            <input type="submit" name="Button1" value=" 确 定 " id="Button1" class="button" />
          </td>
      </tr>
      <tr>
        <td colspan="2">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
</table>
<div>
<?php
}
?>