<?php
require_once '../include/adminfunction.php';
checkadmin();
function updatesettext($text){
	if($text=="")
		return "";
	$text = htmlspecialchars($text,ENT_QUOTES);
    return $text;
}


$action=var_request("action","");
$errmsg = "";
if($action=="ok"){

	$cusername =			updatesettext(var_request("username",""));
	$cpassword =			updatesettext(var_request("password",""));
	$cpassword2 =			updatesettext(var_request("password2",""));

	if($cusername=="" || $cpassword=="" || $cpassword!=$cpassword2 ){
		echo("<script language=\"JavaScript\">alert(\"账号密码不能为空，且两次密码必须一样。\");history.go(-1);</script>");
		exit;
	}

	$pagetext = '$rootroad = "'.$rootroad.'";   //网站所在目录'."\n";
	$pagetext = $pagetext.'$weijingtai="'.$weijingtai.'";  //开启伪静态'."\n";
	$pagetext = $pagetext.'$usernick="'.$usernick.'";  //淘宝昵称'."\n";
	$pagetext = $pagetext.'$userpid="'.$userpid.'";  //阿里妈妈PID'."\n";
	$pagetext = $pagetext.'$userpiddp="'.$userpiddp.'";  //阿里妈妈小PID'."\n";
	$pagetext = $pagetext.'$sitetitle="'.$sitetitle.'";  //网站TITLE'."\n";
	$pagetext = $pagetext.'$sitetitleurl="'.$sitetitleurl.'";  //网站域名'."\n";
	$pagetext = $pagetext.'$sitekey="'.$sitekey.'";  //SEO关键字'."\n";
	$pagetext = $pagetext.'$sitedesc="'.$sitedesc.'";  //SEO网页描述'."\n";
	$pagetext = $pagetext.'$beianxinxi="'.$beianxinxi.'";  //备案信息号'."\n";
	$pagetext = $pagetext.'$webcontact="'.$webcontact.'";  //站长联系方式'."\n";
	$pagetext = $pagetext.'$tongjidaima="'.$tongjidaima.'";  //统计脚本'."\n";
	$pagetext = $pagetext.'$setCacheTime="'.$setCacheTime.'";  //缓存时间'."\n";
	
	//原有的字段
	$pagetext = $pagetext.'$manage_adminname="'.$cusername.'";  //管理员账号'."\n";
	$pagetext = $pagetext.'$manage_adminpass="'.md5($cpassword).'";  //管理员密码'."\n";
	$pagetext = $pagetext.'$ArrayAppKey="'.$ArrayAppKey.'";  //AppKey'."\n";
	$pagetext = $pagetext.'$ArrayAppSecret="'.$ArrayAppSecret.'";  //AppSecret'."\n";
	$pagetext = $pagetext.'$templatefolder="'.$templatefolder.'";  //templatefolder'."\n";
	$pagetext = $pagetext.'define(\'ROOT\',dirname(__FILE__)."/");'."\n";
	
	//写入到缓存中.
	file_put_contents ( "../data/configdata.php", "<?php \n".$pagetext."\n?>");
	
	redirect_to("manageUser.php?add=ok");
	exit;
}



?>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>315爱购网</title>
	<link rel='stylesheet' href='images/order.css'>
    <style type="text/css">
<!--
.STYLE2 {color: #FF0000}
-->
    </style>
</head>

<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<center>
<?php if(var_request("add","")=="ok"){?>
<table width="96%" border="0" cellpadding="3" cellspacing="1" bgcolor="#cccccc">
  <tr>
    <td height="30" colspan="2" align="center" bgcolor="#FFFFCC"><a href="manageUser.php"><span class="STYLE2">修改成功！</span></a> </td>
  </tr>
</table>
<?php }?>
<form name="form1" method="post" action="manageUser.php?action=ok">
<table width="96%" border="0" cellpadding="3" cellspacing="1" bgcolor="#cccccc">
  <tr>
    <td height="30" colspan="2" bgcolor="white">&nbsp;</td>
  </tr>
  <tr bgcolor="#c8ddf4">
    <td align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669">账号：</td>
    <td bgcolor="#ffffff"><input type="text" name="username" id="txtrootroad" value="<?php echo $manage_adminname ?>" style="width:150px;"></td>
  </tr>
  <tr bgcolor="#c8ddf4">
    <td align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669">新密码：</td>
    <td bgcolor="#FFFFFF">
      <label>
        <input type="password" name="password" value="" style="width:150px;">
        </label>    </td>
  </tr>
  <tr bgcolor="#c8ddf4">
    <td width="25%" align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669">确认密码：</td>
    <td width="75%" bgcolor="#ffffff"><input type="password" name="password2" value="" style="width:150px;"></td>
  </tr>
  <tr bgcolor="#c8ddf4">
    <td align="right" bgcolor="#FFFFFF" class="paragraph" title="20039669">&nbsp;</td>
    <td bgcolor="#ffffff"><label>
      <input type="submit" name="button" id="button" value="提交">
      <input type="reset" name="button2" id="button2" value="重置">
    </label></td>
  </tr>
</table>
</form><br>


<table width="96%" height="91" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td height="1" bgcolor="#b2b2b2"></td>
  </tr>
  <tr>
    <td height="90" align=center>
<br> 
<p>&nbsp;    </p>

      </td>
  </tr>
</table>
</center>
</body>
</html>
